How subnetting works
An IPv4 address is 32 bits. The prefix length (the number after the slash) says how many of those bits, counted from the left, identify the network; the rest identify the host inside it. 192.168.1.10/24 means the first 24 bits (192.168.1) are the network and the last 8 are the host, which gives 2⁸ = 256 addresses.
The subnet mask is the same information as a dotted number: 24 one-bits followed by 8 zero-bits is 255.255.255.0. AND the address with the mask and you get the network address; OR it with the inverted mask (the wildcard) and you get the broadcast address.
- Write the address and the mask in binary.
- Network address = address AND mask (host bits forced to 0).
- Broadcast address = address OR wildcard (host bits forced to 1).
- Usable hosts = everything in between, so 2host bits − 2.
Why two addresses are lost
The all-zeros host address names the network itself and the all-ones address is the broadcast, so a /24 has 254 usable hosts, not 256. The exceptions are point-to-point links: a /31 uses both addresses as hosts (RFC 3021) and a /32 is a single host route.
Quick reference
| Prefix | Mask | Addresses | Usable |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 | 1 (host route) |
Private and special ranges
10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private (RFC 1918) and never routed on the internet. 100.64.0.0/10 is carrier-grade NAT space, 169.254.0.0/16 is link-local, 127.0.0.0/8 is loopback, and 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24 are reserved for documentation. The calculator labels these automatically.
Questions
How many hosts are in a /24?
256 addresses, of which 254 are usable: one is the network address and one is the broadcast.
What is the difference between a subnet mask and a wildcard mask?
They are bit-for-bit inverses. The subnet mask has 1s over the network bits (255.255.255.0); the wildcard has 1s over the host bits (0.0.0.255). Cisco access lists and OSPF configuration use wildcard masks.
What does CIDR mean?
Classless Inter-Domain Routing. It replaced the old class A/B/C system with a prefix length that can be any value from 0 to 32, so address blocks can be sized to fit. The /24 notation is CIDR notation.
How do I split a /24 into four subnets?
Add two bits to the prefix: four /26 subnets of 64 addresses each (.0, .64, .128, .192). Choose /26 in the split section above to see the table with each subnet's range.
Is 172.20.1.1 a private address?
Yes. 172.16.0.0/12 covers 172.16.0.0 through 172.31.255.255, so anything from 172.16.x.x to 172.31.x.x is private.
Why is my /31 showing two usable hosts?
RFC 3021 allows /31 on point-to-point links, where there is no need for a broadcast address. Both addresses are assigned to the two ends of the link. Most modern routers support it.