Guide
How to calculate a CIDR prefix from the required host count
Choose the smallest IPv4 subnet for a host count and calculate host bits, prefix, mask, and capacity with examples.
by Tools in a Tab · Published on · Reviewed on
Short answer
To select an IPv4 prefix from a host count, find the smallest number of host
bits h for which 2^h - 2 ≥ required hosts in a traditional subnet. Then
calculate the prefix as 32 - h. Fifty hosts need six bits because
2^6 - 2 = 62, so the corresponding prefix is /26.
Worked example for 50 hosts
Try the smallest candidate sizes first:
5 host bits → 2⁵ = 32 addresses → 30 usable hosts
6 host bits → 2⁶ = 64 addresses → 62 usable hosts
Five bits are insufficient and six are enough. The prefix is therefore:
32 - 6 = /26
Its dotted-decimal mask is 255.255.255.192. Enter /26 in the
IPv4 subnet calculator to confirm 64 total
addresses and 62 traditionally usable addresses.
Quick capacity table
| Required hosts | Smallest prefix | Total addresses | Traditional hosts |
|---|---|---|---|
| 2 | /30 |
4 | 2 |
| 14 | /28 |
16 | 14 |
| 30 | /27 |
32 | 30 |
| 50 | /26 |
64 | 62 |
| 100 | /25 |
128 | 126 |
| 200 | /24 |
256 | 254 |
The table is not a complete network plan. Reserve room for future devices, infrastructure interfaces, and design changes before assigning the final block.
Why two addresses are subtracted
In a conventional IPv4 subnet, the first address identifies the network and
the last is the directed broadcast address. Usable capacity is consequently
calculated as 2^h - 2.
There are exceptions. On a /31 point-to-point link, both addresses can name
the endpoints and no dedicated broadcast address exists. A /32 identifies a
single host route. Do not apply the “minus two” formula to those prefixes.
From capacity to an actual block
Choosing /26 does not make every address a valid network address. Within a
/24, /26 networks advance in blocks of 64:
192.168.10.0/26
192.168.10.64/26
192.168.10.128/26
192.168.10.192/26
192.168.10.50/26 is a host inside the first network, not the network address.
The calculator normalizes the input and shows the correct boundary.
Frequent mistakes
- Choosing the first block whose total exceeds the host count without reserving network and broadcast addresses.
- Subtracting the reserved addresses twice.
- Confusing the number of hosts with the number of subnets.
- Writing a host address as though it were the network address.
- Applying the traditional formula to
/31and/32. - Sizing exactly to today’s limit without operational headroom.
RFC 4632 describes CIDR prefix lengths and power-of-two block sizes. Calculate capacity first, verify block alignment next, and finally document the reservations used by the actual network.