Sub topic 4
Variable-Length Subnet Masks
Prerequisites and purpose
This chapter assumes that you can convert between binary and decimal, read IPv4 prefix notation such as /24, and calculate usable hosts in a subnet. A subnet is a smaller logical network inside a larger IP network.
A variable-length subnet mask (VLSM) lets different subnets use different prefix lengths. This avoids wasting addresses when departments or links need different numbers of hosts. Fixed-length subnetting gives every subnet the same size, even when their requirements differ.
A worked VLSM design
Suppose 192.168.10.0/24 must support these networks:
| Network | Required hosts |
|---|---|
| Engineering | 100 |
| Administration | 50 |
| Laboratory | 20 |
| Point-to-point link | 2 |
For each requirement, choose the smallest subnet that provides enough usable addresses. A prefix with h host bits provides 2^h - 2 usable addresses. The subtraction removes the network and broadcast addresses.
Always allocate the largest requirement first. This reduces the chance that early allocations create unusable gaps.
- Engineering needs 100 hosts.
/25has 7 host bits and provides 126 usable addresses. - Administration needs 50 hosts.
/26has 6 host bits and provides 62 usable addresses. - Laboratory needs 20 hosts.
/27has 5 host bits and provides 30 usable addresses. - The point-to-point link needs 2 hosts.
/30has 2 host bits and provides 2 usable addresses.
The allocations can be placed consecutively:
| Network | Prefix | Address range | Usable hosts |
|---|---|---|---|
| Engineering | `192.168.10.0/25` | `.0`–`.127` | 126 |
| Administration | `192.168.10.128/26` | `.128`–`.191` | 62 |
| Laboratory | `192.168.10.192/27` | `.192`–`.223` | 30 |
| Point-to-point | `192.168.10.224/30` | `.224`–`.227` | 2 |
The unused range is 192.168.10.228–192.168.10.255. It contains a /30 at .228, a /29 at .232, and a /28 at .240, so it can support future subnets if aligned correctly.
Common errors
- Allocating small networks first can leave gaps too small for larger requirements.
- A subnet must start on a boundary determined by its block size. A
/26starts at multiples of 64 in the last octet. - The required host count excludes the network and broadcast addresses.
- A
/30is suitable for two IPv4 endpoints, but a/31may be used for point-to-point links under specific standards and device support.
Exercise
Divide 10.0.0.0/24 into subnets for 60, 25, and 10 usable hosts. What prefixes should you choose?
Show answer
Choose /26 for 60 hosts, /27 for 25 hosts, and /28 for 10 hosts. Allocate them from largest to smallest: 10.0.0.0/26, 10.0.0.64/27, and 10.0.0.96/28.