How to Calculate Subnets in Your Head Without Binary Math
Published 3 min read
Want to check your work as you read? The free calculator at activeitprep.com/subnet shows each step below.
Subnetting has a reputation for being painful, mostly because most guides start by converting everything to binary. You can skip that. Once you know the Magic Number method, you can find a subnet's network ID, broadcast address, and usable range with simple decimal math. I used it to pass Network+, and it's what I teach.
The three steps
1. Find the interesting octet. This is the octet where the mask is neither 255 nor 0. For /25 it's the 4th octet, for /20 it's the 3rd, for /12 it's the 2nd.
2. Find the block size. Block size is 256 minus the mask value in that octet. Another way to see it: halve 256 once for every bit borrowed in that octet.
3. Count up by the block size. Start at 0 and count up until you pass the address's value in that octet. The multiple at or below it is the network ID. The broadcast is one less than the next multiple. The usable hosts are everything between.
Example 1: 192.168.14.77/27
- /27 borrows 3 bits in the 4th octet (27 - 24 = 3)
- Halve 256 three times: 256 / 2 / 2 / 2 = 32, so the block size is 32
- Mask: 256 - 32 = 224, so 255.255.255.224
- Count by 32: 0, 32, 64, 96. The value 77 sits in the 64 block
- Network ID: 192.168.14.64
- Next block starts at 96, so the broadcast is 192.168.14.95
- Usable range: 192.168.14.65 to 192.168.14.94 (30 hosts)
Example 2: when the interesting octet isn't the last one
Take 10.45.130.9/20.
- /20 borrows 4 bits in the 3rd octet (20 - 16 = 4), so the interesting octet is the third
- Block size: 256 / 2 / 2 / 2 / 2 = 16, mask 255.255.240.0
- Count by 16 in the 3rd octet: ..., 112, 128, 144. The value 130 sits in the 128 block
- Network ID: 10.45.128.0
- Next block starts at 144, so the broadcast is 10.45.143.255
- Usable range: 10.45.128.1 to 10.45.143.254 (4,094 hosts)
Everything after the interesting octet is 0 for the network and 255 for the broadcast.
Quick reference
| CIDR | Mask (last octet) | Block size | Usable hosts |
|---|---|---|---|
| /25 | 128 | 128 | 126 |
| /26 | 192 | 64 | 62 |
| /27 | 224 | 32 | 30 |
| /28 | 240 | 16 | 14 |
| /29 | 248 | 8 | 6 |
| /30 | 252 | 4 | 2 |
Usable hosts is always total addresses minus 2, because the first address is the network ID and the last is the broadcast. Two special cases: /31 (point-to-point links, RFC 3021) has no network or broadcast address, and /32 is a single host.
Try these
- 172.16.50.200/26
- 192.168.1.100/28
- 10.20.77.5/21
Answers:
- Network 172.16.50.192, broadcast 172.16.50.255, usable .193 to .254 (62 hosts)
- Network 192.168.1.96, broadcast 192.168.1.111, usable .97 to .110 (14 hosts)
- Network 10.20.72.0, broadcast 10.20.79.255, usable 10.20.72.1 to 10.20.79.254 (2,046 hosts)
If you want more reps, there are 20 graded problems in the practice tab at activeitprep.com/subnet. I built the calculator and it's free with no signup. I'd like to hear about any answer that looks wrong.