subnetting — ipv4
Netmasks and netblock sizes
The relationship between block size, netmask, Cisco "wildcard" bits, CIDR prefix length, and classful designation — for every IPv4 prefix from /16 to /32.
Block size
How many addresses are in the network. The all-zero address refers to the network itself and the all-one address is the broadcast — both unusable — so a given block has two fewer usable addresses than its literal size (except /31 and /32, handled specially below).
Netmask
The dotted-decimal mask applied against an address to define the network. All leading (leftmost) bits in a netmask are ones — e.g. a /22 network pairs with netmask 255.255.252.0.
Cisco wildcard bits
The inverse of the netmask, used in Cisco access-list configuration. It's one less than the block size — the wildcard defines every bit that's allowed to vary within the network.
CIDR prefix
The bit-length of the network part of the address — "/24" means the first 24 bits are fixed. A host route is /32; a full "C-sized" block is /24.
Host bits
The inverse of the prefix — how many bits are free within the network. It's also the exponent of 2 used to calculate block size mathematically.
Classful
A backwards-compatible reference to the archaic Class A/B/C/D/E scheme. Provided only because some people still think in those terms.
| Prefix | Block size | Netmask | Wildcard bits | Usable hosts | Host bits | Classful |
|---|---|---|---|---|---|---|
| /32 | 1 | 255.255.255.255 | 0.0.0.0 | 1 | 0 | subnet of Class C |
| /31 | 2 | 255.255.255.254 | 0.0.0.1 | 2 | 1 | subnet of Class C |
| /30 | 4 | 255.255.255.252 | 0.0.0.3 | 2 | 2 | subnet of Class C |
| /29 | 8 | 255.255.255.248 | 0.0.0.7 | 6 | 3 | subnet of Class C |
| /28 | 16 | 255.255.255.240 | 0.0.0.15 | 14 | 4 | subnet of Class C |
| /27 | 32 | 255.255.255.224 | 0.0.0.31 | 30 | 5 | subnet of Class C |
| /26 | 64 | 255.255.255.192 | 0.0.0.63 | 62 | 6 | subnet of Class C |
| /25 | 128 | 255.255.255.128 | 0.0.0.127 | 126 | 7 | subnet of Class C |
| /24 | 256 | 255.255.255.0 | 0.0.0.255 | 254 | 8 | Class C |
| /23 | 512 | 255.255.254.0 | 0.0.1.255 | 510 | 9 | subnet of Class B |
| /22 | 1,024 | 255.255.252.0 | 0.0.3.255 | 1,022 | 10 | subnet of Class B |
| /21 | 2,048 | 255.255.248.0 | 0.0.7.255 | 2,046 | 11 | subnet of Class B |
| /20 | 4,096 | 255.255.240.0 | 0.0.15.255 | 4,094 | 12 | subnet of Class B |
| /19 | 8,192 | 255.255.224.0 | 0.0.31.255 | 8,190 | 13 | subnet of Class B |
| /18 | 16,384 | 255.255.192.0 | 0.0.63.255 | 16,382 | 14 | subnet of Class B |
| /17 | 32,768 | 255.255.128.0 | 0.0.127.255 | 32,766 | 15 | subnet of Class B |
| /16 | 65,536 | 255.255.0.0 | 0.0.255.255 | 65,534 | 16 | Class B |
// thanks to Joe Provo for the original v4 reference this table is based on.
