Skip to content

Linux Foundations / Follow traffic and find the fault ยท Step 13 of 46

Lesson: Subnetting CheatsSwitch
โ† Linux Foundations

Network operations

Subnetting Cheats

Use a few memorised patterns to solve common subnet questions quickly.

You can work out any subnet from bits, but a few patterns make it much faster. Learn why they work, then use them.

The table

For prefixes inside the last octet:

| Prefix | Mask ends in | Block size | Usable hosts | |--------|--------------|------------|--------------| | /24 | 0 | 256 | 254 | | /25 | 128 | 128 | 126 | | /26 | 192 | 64 | 62 | | /27 | 224 | 32 | 30 | | /28 | 240 | 16 | 14 | | /29 | 248 | 8 | 6 | | /30 | 252 | 4 | 2 |

Each step down the table halves the block size.

The magic number

Subtract the interesting mask octet from 256. That gives the block size. Networks start at multiples of it.

Example: 10.0.0.100/28. The mask ends in 240, and 256 - 240 = 16. Multiples of 16 are 0, 16, 32, 48, 64, 80, 96, 112. So 100 belongs to the network 10.0.0.96. The broadcast is one below the next network: 10.0.0.111.

Same pattern in other octets

Prefixes eight bits apart behave alike. /18, /26 and /10 all have a block size of 64, in the third, fourth and second octet respectively.

For 172.16.100.5/18, the third octet steps by 64: 0, 64, 128, 192. The network is 172.16.64.0 and the broadcast is 172.16.127.255. Octets after the interesting one are all 0 in the network address and all 255 in the broadcast.

Powers of two

Memorise 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024. A /22 has 10 host bits, so 1024 addresses, which is four /24 networks side by side.

A quick check

$ python3 -c 'import ipaddress; print(ipaddress.ip_interface("10.0.0.100/28").network)'
10.0.0.96/28

Use it to mark your own practice, not to replace it. For a longer explanation, read the IPv4 subnetting guide.

Try it

Write the table from memory: prefix, mask value, block size, usable hosts. Then time yourself finding the network and broadcast for 192.168.5.201/27, 10.1.1.14/29 and 172.20.200.1/19. Check each with the Python command above, changing the address.

Check your understanding

Subnetting Cheats

All 4 sections ยท no timer

Unlimited retries

Questions from every section are combined into one assessment. Answer them all correctly to complete the article.

Your completion saves in this browser. Sign in to sync it to your account.