Subnet by host count
Working the subnet problem backwards: start from how many hosts you need, and get the smallest CIDR block that fits. Click any row for the full page with a live calculator, or look up a prefix directly on the CIDR cheat sheet.
| Hosts needed | Smallest prefix | Subnet mask | Usable hosts | Fit |
|---|---|---|---|---|
| 2 | /31 | 255.255.255.254 | 2 | Exact fit |
| 5 | /29 | 255.255.255.248 | 6 | +1 spare |
| 6 | /29 | 255.255.255.248 | 6 | Exact fit |
| 10 | /28 | 255.255.255.240 | 14 | +4 spare |
| 14 | /28 | 255.255.255.240 | 14 | Exact fit |
| 20 | /27 | 255.255.255.224 | 30 | +10 spare |
| 25 | /27 | 255.255.255.224 | 30 | +5 spare |
| 30 | /27 | 255.255.255.224 | 30 | Exact fit |
| 50 | /26 | 255.255.255.192 | 62 | +12 spare |
| 62 | /26 | 255.255.255.192 | 62 | Exact fit |
| 75 | /25 | 255.255.255.128 | 126 | +51 spare |
| 100 | /25 | 255.255.255.128 | 126 | +26 spare |
| 126 | /25 | 255.255.255.128 | 126 | Exact fit |
| 150 | /24 | 255.255.255.0 | 254 | +104 spare |
| 200 | /24 | 255.255.255.0 | 254 | +54 spare |
| 250 | /24 | 255.255.255.0 | 254 | +4 spare |
| 254 | /24 | 255.255.255.0 | 254 | Exact fit |
| 500 | /23 | 255.255.254.0 | 510 | +10 spare |
| 1,000 | /22 | 255.255.252.0 | 1,022 | +22 spare |
| 2,000 | /21 | 255.255.248.0 | 2,046 | +46 spare |
| 5,000 | /19 | 255.255.224.0 | 8,190 | +3,190 spare |
| 10,000 | /18 | 255.255.192.0 | 16,382 | +6,382 spare |
| 20,000 | /17 | 255.255.128.0 | 32,766 | +12,766 spare |
| 65,534 | /16 | 255.255.0.0 | 65,534 | Exact fit |
How to read this table
Each row starts from a host count and shows the smallest standard subnet that can hold it. "Exact fit" means the block's usable host count matches the requirement precisely, with no spare addresses. Anything else shows how much headroom that block leaves for growth, since no CIDR block covers every possible count exactly.
This table is built directly from the same CIDR math as the full cheat sheet: for every host count, it searches every prefix from /0 to /32 for the smallest block whose usable host count is at least the number you need. For the method behind it, read how to calculate a subnet mask.
Frequently asked questions
How do I find a subnet for a specific number of hosts?
Find the smallest power of two, minus two, that is greater than or equal to the host count you need. That determines how many host bits the block needs, which sets the prefix. The table below does this for common host counts.
Why is the host count usually 2 short of a power of two?
Every standard subnet reserves one address for the network itself and one for the broadcast address, so a block with h host bits has 2^h total addresses but only 2^h - 2 usable ones. The exceptions are /31, which uses both addresses under RFC 3021, and /32, a single host route.
What if my host count does not exactly match a block size?
Pick the smallest block whose usable host count is at least what you need. Any leftover addresses are spare capacity for growth, not wasted, since there is no CIDR block that fits every count exactly.
Is this list every possible host count?
No. This page curates the host counts people actually search for and design around: round numbers and the exact 2^h - 2 boundaries. For every prefix from /0 to /32, see the full CIDR cheat sheet.