How subnetting works
An IPv4 address has 32 bits. The prefix length (for example /24) says how many leading bits identify the network; the remaining bits number the hosts. The first address in a subnet is the network address and the last is the broadcast address, so usable hosts = 2host bits − 2.
Subnet cheat sheet
| CIDR | Mask | Usable hosts |
|---|---|---|
| /30 | 255.255.255.252 | 2 |
| /29 | 255.255.255.248 | 6 |
| /28 | 255.255.255.240 | 14 |
| /27 | 255.255.255.224 | 30 |
| /26 | 255.255.255.192 | 62 |
| /25 | 255.255.255.128 | 126 |
| /24 | 255.255.255.0 | 254 |
| /23 | 255.255.254.0 | 510 |
| /22 | 255.255.252.0 | 1,022 |
| /16 | 255.255.0.0 | 65,534 |
Private address ranges (RFC 1918)
10.0.0.0/8 · 172.16.0.0/12 · 192.168.0.0/16. These are not routed on the public internet.
Frequently asked questions
How many hosts are in a /24?
254 usable hosts out of 256 addresses.
What is a wildcard mask?
The inverse of the subnet mask, used in Cisco ACLs and OSPF. For /24 it is 0.0.0.255.
Why does /31 have 2 usable hosts?
RFC 3021 allows /31 on point-to-point links, where no network or broadcast address is needed.