Subnetting Cheat Sheet
Exact IPv4 subnetting reference: CIDR prefix to subnet mask to host counts, wildcard masks, the block-size (magic number) method, powers of two, and the private/reserved ranges. Bookmark or print it for fast lookups during CML labs and the CCNA/CCNP exam.
Part of the Subnetting & IP Addressing learning hub
CIDR prefix → mask → hosts
Usable = 2^(32−prefix) − 2 (subtract network + broadcast); /31 = 2 (RFC 3021 P2P), /32 = 1. Block size = 256 − mask value in the interesting octet (3rd octet for /16–/23, 4th octet for /24–/30).
| Prefix | Subnet mask | Block size | Total | Usable | Wildcard |
|---|---|---|---|---|---|
/16 | 255.255.0.0 | 256 | 65536 | 65534 | 0.0.255.255 |
/20 | 255.255.240.0 | 16 | 4096 | 4094 | 0.0.15.255 |
/22 | 255.255.252.0 | 4 | 1024 | 1022 | 0.0.3.255 |
/23 | 255.255.254.0 | 2 | 512 | 510 | 0.0.1.255 |
/24 | 255.255.255.0 | 256 | 256 | 254 | 0.0.0.255 |
/25 | 255.255.255.128 | 128 | 128 | 126 | 0.0.0.127 |
/26 | 255.255.255.192 | 64 | 64 | 62 | 0.0.0.63 |
/27 | 255.255.255.224 | 32 | 32 | 30 | 0.0.0.31 |
/28 | 255.255.255.240 | 16 | 16 | 14 | 0.0.0.15 |
/29 | 255.255.255.248 | 8 | 8 | 6 | 0.0.0.7 |
/30 | 255.255.255.252 | 4 | 4 | 2 | 0.0.0.3 |
Powers of two
Each added host bit doubles the count; usable hosts = value − 2.
| 2^n | Value |
|---|---|
2^0 | 1 |
2^1 | 2 |
2^2 | 4 |
2^3 | 8 |
2^4 | 16 |
2^5 | 32 |
2^6 | 64 |
2^7 | 128 |
2^8 | 256 |
2^9 | 512 |
2^10 | 1024 |
Block-size (magic number) method
Interesting octet = first octet whose mask is not 255. Block size = 256 − that mask value. Networks start at 0 and count up by the block size; broadcast = next network − 1; hosts sit between network+1 and broadcast−1. Example below: /26 (mask 255.255.255.192, block size 256 − 192 = 64).
| Subnet # | Network ID | First host | Last host | Broadcast |
|---|---|---|---|---|
1 | 192.168.1.0/26 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 |
2 | 192.168.1.64/26 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 |
3 | 192.168.1.128/26 | 192.168.1.129 | 192.168.1.190 | 192.168.1.191 |
4 | 192.168.1.192/26 | 192.168.1.193 | 192.168.1.254 | 192.168.1.255 |
Private + reserved ranges
RFC 1918 blocks are not routed on the public Internet; the others are special-use.
| Range | CIDR | Use |
|---|---|---|
10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | RFC 1918 private |
172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | RFC 1918 private |
192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | RFC 1918 private |
127.0.0.0 – 127.255.255.255 | 127.0.0.0/8 | Loopback (localhost) |
169.254.0.0 – 169.254.255.255 | 169.254.0.0/16 | APIPA / link-local |
100.64.0.0 – 100.127.255.255 | 100.64.0.0/10 | CGNAT (RFC 6598) |
Wildcard masks
Wildcard = 255.255.255.255 − subnet mask (bitwise inverse). Used in ACLs and OSPF network statements: 'access-list <100-199> permit ip <src> <wildcard> <dst> <wildcard>' and 'network <ip> <wildcard> area <area-id>'. Shortcuts: 'host <ip>' = 0.0.0.0, 'any' = 0.0.0.0 255.255.255.255.
| Prefix | Subnet mask | Wildcard |
|---|---|---|
/8 | 255.0.0.0 | 0.255.255.255 |
/16 | 255.255.0.0 | 0.0.255.255 |
/20 | 255.255.240.0 | 0.0.15.255 |
/22 | 255.255.252.0 | 0.0.3.255 |
/23 | 255.255.254.0 | 0.0.1.255 |
/24 | 255.255.255.0 | 0.0.0.255 |
/25 | 255.255.255.128 | 0.0.0.127 |
/26 | 255.255.255.192 | 0.0.0.63 |
/27 | 255.255.255.224 | 0.0.0.31 |
/28 | 255.255.255.240 | 0.0.0.15 |
/29 | 255.255.255.248 | 0.0.0.7 |
/30 | 255.255.255.252 | 0.0.0.3 |
/32 | 255.255.255.255 | 0.0.0.0 |
Frequently asked questions
How do I find the number of usable hosts in a subnet?
Count the host bits h = 32 − prefix, then usable = 2^h − 2 (you subtract the network address and the broadcast address). Example: a /27 has 5 host bits, so 2^5 − 2 = 30 usable. Two exceptions: /31 gives 2 usable addresses (RFC 3021 point-to-point links, no broadcast), and /32 is a single host route.
What's the difference between a subnet mask and a wildcard mask?
A subnet mask is a block of contiguous 1s from the left (e.g., 255.255.255.0) that marks the network portion. A wildcard mask is its bitwise inverse (0.0.0.255) where a 0 means 'must match' and a 1 means 'don't care'; it's used in ACLs and OSPF network statements. Compute it as 255.255.255.255 − subnet mask, octet by octet.
How do I use the block-size (magic number) method quickly?
Find the interesting octet (the first mask octet that isn't 255), then block size = 256 − that octet's value. Subnets begin at 0 in that octet and count up by the block size (0, 64, 128, 192 for a /26). Each subnet's broadcast is one less than the next subnet's network, and the usable hosts fall between network+1 and broadcast−1.
Stop memorizing — practice on real Cisco IOS
A cheat sheet gets you unstuck; a graded lab makes it stick. Start with the free sample.