The rule
A subnet with h host bits has 2h addresses, two of which are reserved for the network and broadcast. To fit N hosts you need the smallest h that satisfies:
Special cases: one host is a /32 and two hosts fit a /31 (RFC 3021, point-to-point only).
Worked example: 50 hosts
N + 2 = 52. The next power of two is 64 = 26, so h = 6 and the prefix is /26 (mask 255.255.255.192). A /26 gives 62 usable addresses, leaving 12 spare (19.4%). The next size up, /25, gives 126 hosts.
Reference table
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /30 | 255.255.255.252 | 4 | 2 |
| /29 | 255.255.255.248 | 8 | 6 |
| /28 | 255.255.255.240 | 16 | 14 |
| /27 | 255.255.255.224 | 32 | 30 |
| /26 | 255.255.255.192 | 64 | 62 |
| /25 | 255.255.255.128 | 128 | 126 |
| /24 | 255.255.255.0 | 256 | 254 |
| /23 | 255.255.254.0 | 512 | 510 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /21 | 255.255.248.0 | 2,048 | 2,046 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
Count more than end users
The host count a subnet must hold is rarely just the number of people. Before sizing, add:
- The gateway address, plus two more if you run HSRP/VRRP (one per router plus the virtual IP).
- Printers, APs, IP phones, cameras and IoT devices that share the VLAN.
- DHCP churn: devices that reconnect with a new MAC (randomized MACs on phones and laptops) can hold leases until they expire.
- Growth over the expected life of the design, typically three to five years.
A good rule of thumb is to size for 1.5× the current count, then round up to the next prefix. In RFC 1918 space, address scarcity is rarely the constraint; broadcast domain size is. Keeping user VLANs at /24 or smaller limits ARP and broadcast traffic and makes failure domains easier to reason about.
Exam shortcut
For CCNA-style questions, memorize the powers of two up to 212 (4,096). Add 2 to the host count, find the first power of two that is equal or larger, and subtract its exponent from 32. For 500 hosts: 502 → 512 = 29 → /23. For 1,000 hosts: 1,002 → 1,024 = 210 → /22. If the question also gives a number of subnets, check that the borrowed bits still leave enough room for both.
Applying it
! Cisco IOS DHCP pool for a /26 ip dhcp pool USERS network 10.10.20.0 255.255.255.192 default-router 10.10.20.1