Network Bytes · Episode 22 · CCNA 1.6
Subnetting trick: the magic number
You can find any subnet in your head with one subtraction. Take the part of the mask that isn't 255 or 0, subtract it from 256, and count up by the answer.
Step 1: find the interesting part
Every prefix length has a subnet mask. A /26 means the first 26 bits are the network part, which written in decimal is 255.255.255.192.
Look for the one part of the mask that isn't 255 or 0. That's the interesting octet, where the network part ends and the host part begins. In 255.255.255.192 it's the last part, 192.
Step 2: subtract it from 256
256 - 192 = 64. That 64 is the magic number, also called the block size: every subnet made with this mask is exactly 64 addresses wide.
Why 256? Each octet can hold 256 values (0 to 255). The mask takes some of them for the network and leaves the rest as the block.
Step 3: count up by the magic number
Start at 0 and keep adding 64: 0, 64, 128, 192. Each of those is where a subnet starts in that octet. With 192.168.1.0/26 that gives four subnets:
192.168.1.0(addresses .0 to .63)192.168.1.64(.64 to .127)192.168.1.128(.128 to .191)192.168.1.192(.192 to .255)
Step 4: place an address
Which subnet is 192.168.1.100 in? Look at the interesting octet, 100. It falls between 64 and 128, so it lives in the subnet that starts at 64: 192.168.1.64/26, which runs from .64 to .127.
Try it yourself
Try /27, whose mask is 255.255.255.224. The magic number is 256 - 224 = 32, so subnets start at 0, 32, 64, 96, 128, 160, 192 and 224. Which one holds 10.0.0.77? (It's between 64 and 96, so the subnet starting at 10.0.0.64.) Check your answer with any online IPv4 subnet calculator.
Good to know
- The trick works on the "interesting" part of the mask, the one that isn't 255 or 0. The block size is 256 minus that value.
192.168.1.100/26is in subnet192.168.1.64(range .64 to .127).- Masks that end exactly on a dot (
/8,/16,/24) have no interesting part: the block is a whole octet. - When the interesting part is in the second or third octet, the same trick works there; you just count up in that octet instead.
For CCNA learners
This lines up with CCNA 200-301 exam topic 1.6, configure and verify IPv4 addressing and subnetting: the block-size (magic number) method lets you find subnet boundaries quickly under exam time pressure, without writing out binary.
Answer to the comment question
The magic number for /27 is 32. Its mask is 255.255.255.224, the interesting part is 224, and 256 - 224 = 32. So every /27 block is 32 addresses wide, and the subnets start at 0, 32, 64, 96 and so on.
Test your knowledge
Quick quiz: Subnetting trick: the magic number
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "IP Addressing and Subnetting for New Users": worked subnetting examples; subnets of a 255.255.255.192 mask start at .0, .64, .128 and .192
- IETF, "RFC 4632, Classless Inter-domain Routing (CIDR)": prefix lengths and address blocks sized in powers of two
- Cisco, CCNA 200-301 v1.1 exam topics: 1.6 configure and verify IPv4 addressing and subnetting
Video transcript
How can you subnet in your head with one subtraction?
Take /26. Its mask is 255.255.255.192. Find the part that isn't 255 or 0. That's the one to watch, the interesting part.
Subtract it from 256. 256 minus 192 is 64. That's the magic number: the size of every block.
Now count up by 64, starting from zero: 0, 64, 128, 192. Each one is where a new subnet starts.
Where does 192.168.1.100 live? It's between 64 and 128. So it's in the subnet that starts at 64.
Your turn. /27's mask ends in 224. What's the magic number? Comment your answer below!
That's your byte.
More from Network Bytes
- EP17Duplex and speed mismatch
- EP18Collisions and why switches killed hubs
- EP19Binary in 60 seconds
- EP20What a subnet mask does