The block-size method
You don't need to convert whole addresses to binary. For a prefix that doesn't end on an octet boundary, only one octet is "interesting": the one where the mask isn't 255 or 0.
- Find the interesting octet and its mask value. For /26 that is the 4th octet, mask 192.
- Block size = 256 − mask value. 256 − 192 = 64.
- Subnets start at multiples of the block size: 0, 64, 128, 192.
- The address's subnet is the multiple just at or below it. The broadcast is one less than the next multiple.
- First host = network + 1. Last host = broadcast − 1.
Example 1: 192.168.1.77/26
Block size 64 → subnets .0, .64, .128, .192. 77 falls in the .64 block.
| Network | First host | Last host | Broadcast | Hosts |
|---|---|---|---|---|
| 192.168.1.64 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 | 62 |
Example 2: 10.20.130.5/20
/20 = 255.255.240.0, so the interesting octet is the 3rd, mask 240, block size 16: 0, 16, 32 ... 128, 144. 130 falls in the 128 block. The 4th octet goes from 0 to 255 inside it.
| Network | First host | Last host | Broadcast |
|---|---|---|---|
| 10.20.128.0 | 10.20.128.1 | 10.20.143.254 | 10.20.143.255 |
Example 3: 172.16.5.201/30
/30 = mask 252, block size 4: ... 196, 200, 204. 201 is in the 200 block: network .200, hosts .201 and .202, broadcast .203. Two usable hosts: perfect for a link between two routers.
Your turn
These questions are generated at random, as many as you like. Aim for each one in under 30 seconds.
Tip: Check your answers with the router:
show ip routeshows the network address of every interface's subnet, and an invalid address (a network or broadcast address) is refused with% Bad mask.