CIDR, VLSM, and Subnet Math
Key Takeaways
- CIDR slash notation counts network bits; host bits determine subnet size.
- Usable IPv4 hosts are usually 2 to the host-bits power minus 2, because network and broadcast addresses are reserved.
- VLSM assigns different subnet sizes based on need, conserving address space.
- Block size in the interesting octet helps find network IDs, broadcast addresses, and valid host ranges.
- Subnetting PBQs reward a repeatable method more than memorizing isolated answers.
CIDR replaces classful assumptions with explicit prefix lengths. A /24 means 24 network bits and 8 host bits. A /26 means 26 network bits and 6 host bits.
| Prefix | Mask | Addresses per subnet | Usable hosts | Block size |
|---|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 | 1 in third octet, 256 in fourth |
| /25 | 255.255.255.128 | 128 | 126 | 128 |
| /26 | 255.255.255.192 | 64 | 62 | 64 |
| /27 | 255.255.255.224 | 32 | 30 | 32 |
| /28 | 255.255.255.240 | 16 | 14 | 16 |
| /29 | 255.255.255.248 | 8 | 6 | 8 |
| /30 | 255.255.255.252 | 4 | 2 | 4 |
Fast Method
- Convert the prefix to a mask.
- Find the interesting octet, the octet where the mask is not 255 or 0.
- Calculate block size as 256 minus the mask value in that octet.
- Count network IDs by that block size.
- The broadcast address is one less than the next network ID.
- Usable hosts are between network ID and broadcast address.
Example: 192.168.10.77/26.
| Step | Result |
|---|---|
| /26 mask | 255.255.255.192 |
| Interesting octet | Fourth octet |
| Block size | 256 - 192 = 64 |
| Network IDs | .0, .64, .128, .192 |
| 77 falls in | .64 subnet |
| Network ID | 192.168.10.64 |
| Broadcast | 192.168.10.127 |
| Usable range | 192.168.10.65-192.168.10.126 |
VLSM Allocation
Variable length subnet masking uses different subnet sizes in the same address plan. Allocate largest requirements first so smaller subnets can fit into the remaining space.
| Need | Smallest common prefix | Usable hosts |
|---|---|---|
| 100 hosts | /25 | 126 |
| 50 hosts | /26 | 62 |
| 25 hosts | /27 | 30 |
| 12 hosts | /28 | 14 |
| 5 hosts | /29 | 6 |
| 2 hosts | /30 | 2 |
Given 192.168.50.0/24 and requirements for 100, 50, 25, and 12 hosts, a clean allocation could be:
| Requirement | Subnet | Usable range |
|---|---|---|
| 100 hosts | 192.168.50.0/25 | .1-.126 |
| 50 hosts | 192.168.50.128/26 | .129-.190 |
| 25 hosts | 192.168.50.192/27 | .193-.222 |
| 12 hosts | 192.168.50.224/28 | .225-.238 |
PBQ-Style Thinking
Scenario: You must assign subnets to departments with 55, 27, 12, and 2 hosts from one /24. Sort largest to smallest. Choose /26 for 55, /27 for 27, /28 for 12, and /30 for 2. Then place each subnet on valid boundaries without overlap.
Scenario: A host 10.1.5.130/25 cannot reach 10.1.5.20/25 directly. Calculate the subnets: /25 has block size 128, so 10.1.5.130 is in 10.1.5.128/25 and 10.1.5.20 is in 10.1.5.0/25. They are in different subnets and need a router or corrected addressing.
Subnet Trap Table
| Trap | Correction |
|---|---|
| Using classful mask automatically | Use the provided CIDR prefix |
| Assigning the network ID to a host | First address is reserved for subnet ID |
| Assigning the broadcast address to a host | Last address is reserved for broadcast |
| Forgetting to sort VLSM by size | Allocate largest subnet first |
| Overlapping VLSM ranges | Use valid block boundaries |
| Confusing addresses with usable hosts | Usable is usually total minus 2 |
What is the network ID for host 192.168.10.77/26?
Which prefix is the smallest common choice that supports 50 usable IPv4 hosts?
Which steps are part of reliable VLSM planning? Choose two.
Select all that apply