Subnetting with block size instead of binary
A host cannot reach its gateway. The ticket says the cable is fine and the link light is on. Two addresses, two masks, and a question: are they in the same subnet? You can answer that without writing out 32 bits.
A host cannot reach its gateway. The ticket says the cable is fine and the link light is on. Two addresses, two masks, and a question: are they in the same subnet?
You can answer that without writing out 32 bits.
Block size
Look at the mask and find the octet where it is neither 255 nor 0. Subtract that value from 256. The result is the block size, and subnets start at multiples of it.
A /26 is 255.255.255.192. The interesting octet is the last one, 192. 256 minus 192 is 64. Subnets therefore start at .0, .64, .128 and .192.
Place an address
Take 10.0.5.130/26. The last octet, 130, sits between 128 and 192, so the host is in the 10.0.5.128 subnet. From there:
- Network address: 10.0.5.128
- First usable host: 10.0.5.129
- Last usable host: 10.0.5.190
- Broadcast: 10.0.5.191
That is 62 usable addresses, the 64 in the block minus the network and broadcast addresses.
Check the gateway
Say the gateway is configured as 10.0.5.65 with the same /26 mask. It belongs to the .64 block, which runs from .64 to .127. The host at .130 is in the next block over. They are not on the same subnet, so the host will not ARP for the gateway, and the "cable is fine" ticket turns out to be a wrong address or mask. This is a made-up example, but the pattern is a common one.
Other masks
The method holds for any mask. A /27 is 255.255.255.224, so blocks of 32. A /28 is 240, so blocks of 16. When the interesting octet is not the last one, the block size applies to that octet and the octets after it run the full range.
A second example
Try 172.16.40.77/28. A /28 is 255.255.255.240, so the block size is 256 minus 240, which is 16. Blocks in the last octet start at 0, 16, 32, 48, 64, 80. The value 77 falls between 64 and 80, so the host is in 172.16.40.64/28. Usable hosts run from .65 to .78 and the broadcast address is .79. That is 14 usable addresses.
When the mask crosses an octet
A /20 is 255.255.240.0. The interesting octet is the third one, so the block size is 256 minus 240, or 16, counted in the third octet. Subnets start at 10.1.0.0, 10.1.16.0, 10.1.32.0 and so on, and each one spans the full .0 to .255 range in the last octet. A host at 10.1.37.9 is therefore in 10.1.32.0/20.
Practise
The networking fundamentals learning path on Codelivly is free and has five rooms on addressing, protocols and how traffic moves. If you want a book to keep next to you while studying for Network+ or CCNA, the Computer Networking book covers the OSI model, TCP/IP, subnetting, DNS, DHCP, HTTP/3 and hardware. The product page lists it at $9.99.
Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.