Skip to main content
PacketMentor logo
Open menu
← 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.

Verify on real IOS

The router-side proof — configure the address and read it back:

R1(config)# interface GigabitEthernet0/0
R1(config-if)# ip address 172.20.45.90 255.255.255.192
R1(config-if)# no shutdown
R1# show ip route connected
     172.20.0.0/16 is variably subnetted, 2 subnets, 2 masks
C       172.20.45.64/26 is directly connected, GigabitEthernet0/0
L       172.20.45.90/32 is directly connected, GigabitEthernet0/0

The C line confirms the subnet is 172.20.45.64/26 — exactly what the magic-number trick produces (magic 64, largest multiple of 64 ≤ 90 is 64).

Ten-question timed drill

Now put it under exam-day pressure. Set a 5-minute stopwatch — aim: all ten answered correctly in under 300 seconds. Compute in your head, no paper.

For each, give the subnet, broadcast, and usable host range.

  1. 192.168.20.85/29
  2. 10.1.1.100/26
  3. 172.16.200.5/29
  4. 192.168.10.150/28
  5. 10.10.10.10/30
  6. 172.20.5.5/23
  7. 192.168.0.200/25
  8. 10.50.100.100/22
  9. 172.16.16.99/21
  10. 192.168.5.5/28

Try before scrolling. 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 → subnet 10.1.1.64, broadcast 10.1.1.127, hosts .65 – .126.
  3. /29 → magic 8 → subnet 172.16.200.0, broadcast 172.16.200.7, hosts .1 – .6.
  4. /28 → magic 16 → subnet 192.168.10.144, broadcast 192.168.10.159, hosts .145 – .158.
  5. /30 → magic 4 → subnet 10.10.10.8, broadcast 10.10.10.11, hosts .9 – .10 (point-to-point, only 2 usable).
  6. /23, mask 255.255.254.0, magic 2 in 3rd octet → subnet 172.20.4.0, broadcast 172.20.5.255, hosts 172.20.4.1 – 172.20.5.254.
  7. /25 → magic 128 → subnet 192.168.0.128, broadcast 192.168.0.255, hosts .129 – .254.
  8. /22, mask 255.255.252.0, magic 4 in 3rd octet → subnet 10.50.100.0, broadcast 10.50.103.255, hosts 10.50.100.1 – 10.50.103.254.
  9. /21, mask 255.255.248.0, magic 8 in 3rd octet → subnet 172.16.16.0, broadcast 172.16.23.255, hosts 172.16.16.1 – 172.16.23.254.
  10. /28 → magic 16 → subnet 192.168.5.0, broadcast 192.168.5.15, hosts .1 – .14.

The #1 mistake

Forgetting to identify the interesting octet first. Students see /22 and reflexively work in the fourth octet — but /22 splits the third octet. Every wrong answer above traces back to this. Say the interesting octet out loud before you start computing.

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.

Drill the ten questions above twice this week. By exam day you’ll answer any subnetting question in under 30 seconds — and free up the minutes that decide pass or fail.

Get posts like this by email.

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

Personal reply from a senior network engineer. No third-party tracking. Unsubscribe any time.