The CIDR prefix reference: masks, hosts, and block sizes
CIDR replaced the old classful system (Class A/B/C) with a single, uniform idea: a prefix length from /0 to /32 that says how many leading bits are the network. That one number determines everything else about the block — its subnet mask, its wildcard, how many total addresses it holds, and how many of those are usable for hosts. This converter is the lookup table: type a prefix and read the rest off.
Total addresses double every time the prefix shrinks by one. A /32 is one address, a /31 is two, a /30 is four, and so on up to /0, which is all 2³² addresses. Usable host count is total minus two for the reserved network and broadcast addresses — so a /24 gives 254 usable, a /25 gives 126, a /26 gives 62, a /27 gives 30, a /28 gives 14. Memorizing the small end of this table (28 through 30) saves real time when you're hand-carving address space.
The /31 and /32 rows are reported per RFC 3021, not by the naive 2^n − 2 formula. A /30 has been the traditional choice for point-to-point links — 4 addresses, 2 usable — but it wastes half the block on the network and broadcast you can't use. A /31 gives both of its 2 addresses to the two ends of the link, which is why modern router-to-router links increasingly use /31s. A /32 is a single host route, used for loopbacks and host-specific entries.
Use this when you're sizing subnets and need to match a host requirement to a prefix. Need room for 50 hosts? A /26 (62 usable) fits and a /27 (30) doesn't, so /26 is the smallest that works. Working the other way, an unfamiliar prefix like /22 resolves to mask 255.255.252.0, 1024 total addresses, 1022 usable — the size of four /24s combined.
Worked example
A subnet needs to hold 50 hosts and you want the smallest prefix that fits.
- /27 = 2⁵ = 32 total, 30 usable — too small
- /26 = 2⁶ = 64 total, 62 usable — fits
- /26 mask = 255.255.255.192, wildcard 0.0.0.63
→ Use a /26: 62 usable hosts, mask 255.255.255.192. The /27 below it tops out at 30.