One printable page for subnetting IPv4 without a chart: the four steps, the interesting octet for each prefix, mask values and increments, powers of two, and /0, /31 and /32.
Ask AI about this cheatsheetChatGPT, Claude, or any assistant
These open a new chat with a prompt that points the assistant to this cheatsheet. It only sees the cheatsheet if it can open the link. If it says it can't, use Copy cheatsheet for AI and paste the text into the chat.
Nothing goes to an AI service unless you choose one. AI answers can be wrong: check them against the cheatsheet before you change anything important.
The full explanation, with worked examples, is in Subnetting in Your Head. Practice with the Mental Subnetting Trainer; check answers with the IPv4 Subnet Calculator. Examples use documentation and private addresses.
The method is inspired by an explanation u/nivekami posted on r/ccna. This cheatsheet is written independently, in its own words, and isn't endorsed by that author.
The four steps#
- Interesting octet: the octet the prefix ends in (table below). Copy the octets before it.
- Increment: 2 to the power of the host bits left in that octet, which is 256 minus the mask value there.
- Block: round the address's value in that octet down to a multiple of the increment. The block ends at start + increment − 1.
- Fill in: network = block start, then 0 in every later octet. Broadcast = block end, then 255 in every later octet. Usable hosts are in between.
Example: 172.23.23.18/22 is the third octet, increment 4, 23 rounds down to 20, so the network is 172.23.20.0/22 and the broadcast is 172.23.23.255.
Which octet#
| Prefix | Interesting octet | Copy unchanged | Fill with 0s / 255s |
|---|---|---|---|
| /1 to /8 | first | none | second, third, fourth |
| /9 to /16 | second | first | third, fourth |
| /17 to /24 | third | first, second | fourth |
| /25 to /32 | fourth | first three | none |
Mask values and increments#
| Bits in the octet | Mask value | Increment | Prefixes |
|---|---|---|---|
| 1 | 128 | 128 | /1, /9, /17, /25 |
| 2 | 192 | 64 | /2, /10, /18, /26 |
| 3 | 224 | 32 | /3, /11, /19, /27 |
| 4 | 240 | 16 | /4, /12, /20, /28 |
| 5 | 248 | 8 | /5, /13, /21, /29 |
| 6 | 252 | 4 | /6, /14, /22, /30 |
| 7 | 254 | 2 | /7, /15, /23, /31 |
| 8 | 255 | 1 | /8, /16, /24, /32 |
With 8 bits, the prefix is octet-aligned: copy the octet as it is.
Powers of two#
Total addresses in a subnet = 2 to the power of (32 − prefix).
| Host bits | Addresses | Prefix |
|---|---|---|
| 0 | 1 | /32 |
| 1 | 2 | /31 |
| 2 | 4 | /30 |
| 3 | 8 | /29 |
| 4 | 16 | /28 |
| 5 | 32 | /27 |
| 6 | 64 | /26 |
| 7 | 128 | /25 |
| 8 | 256 | /24 |
| 10 | 1,024 | /22 |
| 12 | 4,096 | /20 |
| 16 | 65,536 | /16 |
| 20 | 1,048,576 | /12 |
| 22 | 4,194,304 | /10 |
| 24 | 16,777,216 | /8 |
| 32 | 4,294,967,296 | /0 |
Special prefixes#
| Prefix | Total | Usable | Notes |
|---|---|---|---|
| /30 | 4 | 2 | Network, two hosts, broadcast |
| /31 | 2 | 2 | Point-to-point link (RFC 3021): no network or broadcast address |
| /32 | 1 | 1 | Single-address route: host routes, loopbacks |
| /0 | 4,294,967,296 | Not meaningful | Default route: 0.0.0.0 to 255.255.255.255 |
Conventional usable hosts = total − 2, from /1 to /30 only; at /0 the count isn't meaningful.
Watch for#
- A host address isn't the network ID:
192.168.4.20/28is a host on192.168.4.16/28. - Fill every octet after the interesting one, not just the last.
- Round down, never to the nearest multiple.
- "How many subnets?" needs a parent prefix: a /24 holds 4 /26s; a /22 holds 16.
- "Subnet 3" needs a parent range and a starting count (0 or 1).
Sources and official documentation
Review history
- Technical review: Jeremiah Ellington,
- Editorial review: Jeremiah Ellington,
- Next scheduled review:
Spotted something out of date or wrong? Email a correction and I'll fix it. See how these guides are made.