Skip to main content
Your first session is free. Claim mine
PacketMentor logo
Open menu
Home
Training
CCNA Library (74)
Browse all CCNA topics →
Network (13)
Device Operations (5)
Network Access (12)
Wireless (6)
IP Connectivity (10)
IP Services (11)
Security (10)
Automation (7)
CCNP Library (15)
LabsPricing
Contact 📞 +1 (860) 556-3010 Book a Call
← All posts
ccnasubnettingfundamentals

Subnetting in Your Head — The Magic-Number Trick (CCNA)

The one method that turns CCNA subnetting from 'do the binary math' into 'glance at the mask, subtract, done'. Worked examples for /27, /28, /22, /21.

If subnetting feels like binary-math homework every time, you’re doing it the slow way. There’s a trick — the magic number — that turns the whole thing into a 10-second mental calculation. Once you have it, you’ll never go back to writing out 32-bit binary on scratch paper.

The idea

Every subnet mask “splits” one octet of the IP address. The size of each subnet’s block, in that octet, is the magic number: 256 − the mask value of that octet.

That’s the whole trick.

Walk through /27

A /27 mask is 255.255.255.224. The interesting octet is the fourth (the only one that isn’t 0 or 255).

Magic number = 256 − 224 = 32.

So subnets in a /27 are 32 addresses wide. Networks land at multiples of 32:

192.168.10.0  /27   →  hosts .1   – .30,   broadcast .31
192.168.10.32 /27   →  hosts .33  – .62,   broadcast .63
192.168.10.64 /27   →  hosts .65  – .94,   broadcast .95
192.168.10.96 /27   →  hosts .97  – .126,  broadcast .127

Given an IP like 192.168.10.50/27 — what’s its subnet?

Magic number is 32. The largest multiple of 32 that’s ≤ 50 is 32. So the subnet is 192.168.10.32/27. Broadcast is 192.168.10.63. Usable hosts are .33 through .62. Done in 5 seconds, no binary.

Walk through /28

Mask 255.255.255.240. Magic number = 256 − 240 = 16.

Subnets are 16 addresses wide: .0, .16, .32, .48, .64, … .240.

192.168.10.45/28 → biggest multiple of 16 ≤ 45 is 32. Subnet = 192.168.10.32/28. Broadcast = 192.168.10.47. Hosts .33.46.

Walk through /22

Now the interesting octet is the third (because /22 borrows into octet 3).

Mask 255.255.252.0. Magic number = 256 − 252 = 4.

Subnets are 4 addresses wide in the third octet: 0.0, 4.0, 8.0, 12.0, …

172.16.10.0/22 → biggest multiple of 4 ≤ 10 is 8. Subnet = 172.16.8.0/22. The full range covers 172.16.8.0 through 172.16.11.255. Broadcast = 172.16.11.255. That’s 1,024 addresses, 1,022 usable hosts.

Walk through /21

Mask 255.255.248.0. Magic number = 256 − 248 = 8.

Subnets are 8 addresses wide in the third octet: 0.0, 8.0, 16.0, 24.0, …

10.50.20.5/21 → biggest multiple of 8 ≤ 20 is 16. Subnet = 10.50.16.0/21, range 10.50.16.010.50.23.255. Broadcast = 10.50.23.255.

The whole process — 5 steps

  1. Identify the interesting octet (the one where the mask isn’t 0 or 255).
  2. Compute the magic number: 256 − mask value of that octet.
  3. Find the biggest multiple of the magic number that’s ≤ the IP’s value in that octet → that’s your subnet’s network address for that octet.
  4. Broadcast = network address + magic number − 1.
  5. Usable hosts = network address + 1 through broadcast − 1.

That’s it. The same five steps work for every mask between /9 and /30.

Memorize the mask table

Don’t compute masks every time — memorize the 8 values:

BitsMask value
1128
2192
3224
4240
5248
6252
7254
8255

A /27 mask in the fourth octet has 3 borrowed bits → look up “3” → 224. /22 mask in the third octet has 6 borrowed bits → “6” → 252.

How many subnets / how many hosts?

  • Subnets = 2^(borrowed bits). /27 from a /24 = 3 borrowed bits = 8 subnets.
  • Hosts per subnet = 2^(host bits) − 2. /27 has 5 host bits = 2^5 − 2 = 30 hosts.

These are the only formulas you need. Combined with the magic-number trick, you can answer any CCNA subnetting question in under a minute.

A quick drill

Find subnet, broadcast, and usable host range for each:

  1. 192.168.20.85/29
  2. 10.1.1.100/26
  3. 172.20.5.5/23
  4. 192.168.0.200/27

Try it before looking. Answers below.


Answers:

  1. /29 → magic 8. 85 → biggest mult of 8 ≤ 85 = 80. Subnet 192.168.20.80/29, broadcast .87, hosts .81–.86.
  2. /26 → magic 64. 100 → biggest mult of 64 ≤ 100 = 64. Subnet 10.1.1.64/26, broadcast .127, hosts .65–.126.
  3. /23 → mask 255.255.254.0. Third octet interesting, magic = 256 − 254 = 2. 5 → biggest mult of 2 ≤ 5 = 4. Subnet 172.20.4.0/23, broadcast 172.20.5.255, hosts 172.20.4.1 – 172.20.5.254.
  4. /27 → magic 32. 200 → biggest mult of 32 ≤ 200 = 192. Subnet 192.168.0.192/27, broadcast .223, hosts .193–.222.

If you got 3 of 4 right, you’ve got the technique. If you missed any, you probably forgot to identify the interesting octet first — that’s the #1 mistake.

Where to go from here

If you want more — the full Subnetting library topic covers the binary-math version (slower but more rigorous), VLSM (variable-length masks for efficient address allocation), and the “I have a /24 — give me four equal subnets” pattern. The magic-number trick covers 95% of what you’ll see on the CCNA exam.

Get posts like this by email.

One short, opinionated tutorial per week. Unsubscribe in one click.

We respect your inbox. One email per week, max. Unsubscribe any time.

Start typing — or browse popular topics below.

↑↓ navigate open Searches topics · labs · programs · pages