Quick Answer — How Do You Calculate a CIDR Range?
The prefix says how many leading bits identify the network. Everything else follows from masking: Network = IP AND Mask, Broadcast = Network OR Wildcard, Total Addresses = 2^(32-prefix), and Usable Hosts = 2^(32-prefix) - 2 — the two exceptions being a /31, where RFC 3021 makes both addresses usable on a point-to-point link, and a /32, which is a single host route.
Worked example: `192.168.1.0/24`. Mask 255.255.255.0, wildcard 0.0.0.255, network 192.168.1.0, broadcast 192.168.1.255, usable range 192.168.1.1 – 192.168.1.254, 256 total addresses and 254 usable hosts. Scope: private, RFC 1918.
Common prefixes at a glance:
- /16 — mask 255.255.0.0, 65,536 addresses, 65,534 usable hosts
- /20 — mask 255.255.240.0, 4,096 addresses, 4,094 usable hosts
- /22 — mask 255.255.252.0, 1,024 addresses, 1,022 usable hosts
- /24 — mask 255.255.255.0, 256 addresses, 254 usable hosts
- /30 — mask 255.255.255.252, 4 addresses, 2 usable hosts
- /31 — mask 255.255.255.254, 2 addresses, 2 usable (RFC 3021 point-to-point)
- /32 — mask 255.255.255.255, 1 address, a single host route
Every bit added to the prefix halves the block. That is why /24 and /16 feel so far apart: eight bits of difference is a factor of 256.