What is a subnet calculator?
A subnet calculator does the binary side of subnetting for you. Give it an IPv4 address and a mask, or a prefix such as /24, and it works out the subnet that address belongs to: where it starts, where it ends and how many devices fit inside.
For every address you get the network and broadcast addresses, the first and last host you can really assign, the host count, the subnet and wildcard masks, the mask in binary, and what kind of address it is (private, public, loopback and so on).
People use it when they're splitting up an office or lab network, writing a firewall or ACL rule, checking whether two machines can talk without a router, or practising for an exam like CCNA. Working one out by hand is great practice. Working out twenty in a row is where a calculator pays off.
How to use this calculator
It takes about ten seconds once you've done it once. There are only a few steps.
Type the address in the first box, for example 192.168.0.1. That's four numbers between 0 and 255, separated by dots. The box only takes digits and dots (a comma is turned into a dot, which helps on phone keyboards). If something's off, like 256 or a leading zero such as 01, the field turns red and tells you what's wrong. IPv6 addresses aren't supported.
Either type a mask such as 255.255.255.0, or drag the CIDR slider anywhere from 0 to 32. The two are linked, so changing one updates the other. A bigger CIDR number means a smaller subnet.
10.0.5.17/22, paste it into the address box. The calculator splits it into address, CIDR and mask for you.The table refreshes with every keystroke. Network Address is the first address in the subnet and Broadcast Address is the last. Neither can go to a normal device, so the range you can actually hand out runs from First Usable IP to Last Usable IP.
Total Usable Hosts is how many devices you can place in the subnet. Total Available Hosts is the raw count of addresses, network and broadcast included.
Subnet Mask and Wildcard Mask are opposites. Routers and firewalls tend to want the wildcard form in ACLs and OSPF statements. Binary Subnet Mask shows the same mask as 1s and 0s, which is handy for checking your own working. IP Type says whether the address is private, public, loopback, multicast and so on, along with its old class.
Copy puts the whole table on your clipboard as plain text. Download saves it as a CSV file that opens in Excel or Google Sheets. Both buttons stay greyed out while the address or mask has an error.
Common slip-ups
- The mask is rejected. A valid mask is a block of 1s followed by a block of 0s.
255.255.255.0works,255.0.255.0doesn't. - The host count looks two short. That's on purpose. A
/24has 256 addresses but only 254 can go to devices. - The table is empty. Look for a red message under the address or mask box.
How the subnet maths works
An IPv4 address is just a 32-bit number. The mask splits it in two: the 1s mark the network part and the 0s mark the host part. Every result on this page comes from a handful of operations on those bits.
There are two ways to reach the broadcast address, and they always agree. The bitwise way sets every host bit to 1, which is what the OR with the wildcard mask does. The shortcut adds the address count minus one to the network address: 192.168.0.0 + 255 = 192.168.0.255.
Worked example: 192.168.0.1/24
A /24 means the first 24 bits of the mask are 1s. Start by writing the address and the mask in binary:
AND the two lines together, keeping a 1 only where both lines have a 1. That gives the network address:
Flip every bit of the mask to get the wildcard mask:
OR the network address with the wildcard mask. Every host bit becomes a 1, and that's the broadcast address:
Last, count the hosts. 32 minus 24 leaves 8 host bits, so the block holds 28 = 256 addresses. Take away the network and broadcast addresses and 254 are left, running from 192.168.0.1 to 192.168.0.254.
Here's the same example in the calculator's own result table. It's built by the same code as the calculator above, so the two always match.
Why subtract 2?
The first address names the subnet and the last one is the broadcast address, so neither can go to a host. That's the whole reason for the minus 2. Two prefixes break the rule. A /31 is meant for point-to-point links between two routers (RFC 3021), so both addresses are usable and there's no broadcast. A /32 is one single host address.
IPv4 CIDR chart (/0 to /32)
Every prefix length from /0 to /32 with its subnet mask, wildcard mask and address counts. Usable hosts are the total minus 2, apart from /31 (2) and /32 (1).
| CIDR | Subnet mask | Wildcard | Total addresses | Usable hosts |
|---|
Standard IPv4 classes
Early IPv4 sorted addresses into classes by their first number, and each class came with a fixed mask. CIDR replaced that scheme in the 1990s, so you can use any prefix length today. Class names still turn up in textbooks, exams and some vendor docs, which is why they're listed here.
| Class | First number | IP range | Default mask | CIDR | Networks | Hosts per network | Used for |
|---|---|---|---|---|---|---|---|
| A | 1 – 126 | 1.0.0.0 – 126.255.255.255 | 255.0.0.0 | /8 | 126 | 16,777,214 | Very large networks |
| – | 127 | 127.0.0.0 – 127.255.255.255 | Not used | – | – | – | Loopback (reserved) |
| B | 128 – 191 | 128.0.0.0 – 191.255.255.255 | 255.255.0.0 | /16 | 16,384 | 65,534 | Medium networks |
| C | 192 – 223 | 192.0.0.0 – 223.255.255.255 | 255.255.255.0 | /24 | 2,097,152 | 254 | Small networks |
| D | 224 – 239 | 224.0.0.0 – 239.255.255.255 | Not used | – | – | – | Multicast |
| E | 240 – 255 | 240.0.0.0 – 255.255.255.255 | Not used | – | – | – | Reserved for research |
Class A stops at 126 because 0.0.0.0/8 means "this network" and 127.0.0.0/8 is loopback. Neither counts as a normal Class A network.
Private and special IPv4 ranges
These blocks are reserved for particular jobs. The second column shows the first and last address in each one.
| Range | IP range | Total addresses | Purpose |
|---|---|---|---|
| 10.0.0.0/8 | 10.0.0.0 – 10.255.255.255 | 16,777,216 | Private (RFC 1918) |
| 172.16.0.0/12 | 172.16.0.0 – 172.31.255.255 | 1,048,576 | Private (RFC 1918) |
| 192.168.0.0/16 | 192.168.0.0 – 192.168.255.255 | 65,536 | Private (RFC 1918) |
| 100.64.0.0/10 | 100.64.0.0 – 100.127.255.255 | 4,194,304 | Shared address space (carrier-grade NAT) |
| 127.0.0.0/8 | 127.0.0.0 – 127.255.255.255 | 16,777,216 | Loopback |
| 169.254.0.0/16 | 169.254.0.0 – 169.254.255.255 | 65,536 | Link-local (APIPA) |
| 224.0.0.0/4 | 224.0.0.0 – 239.255.255.255 | 268,435,456 | Multicast |