First published by DailyDebian. The one-page version, with a free PDF, is the Subnetting Cheat Sheet.
Subnetting is on both CompTIA Network+ and Cisco CCNA. It also turns up in every network job you will ever have. Most people find it hard because they learn it as binary arithmetic and then try to do binary in their head on a timer. There is a faster way. You only need one number, the block size, and four short steps.
The one table worth memorising
Every step down in prefix length doubles the number of addresses. If you know that a /24 has 256 addresses, you can build the rest:
| CIDR | Mask | Usable hosts |
|---|---|---|
| /30 | 255.255.255.252 | 2 |
| /29 | 255.255.255.248 | 6 |
| /28 | 255.255.255.240 | 14 |
| /27 | 255.255.255.224 | 30 |
| /26 | 255.255.255.192 | 62 |
| /25 | 255.255.255.128 | 126 |
| /24 | 255.255.255.0 | 254 |
| /23 | 255.255.254.0 | 510 |
| /22 | 255.255.252.0 | 1,022 |
"Usable hosts" is the total number of addresses minus two. The first address in a subnet is the network address and the last is the broadcast address, so neither can go to a host. The formula is 2 to the power of h, minus 2, where h is the number of host bits.
Two exceptions are worth knowing. A /32 is one single host address. A /31 gives 2 usable addresses, but only on a point-to-point link.
The block size, or "magic number"
The block size is 256 minus the mask value in the octet that is not 0 or 255. Subnets always start on a multiple of the block size.
| Mask value | Block size |
|---|---|
| 128 | 128 |
| 192 | 64 |
| 224 | 32 |
| 240 | 16 |
| 248 | 8 |
| 252 | 4 |
| 254 | 2 |
Once you have the block size, you never need to convert anything to binary.
The four steps
Take 192.168.10.77/26 as the example.
1. Find the mask. A /26 is 255.255.255.192. The fourth octet is the one that is neither 0 nor 255, so that is where the work happens.
2. Find the block size. 256 minus 192 is 64. Subnets in that octet start at .0, .64, .128 and .192.
3. Find the network address. Take the highest multiple of 64 that is not above 77. That is 64, so the network is 192.168.10.64.
4. Find the broadcast and the host range. The next subnet starts at .128, so the broadcast is one less: 192.168.10.127. The usable hosts are .65 to .126, which is 62 hosts.
That is the whole method. With practice it takes well under a minute, and it works the same in any octet.
Going the other way: "how many hosts do I need?"
Exams love this question. You get a number of hosts and must choose the smallest subnet that fits. Always round up:
- Up to 14 hosts: /28
- Up to 30 hosts: /27
- Up to 62 hosts: /26
- Up to 126 hosts: /25
So a subnet for 50 hosts cannot be a /27, because that only gives 30. The answer is /26, with 62.
Ranges you should recognise on sight
- 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private (RFC 1918). The 172 range runs from 172.16.0.0 to 172.31.255.255. That makes 172.32.0.1 a public address, which is a favourite trick question.
- 127.0.0.0/8 is loopback. 127.0.0.1 is the local machine.
- 169.254.0.0/16 is APIPA, or link-local. If a device has one of these, it failed to get a DHCP address. It does not mean the network is fine.
- 100.64.0.0/10 is the shared space used for carrier-grade NAT.
- 224.0.0.0/4 is multicast, the old class D.
Common exam traps
- The network and broadcast addresses cannot be assigned to a host.
- A wildcard mask, used in access lists and OSPF, is 255.255.255.255 minus the subnet mask. For a /26 that gives 0.0.0.63.
- Classful addressing is no longer used for routing, but exams still ask about classes. Class A starts at 1 to 126, B at 128 to 191 and C at 192 to 223.
- IPv6 has no broadcast at all. It uses multicast (ff00::/8) instead, and a normal LAN subnet is a /64.
How to make it stick
Reading the method once is not enough. What works is doing 10 to 20 random questions a day for a week, until the block sizes come without thinking. Then check yourself against a calculator, so you know your answers are right and you are not drilling a mistake.
Some free tools for that:
- Subnetting practice: unlimited random questions at three levels, with worked answers.
- Subnet calculator: network, broadcast, host range, mask, wildcard and binary for any IPv4 address.
- CIDR calculator and VLSM planner: for splitting one block into several subnets of different sizes.
- Wildcard mask calculator: for Cisco access lists.
The full cheat sheet, with every prefix from /32 to /8, an IPv6 quick reference and a printable one-page PDF, is here: Subnetting Cheat Sheet.
![AMR AI and Embodied Intelligence — Ch.12: Scene Understanding [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F3xad6ecur51evijoziky.png)
![AMR AI and Embodied Intelligence — Ch.15: Embodied AI [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F2b7ws9pmj9fexqpbtl14.png)
![AMR AI and Embodied Intelligence — Ch.16: Edge AI for AMR [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmqp31rp4k9dph48ghovh.png)
![AMR AI and Embodied Intelligence — Ch.17: Low Mid High AI Architecture [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F9g5fenohiv4y3nawwklt.png)
![AMR AI and Embodied Intelligence — Ch.18: GPU and Accelerator Design [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fospxyzadkcmpo8xjqyok.png)
![AMR AI and Embodied Intelligence — Ch.19: Cloud Robot Architecture [EN]](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F59osofl1km4y8vngcpzs.png)