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 neededSmallest prefixSubnet maskUsable hostsFit
2/31255.255.255.2542Exact fit
5/29255.255.255.2486+1 spare
6/29255.255.255.2486Exact fit
10/28255.255.255.24014+4 spare
14/28255.255.255.24014Exact fit
20/27255.255.255.22430+10 spare
25/27255.255.255.22430+5 spare
30/27255.255.255.22430Exact fit
50/26255.255.255.19262+12 spare
62/26255.255.255.19262Exact fit
75/25255.255.255.128126+51 spare
100/25255.255.255.128126+26 spare
126/25255.255.255.128126Exact fit
150/24255.255.255.0254+104 spare
200/24255.255.255.0254+54 spare
250/24255.255.255.0254+4 spare
254/24255.255.255.0254Exact fit
500/23255.255.254.0510+10 spare
1,000/22255.255.252.01,022+22 spare
2,000/21255.255.248.02,046+46 spare
5,000/19255.255.224.08,190+3,190 spare
10,000/18255.255.192.016,382+6,382 spare
20,000/17255.255.128.032,766+12,766 spare
65,534/16255.255.0.065,534Exact 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.