Lesson 2 — CIDR, Subnet Masks & Host Ranges
CIDR, Subnet Masks & Host Ranges
Convert fluently between prefix lengths and dotted-decimal masks, then compute the network address, broadcast address, and usable host range for any address using the block-size method.
Lesson orientation
What you'll learn (4 objectives)~21 min: video → lesson → check → apply → lab prep
Learning objectives
- Convert between a /n prefix and its dotted-decimal subnet mask in both directions
- Find the block size from the interesting mask octet and locate the subnet an address belongs to
- Compute the network address, broadcast address, and first and last usable host for a given address and mask
- Apply the same method when the interesting octet is not the last one
Terms you will see
Time breakdown
- Read the notes10 min
- Subnetting Trainer drills8 min
- Worked examples and predictions3 min
Two notations, one boundary
A prefix like /26 and a mask like 255.255.255.192 say exactly the same thing: how many leading bits are network. Converting between them is just placing n one-bits from the left and reading off each octet. A full octet of ones is 255, so /8 is 255.0.0.0, /16 is 255.255.0.0, and /24 is 255.255.255.0. Any bits left over land in the next octet as a partial value.
| Bits in the octet | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Octet value | 128 | 192 | 224 | 240 | 248 | 252 | 254 | 255 |
Forward: /26 is 24 bits (255.255.255) plus 2 more, and two bits is 192, so the mask is 255.255.255.192. Backward: a mask of 255.255.255.224 has 224 in the last octet, which is three bits, so the prefix is 24 + 3 = /27. That is the whole conversion, in both directions, with no binary written down.
Four answers, one method
Almost every subnetting question wants the same four things: the network address, the broadcast address, the usable host range, and the mask. The block-size method produces all four without long-hand binary.
- Find the interesting octet — the one where the mask is a partial value, neither 255 nor 0.
- Block size = 256 − that mask octet.
- Network address: round the address down to the nearest multiple of the block size in that octet. Every octet to the right becomes 0.
- Broadcast address: network + block size − 1 in the interesting octet. Every octet to the right becomes 255.
- Usable hosts: everything strictly between the network and broadcast addresses.
Notice what that example is not. The first host is .49, not .1. The broadcast is .63, not .255. Those familiar values are properties of a /24 specifically, and carrying them into any other prefix is the single most common source of wrong answers on this topic.
When the split is not in the last octet
The method does not change when the boundary falls further left — only the octet you apply it to changes. Practising exclusively on the fourth octet builds a habit that breaks the first time an exam hands you a /20.
Check that against the host-bit count as a habit. A /20 leaves 32 − 20 = 12 host bits, so the subnet holds 2^12 = 4096 addresses and 4094 usable ones. Counting the range directly: the third octet spans 16 through 31, which is 16 values, each carrying 256 addresses, giving 16 × 256 = 4096. The two methods agree, and when they disagree you have made an arithmetic slip rather than discovered an exception.
Reading a bad address assignment
The same arithmetic tells you when a configured address is invalid. Three failures account for most of what you will see.
| Symptom | What went wrong | How the maths shows it |
|---|---|---|
| Host cannot communicate at all; address ends in the block boundary | The address is the subnet's network address | Round the address down to a multiple of the block size — if it lands on itself, it is the network address, not a host |
| Host cannot communicate; address is one below the next boundary | The address is the subnet's broadcast address | Compute network + block size − 1; if the address equals it, it is the broadcast |
| Two hosts on the same wire cannot reach each other, and the first three octets match | They are in different subnets | Round each address down to its own block boundary — if the results differ, they need a router |
What you should retain
- Prefix to mask: full octets are 255, and the partial octet is one of 128, 192, 224, 240, 248, 252, 254.
- Block size = 256 − the interesting mask octet.
- Network = round the address down to a multiple of the block size; octets to the right go to 0.
- Broadcast = network + block size − 1; octets to the right go to 255.
- Usable hosts = everything strictly between network and broadcast.
- The .1 and .255 defaults hold only for a /24 — always compute the real block.
- Cross-check the range against 2^h − 2. Disagreement means a slip, not an exception.
Before you read on
Solve 10.4.9.130 /26 completely: mask, block size, network address, broadcast address, and the usable host range. Then say how many usable hosts that is.
See it happen
Subnetting Trainer
Drill network, broadcast, and host-range questions until any prefix from /24 to /30 takes you under a minute. This is the practice engine for the rest of the week — the method above only becomes useful once it is fast.
Check this section before moving on
Subnetting Foundations
The quiz opens on its own page so you can focus on it. It is a Week 1 milestone, tracked separately from this lesson's own completion.
Topics covered
- • Network bits versus host bits, and the 2^h − 2 host count
- • Binary and hexadecimal conversion of a single octet
- • Prefix to mask and mask to prefix in both directions
- • Block size, network, broadcast, and usable host range
Study deeper
Topic guides extend this lesson — they do not replace the first-party walkthrough above.
IP Addressing & Subnetting
For the full CIDR reference and additional worked ranges beyond the examples above
