Subnetting formula and usable hosts cheat sheet
Almost every CCNA subnetting question reduces to one formula and one shortcut. Learn both, then use the table at the bottom to check your work.
The usable hosts formula
An IPv4 address has 32 bits. If the prefix length is n, the number of host bits is h = 32 − n.
total addresses = 2^h usable hosts = 2^h − 2
You subtract two because the first address is the network address and the last is the broadcast address. Neither can be assigned to a host. For a /26: h = 6, 2^6 = 64 addresses, 64 − 2 = 62 usable hosts.
Find the subnet with the block-size method
Look at the interesting octet, the one where the mask is neither 0 nor 255. The block size is 256 minus the mask value in that octet, and subnets start at multiples of the block size.
Example: 192.168.10.70 with mask 255.255.255.192. The interesting octet is the fourth, and the block size is 256 − 192 = 64. Subnets begin at .0, .64, .128 and .192, so 70 belongs to the .64 subnet:
network 192.168.10.64 first host 192.168.10.65 last host 192.168.10.126 broadcast 192.168.10.127
The broadcast address is the next network address minus one. Try the same method on the subnetting practice questions.
How many subnets and how big?
- Borrowing bits: borrowing b bits from the host portion gives 2^b equal subnets. Splitting a /24 into four subnets borrows 2 bits and gives four /26 networks.
- Hosts needed: pick the smallest h where 2^h − 2 is at least the number of hosts. For 50 hosts, 2^5 − 2 = 30 is too small and 2^6 − 2 = 62 works, so h = 6 and the prefix is /26.
The /31 and /32 exceptions
The “minus two” rule is for ordinary broadcast subnets. A /32 is a single host route. A /31 has two addresses and is used on point-to-point links; under RFC 3021 both addresses are usable. If an exam question asks about usable hosts in a normal LAN subnet, apply 2^h − 2; if it describes a point-to-point link, read it carefully.
CIDR quick reference
Totals and usable hosts for common prefixes. The sizes follow directly from the formula above.
| Prefix | Subnet mask | Total addresses | Usable hosts |
|---|---|---|---|
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 512 | 510 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
Spot the pattern: every extra prefix bit halves the block. You can also rebuild the table from memory by starting at /24 = 256 and halving.
Sources and further reading
- RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links
- RFC 4632: Classless Inter-domain Routing (CIDR)
ccna.dev is independent and not affiliated with or endorsed by Cisco. Always confirm exam details with Cisco.