PracticeLabs
Week 2Lesson 2Required21 min estimated0% progress

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

CIDRPrefix lengthDotted-decimal maskInteresting octetBlock sizeNetwork addressBroadcast addressFirst usable hostLast usable host

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.

The only eight values a partial mask octet can take
Bits in the octet12345678
Octet value128192224240248252254255

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.

  1. Find the interesting octet — the one where the mask is a partial value, neither 255 nor 0.
  2. Block size = 256 − that mask octet.
  3. Network address: round the address down to the nearest multiple of the block size in that octet. Every octet to the right becomes 0.
  4. Broadcast address: network + block size − 1 in the interesting octet. Every octet to the right becomes 255.
  5. Usable hosts: everything strictly between the network and broadcast addresses.
Worked example — 172.16.20.50 /28
A /28 is 24 + 4 bits, and four bits is 240, so the mask is 255.255.255.240 and the fourth octet is interesting. Block size is 256 − 240 = 16. The multiples of 16 are 0, 16, 32, 48, 64 — and 50 rounds down to 48, so the network is 172.16.20.48. The broadcast is 48 + 16 − 1 = 63, giving 172.16.20.63. The usable hosts run from 172.16.20.49 to 172.16.20.62, which is 14 addresses — exactly the 2^4 − 2 the host bits predict.

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.

Worked example — 10.55.20.100 /20
A /20 is 16 bits (255.255) plus 4 more, and four bits is 240, so the mask is 255.255.240.0 and the third octet is the interesting one. Block size is 256 − 240 = 16, so subnets step through the third octet as 0, 16, 32, 48. The third octet here is 20, which rounds down to 16, so the network address is 10.55.16.0 — note the fourth octet becomes 0. The broadcast has third octet 16 + 16 − 1 = 31 and the fourth octet filled to 255, giving 10.55.31.255. Usable hosts run from 10.55.16.1 to 10.55.31.254.

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.

Common invalid assignments and how to spot them
SymptomWhat went wrongHow the maths shows it
Host cannot communicate at all; address ends in the block boundaryThe address is the subnet's network addressRound 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 boundaryThe address is the subnet's broadcast addressCompute 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 matchThey are in different subnetsRound each address down to its own block boundary — if the results differ, they need a router
Matching octets prove nothing
192.168.5.60 and 192.168.5.70 share their first three octets, but in a /27 the block size is 32, so 60 rounds down to 32 and 70 rounds down to 64. They sit in different subnets — 192.168.5.32 and 192.168.5.64 — and cannot talk without a router. Whenever the boundary is inside the last octet, visual similarity is worthless. Compute it.

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.
Pause and predictNot scored — nothing is recorded

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.

Interactive tool
Required~8 min

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.

Section quiz

Check this section before moving on

Required8 questions~10 min

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
Start the quiz

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