BeginnerNetwork Troubleshooting 7 min read

How to Calculate Subnets by Hand

The magic number method — find any subnet's network, broadcast, and host range in under 60 seconds

Subnetting by hand is a core skill for CCNA and Network+. You cannot rely on a calculator in the exam room. This guide teaches the 'magic number' method — a consistent 4-step process that lets you calculate any subnet's network address, broadcast address, and host range in under a minute.

1

Identify the interesting octet

The 'interesting octet' is the octet where subnetting is happening — where the subnet mask value is neither 0 nor 255. This is always the last non-255 octet in the mask.

Subnetting examples
! Example 1: 255.255.255.0
! Mask:   255.255.255.0
! Octet:  1st  2nd  3rd  4th
! Value:  255  255  255   0
! Interesting octet = 3rd (value 255 means fixed, 0 means all host bits)
! Wait — this is a clean /24, there IS no interesting octet
! The entire 4th octet is the host portion

! Example 2: 255.255.255.192
! Mask:   255  255  255  192
! Interesting octet = 4th (192 is not 0 or 255)

! Example 3: 255.255.240.0
! Mask:   255  255  240   0
! Interesting octet = 3rd (240 is not 0 or 255)
2

Calculate the magic number (block size)

The magic number is 256 minus the subnet mask value in the interesting octet. It tells you how big each subnet block is — the 'stride' between network addresses.

Magic number formula
! Magic number = 256 - (mask value in interesting octet)

! Example: mask = 255.255.255.192
! Interesting octet = 4th, value = 192
! Magic number = 256 - 192 = 64

! Example: mask = 255.255.255.224
! Interesting octet = 4th, value = 224
! Magic number = 256 - 224 = 32

! Example: mask = 255.255.240.0
! Interesting octet = 3rd, value = 240
! Magic number = 256 - 240 = 16

! The magic number tells you how many addresses are in each subnet block
3

Find the network address

The network address is the multiple of the magic number that is less than or equal to the IP's value in the interesting octet.

Finding network address
! Example: IP = 192.168.1.100, Mask = 255.255.255.192
! Magic number = 64

! Find multiples of 64: 0, 64, 128, 192, 256...
! IP in interesting octet (4th) = 100
! 100 is between 64 and 128
! Network address = the multiple BELOW 100 = 64

! So network address = 192.168.1.64

! Example: IP = 10.0.50.200, Mask = 255.255.240.0
! Magic number = 16, interesting octet = 3rd
! IP in 3rd octet = 50
! Multiples of 16: 0, 16, 32, 48, 64...
! 50 is between 48 and 64
! Network address = 10.0.48.0 (use 48 in 3rd octet, 0 in remaining octets)

The network address is always a multiple of the magic number in the interesting octet. All octets after the interesting octet become 0 in the network address.

4

Find the broadcast address

The broadcast address is the address just before the next network — or equivalently, network address + magic number - 1 in the interesting octet, with all remaining octets set to 255.

Finding broadcast address
! Example: IP = 192.168.1.100, Mask = 255.255.255.192
! Network address = 192.168.1.64
! Magic number = 64
! Next network = 192.168.1.(64 + 64) = 192.168.1.128
! Broadcast = one before next network = 192.168.1.127

! Example: IP = 10.0.50.200, Mask = 255.255.240.0
! Network address = 10.0.48.0
! Magic number = 16
! Next network = 10.0.(48+16).0 = 10.0.64.0
! Broadcast = 10.0.63.255 (all remaining octets = 255)
5

Find the host range and count

The first usable host is network + 1. The last usable host is broadcast - 1. Usable hosts = 2^(host bits) - 2.

Host range calculation
! Example: 192.168.1.64/26
! Network:    192.168.1.64
! Broadcast:  192.168.1.127
! First host: 192.168.1.65
! Last host:  192.168.1.126
! Usable hosts = 126 - 65 + 1 = 62
! OR: 2^(32-26) - 2 = 2^6 - 2 = 64 - 2 = 62

! Quick host count formula: magic_number - 2
! For /26: magic = 64, hosts = 64 - 2 = 62 ✓

The 'magic number - 2' shortcut for host count only works when the interesting octet is the last octet. For masks like 255.255.240.0, you need: 2^(32-prefix) - 2. For /20: 2^12 - 2 = 4094 hosts.

6

Work through a VLSM exam question

VLSM questions give you a base network and multiple subnets to allocate. Always sort by hosts needed (largest first) and work through each allocation in sequence.

VLSM worked example
! Question: Subnet 192.168.10.0/24 for:
! Dept A: 50 hosts
! Dept B: 25 hosts
! Dept C: 10 hosts

! Step 1: Find minimum prefix for each:
! 50 hosts → 2^6=64 - 2=62 ≥ 50 → /26 (magic=64)
! 25 hosts → 2^5=32 - 2=30 ≥ 25 → /27 (magic=32)
! 10 hosts → 2^4=16 - 2=14 ≥ 10 → /28 (magic=16)

! Step 2: Allocate largest first:
! Dept A: 192.168.10.0/26 (network .0, broadcast .63, hosts .1-.62)
! Dept B: 192.168.10.64/27 (network .64, broadcast .95, hosts .65-.94)
! Dept C: 192.168.10.96/28 (network .96, broadcast .111, hosts .97-.110)
! Remaining: 192.168.10.112 - 192.168.10.255 (unallocated)

Key tips

  • Memorise the 8 mask values and their magic numbers: 128→128, 192→64, 224→32, 240→16, 248→8, 252→4, 254→2, 255→1 (no host bits).

  • The magic number is always the block size — every network in that subnet scheme starts at a multiple of the magic number.

  • For VLSM problems: always sort requirements from largest to smallest BEFORE starting to allocate.

  • Host count shortcut: magic_number - 2 (only valid when the interesting octet is the final octet of the mask).

  • Practice until you can calculate a /27 or /26 subnet in under 30 seconds — speed matters when exam time pressure is high.

Frequently asked questions

What prefix is needed for 30 hosts?

A /27 — 2^5 = 32 addresses, minus 2 (network + broadcast) = 30 usable hosts. This is the exact match. For 31+ hosts, you need a /26 (62 usable hosts).

How many /28 subnets fit in a /24?

A /24 has 256 addresses. A /28 has 16 addresses (magic number = 16). 256 / 16 = 16 subnets. Each has 14 usable hosts.

What is the difference between FLSM and VLSM?

FLSM (Fixed Length Subnet Masking) divides a network into equal-sized subnets. VLSM allows subnets of different sizes. VLSM is more efficient because you can size each subnet to match the actual host requirement, rather than wasting addresses by making every subnet the same size.

Related glossary terms

Browse full glossary →

Practice with real exam questions

Apply what you just learned with exam-style practice questions.

Related guides