Convert fluently between CIDR prefixes and dotted-decimal masks, and compute the network, broadcast, and usable host range for any address using the block-size method.
Week 2 · Lesson 2 · Active ~21 min · No required video · Domain: Network Fundamentals
You already know masks split network from host bits and that block size = 256 - the interesting mask octet. This lesson makes that a fast, repeatable procedure.
Prerequisites: subnetting-mental-model
Two notations, one boundary. /n and a dotted-decimal mask describe the same thing: how many leading bits are network. Converting is just placing n ones from the left and reading each octet:
- A full octet of 1s = 255. So
/8= 255.0.0.0,/16= 255.255.0.0,/24= 255.255.255.0. - A partial octet holds the leftover bits. The eight possible partial values are the running sums of 128, 64, 32, 16, 8, 4, 2, 1:
| Bits in the octet | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Octet value | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
Example: /26 = 24 bits (255.255.255) + 2 more bits in the fourth octet. Two bits = 192, so the mask is 255.255.255.192. Going backward, a mask of 255.255.255.224 has 3 partial bits (224 is three bits), so it is 24 + 3 = /27.
Four answers, one method. Every subnet question wants the network, the broadcast, the host range, and the mask. The block-size method finds them without long binary:
- Find the interesting octet — the octet where the mask is a partial value (not 255, not 0).
- Block size = 256 - that mask octet.
- Network address = round the address down to the nearest multiple of the block size in that octet (host bits become 0).
- Broadcast = network + block size - 1 in the interesting octet (host bits become 1).
- Usable hosts = network + 1 through broadcast - 1.
Worked example: 172.16.20.50 /28.
- Mask = 255.255.255.240; interesting octet is the fourth (240). Block size = 256 - 240 = 16.
- Multiples of 16: 0, 16, 32, 48, 64… 50 rounds down to 48. Network =
172.16.20.48. - Broadcast = 48 + 16 - 1 = 63 →
172.16.20.63. - Usable hosts =
172.16.20.49through172.16.20.62(14 hosts = 2^4 - 2).
Notice the first host is .49, not .1, and the broadcast is .63, not .255 — those defaults only hold for a /24.
Pause and predict
Solve 10.4.9.130 /26 completely: mask, block size, network, broadcast, and usable host range.
Reveal answer
Mask = 255.255.255.192; block size = 256 - 192 = 64. Multiples of 64: 0, 64, 128, 192 — 130 rounds down to 128. Network = 10.4.9.128, broadcast = 128 + 64 - 1 = 10.4.9.191, usable hosts = 10.4.9.129 through 10.4.9.190 (62 hosts).
Pause and predict
Are 192.168.5.60 and 192.168.5.70 in the same /27 subnet? Show why.
Reveal answer
/27 block size = 256 - 224 = 32, so subnets start at .0, .32, .64, .96. 60 rounds down to 32 (subnet 192.168.5.32, broadcast .63); 70 rounds down to 64 (subnet 192.168.5.64). Different subnets — they need a router to communicate, even though the first three octets match.
Run network/broadcast/host-range drills until you can solve any /24-/30 in under a minute.
Open subnettingQuick check (3 items) · retrieve
Answer from memory:
- What is the dotted-decimal mask for /29, and how many usable hosts does it give?
- For an address in a /28, how do you find the network address from any host in it?
- Where do the first and last usable hosts sit relative to the network and broadcast?
Review sheet
- /n ↔ mask: full octets are 255; the partial octet is one of 128/192/224/240/248/252/254.
- Block size = 256 - interesting mask octet.
- Network = round the address down to a multiple of the block size; broadcast = network + block size - 1.
- Usable hosts = network + 1 to broadcast - 1.
- The
.1/.255defaults are true only for /24 — always compute the actual block.
.60 and .70 can land in different /27s.You can read a subnet mask; next you flip it into the wildcard form that ACLs and OSPF use to match address ranges.
Next: Wildcard Masks