VLSM: Variable-Length Subnet Masking

Learning Objectives

Pre-Quiz: Why VLSM

Why does fixed-length subnetting waste so many addresses when a network mixes large LANs and tiny point-to-point links?

One uniform mask must be sized for the largest segment, so small segments receive oversized blocks.
Fixed-length subnetting reserves half of every block for broadcast traffic.
Each subnet must leave a gap of unused addresses between it and the next subnet.
Point-to-point links cannot use any subnet mask, so their addresses are unusable.

A 2-host WAN link is given a /28 block (14 usable). How many addresses are wasted, and what does that reveal?

2 wasted; the link is efficiently sized.
12 wasted; a mask sized for a LAN is far too generous for a 2-host link.
14 wasted; the whole block is unusable for a WAN link.
0 wasted; a /28 is the correct size for any point-to-point link.

What is the defining characteristic that distinguishes VLSM from fixed-length subnetting?

VLSM uses more than one subnet mask within a single parent block.
VLSM requires a different parent network for each subnet size.
VLSM only works with IPv6 address space.
VLSM eliminates the need for network and broadcast addresses.

"Right-sizing" a subnet means:

Choosing the mask whose usable-host count most closely fits the segment's actual device count.
Always choosing the largest possible mask so there is room to grow.
Making every subnet exactly the same size for consistency.
Rounding every host requirement down to the nearest power of two.

Beyond neatness, why does address conservation genuinely matter, even inside a private network?

Private networks are legally required to conserve addresses under RFC 1918.
Conserved space stays contiguous and available for growth, avoiding a painful readdressing later.
Wasted private addresses are billed monthly by the registrar.
Routers refuse to forward traffic for subnets larger than needed.

Why VLSM

Key Points

In traditional fixed-length subnetting, a single subnet mask is applied uniformly to every subnet you carve from a parent block. Every subnet therefore receives an identically sized block of addresses, regardless of how many hosts actually live on that segment. Real networks are lumpy: a large user LAN might need 60 addresses while a router-to-router link needs only 2. With one mask, you must satisfy your largest segment and apply that generous mask everywhere.

Consider a /28 mask (255.255.255.240), which yields 14 usable hosts. Apply that same /28 to a WAN link that needs only 2 usable addresses and you have wasted 12 addresses on a single link. Multiply that across dozens of point-to-point links and you have thrown away thousands of addresses for no reason.

Figure 8.1: Fixed /28 waste vs. right-sized /30 on a 2-host WAN link

graph TD N["WAN link needs 2 usable hosts"] N --> F["Fixed-length /28 block
16 addresses, 14 usable"] N --> V["Right-sized /30 block
4 addresses, 2 usable"] F --> FU["2 addresses used"] F --> FW["12 addresses WASTED"] V --> VU["2 addresses used"] V --> VW["0 addresses wasted"] style FW fill:#f8d7da,stroke:#c00 style VW fill:#d4edda,stroke:#0a0

VLSM is the technique of dividing a single IP network into subnets of different sizes by using more than one subnet mask within the same parent block. Rather than giving the 2-host WAN link a wasteful /28, VLSM lets you assign it a /30 (255.255.255.252), which provides exactly 2 usable addresses — precisely what a point-to-point link requires. Matching subnet size to the real requirement is called right-sizing, the heart of good address design.

Visual animation — coming soon

The payoff from right-sizing is address conservation: because each subnet closely fits the devices it serves, few or no addresses go unused. Conservation was a founding motivation for VLSM and CIDR — slowing IPv4 exhaustion — but it matters inside private networks too: a well-conserved plan leaves clean, contiguous free space to grow into rather than a patchwork of exhausted blocks that forces a painful readdressing project later.

SegmentHosts neededFixed /28 block (14 usable)Wasted with /28Right-sized VLSM maskWasted with VLSM
User LAN14/280/28 (14 usable)0
WAN link A2/2812/30 (2 usable)0
WAN link B2/2812/30 (2 usable)0
WAN link C2/2812/30 (2 usable)0
Post-Quiz: Why VLSM

Why does fixed-length subnetting waste so many addresses when a network mixes large LANs and tiny point-to-point links?

One uniform mask must be sized for the largest segment, so small segments receive oversized blocks.
Fixed-length subnetting reserves half of every block for broadcast traffic.
Each subnet must leave a gap of unused addresses between it and the next subnet.
Point-to-point links cannot use any subnet mask, so their addresses are unusable.

A 2-host WAN link is given a /28 block (14 usable). How many addresses are wasted, and what does that reveal?

2 wasted; the link is efficiently sized.
12 wasted; a mask sized for a LAN is far too generous for a 2-host link.
14 wasted; the whole block is unusable for a WAN link.
0 wasted; a /28 is the correct size for any point-to-point link.

What is the defining characteristic that distinguishes VLSM from fixed-length subnetting?

VLSM uses more than one subnet mask within a single parent block.
VLSM requires a different parent network for each subnet size.
VLSM only works with IPv6 address space.
VLSM eliminates the need for network and broadcast addresses.

"Right-sizing" a subnet means:

Choosing the mask whose usable-host count most closely fits the segment's actual device count.
Always choosing the largest possible mask so there is room to grow.
Making every subnet exactly the same size for consistency.
Rounding every host requirement down to the nearest power of two.

Beyond neatness, why does address conservation genuinely matter, even inside a private network?

Private networks are legally required to conserve addresses under RFC 1918.
Conserved space stays contiguous and available for growth, avoiding a painful readdressing later.
Wasted private addresses are billed monthly by the registrar.
Routers refuse to forward traffic for subnets larger than needed.
Pre-Quiz: The VLSM Procedure

Why must you allocate the largest subnet first and the smallest links last?

Large blocks need a big, aligned, contiguous space; placing them first leaves one clean free block instead of scattered gaps.
Small subnets take longer to compute, so doing them last saves time.
Routers process large subnets faster when they appear first in the table.
The smallest link must always receive the lowest network address.

A segment needs 60 usable hosts. How do you size it, and what prefix results?

60 + 2 = 62, round up to 64, block size 64 → /26.
60 hosts fit exactly in 60 addresses → /26.
60 + 2 = 62, round down to 32 → /27.
60 × 2 = 120, round up to 128 → /25.

Why do you add 2 to the host count before rounding up to a power of two?

To reserve one address for the network/subnet ID and one for the broadcast address.
To leave two spare addresses for future hosts on every subnet.
To account for the default gateway and the DNS server.
Because every subnet mask reserves exactly 2 bits for VLSM.

In Step 4, what does it mean for a subnet to be "aligned to its own block size"?

Its network address is an exact multiple of its block size.
Its first host address equals the parent network address.
Its broadcast address equals the parent broadcast address.
Its mask is identical to every other subnet's mask.

Which pair of checks in Step 5 proves a VLSM plan is sound before deployment?

Each broadcast < next network address (no overlap), and each network address divisible by its block size (alignment).
Each subnet has the same number of usable hosts, and all masks are equal.
Each subnet uses a /30, and the total address count equals 256.
Each network address is odd, and each broadcast address is even.

The VLSM Procedure

Key Points

VLSM gives you freedom, and freedom demands discipline. Carve blocks carelessly and you get overlapping subnets or wasteful gaps. The single rule that prevents most mistakes: allocate the subnet with the most hosts first, then the next largest, and work down to the smallest links last. A large subnet needs a big, contiguous block aligned to its own boundary. Placing the big blocks first leaves a single, clean, contiguous free block at the end; allocating small subnets first can leave a later large subnet with no properly aligned space, fragmenting the parent into scattered, unusable gaps.

The full procedure:

Figure 8.2: The five-step VLSM allocation procedure

flowchart TD S1["Step 1: List every segment
with its usable host count"] S2["Step 2: Size each segment
hosts + 2, round up to power of two
read off the prefix"] S3["Step 3: Sort segments
largest block to smallest"] S4["Step 4: Allocate sequentially
each block starts where the last ended,
aligned to its own block size"] S5{"Step 5: Verify"} OK["No overlap: each broadcast < next network address"] AL["Alignment: each network address
divisible by its block size"] DONE["Plan is sound - deploy"] S1 --> S2 --> S3 --> S4 --> S5 S5 --> OK S5 --> AL OK --> DONE AL --> DONE

Keep this prefix reference table close while you work:

PrefixSubnet maskBlock sizeUsable hosts
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242

Overlap — two subnets whose ranges intersect — is the cardinal sin of subnet design; an address could belong to two segments at once and routing breaks. The largest-first, sequential-allocation approach makes overlap impossible: each block begins where the last ended and is aligned to its own size, so no two ranges can collide. Step 5 is your mathematical safety net.

Figure 8.4: The Step 5 verification checks per subnet

flowchart TD START["For each subnet:
compute network ID and
broadcast = network ID + block size - 1"] START --> Q1{"Is broadcast address <
next subnet's network ID?"} Q1 -->|No| FAIL["OVERLAP - subnets collide
fix allocation"] Q1 -->|Yes| Q2{"Is network address
divisible by its block size?"} Q2 -->|No| FAIL2["MISALIGNED - block off boundary
fix allocation"] Q2 -->|Yes| PASS["Subnet verified"] style FAIL fill:#f8d7da,stroke:#c00 style FAIL2 fill:#f8d7da,stroke:#c00 style PASS fill:#d4edda,stroke:#0a0
Post-Quiz: The VLSM Procedure

Why must you allocate the largest subnet first and the smallest links last?

Large blocks need a big, aligned, contiguous space; placing them first leaves one clean free block instead of scattered gaps.
Small subnets take longer to compute, so doing them last saves time.
Routers process large subnets faster when they appear first in the table.
The smallest link must always receive the lowest network address.

A segment needs 60 usable hosts. How do you size it, and what prefix results?

60 + 2 = 62, round up to 64, block size 64 → /26.
60 hosts fit exactly in 60 addresses → /26.
60 + 2 = 62, round down to 32 → /27.
60 × 2 = 120, round up to 128 → /25.

Why do you add 2 to the host count before rounding up to a power of two?

To reserve one address for the network/subnet ID and one for the broadcast address.
To leave two spare addresses for future hosts on every subnet.
To account for the default gateway and the DNS server.
Because every subnet mask reserves exactly 2 bits for VLSM.

In Step 4, what does it mean for a subnet to be "aligned to its own block size"?

Its network address is an exact multiple of its block size.
Its first host address equals the parent network address.
Its broadcast address equals the parent broadcast address.
Its mask is identical to every other subnet's mask.

Which pair of checks in Step 5 proves a VLSM plan is sound before deployment?

Each broadcast < next network address (no overlap), and each network address divisible by its block size (alignment).
Each subnet has the same number of usable hosts, and all masks are equal.
Each subnet uses a /30, and the total address count equals 256.
Each network address is odd, and each broadcast address is even.
Pre-Quiz: Worked VLSM Example

A 74-host Development LAN is being sized from 192.168.1.0/24. Which prefix does it receive and why?

/25 — 74 + 2 = 76 rounds up to 128, so it needs a 128-address block.
/26 — 74 hosts fit within 62 usable addresses.
/24 — any LAN over 50 hosts requires the full block.
/27 — 74 rounds down to 32 for efficiency.

After Development takes 192.168.1.0/25 (through .127), where does the Production /26 begin, and why there?

At 192.168.1.128 — the next address after Development's block, and 128 is divisible by 64.
At 192.168.1.126 — reusing Development's last host address.
At 192.168.1.192 — Production must skip a /27 for alignment.
At 192.168.1.64 — /26 blocks always start at .64.

In the worked plan, the overlap check confirms soundness because each subnet's broadcast:

Lands exactly one address below the next subnet's network ID.
Equals the next subnet's network ID.
Is two or more addresses below the next network ID, leaving a gap.
Is higher than the next subnet's first host address.

After allocating a /25, /26, /27, and three /30 links in 192.168.1.0/24, what remains, and why is that shape valuable?

A single contiguous block, 192.168.1.236–.255 (20 addresses), which is easy to reuse later.
Twenty scattered addresses spread between the subnets.
Nothing — the /24 is fully consumed.
A /28 block in the middle of the plan that cannot be used.

For a 2-endpoint point-to-point link, how does an RFC 3021 /31 compare to a /30?

A /31 gives 2 usable addresses with zero waste; a /30 gives 2 usable but reserves 2 more for network/broadcast.
A /31 gives 4 usable addresses, twice as many as a /30.
A /31 and /30 are identical in address usage.
A /31 wastes more addresses than a /30 on a two-node link.

Worked VLSM Example

Key Points

You are given 192.168.1.0/24 (256 addresses) and asked to accommodate: a Development LAN (74 hosts), Production LAN (52), Administration LAN (28), and three point-to-point WAN links (2 hosts each). No single uniform mask can serve all six sensibly — VLSM is the only answer.

Steps 1–2: Size each segment (add 2, round up to the next power of two):

SegmentHosts neededActual (+2)Block sizePrefix
Development7476128/25
Production525464/26
Administration283032/27
WAN Link 1244/30
WAN Link 2244/30
WAN Link 3244/30

Steps 3–4: Sort and allocate sequentially. The list is already largest-first. Development takes the first 128 addresses, Production the next 64, Administration the next 32, and the three WAN links 4 each:

SegmentCIDRNetwork IDFirst hostLast hostBroadcast
Development/25192.168.1.0192.168.1.1192.168.1.126192.168.1.127
Production/26192.168.1.128192.168.1.129192.168.1.190192.168.1.191
Administration/27192.168.1.192192.168.1.193192.168.1.222192.168.1.223
WAN Link 1/30192.168.1.224192.168.1.225192.168.1.226192.168.1.227
WAN Link 2/30192.168.1.228192.168.1.229192.168.1.230192.168.1.231
WAN Link 3/30192.168.1.232192.168.1.233192.168.1.234192.168.1.235

Figure 8.3: Carving 192.168.1.0/24 into different-sized subnets, largest first

graph TD P["Parent block: 192.168.1.0/24
256 addresses"] P --> A["Development /25
192.168.1.0 - .127
128 addresses"] P --> B["Production /26
192.168.1.128 - .191
64 addresses"] P --> C["Administration /27
192.168.1.192 - .223
32 addresses"] P --> D["WAN Link 1 /30
192.168.1.224 - .227"] P --> E["WAN Link 2 /30
192.168.1.228 - .231"] P --> F["WAN Link 3 /30
192.168.1.232 - .235"] P --> G["Free space
192.168.1.236 - .255
20 addresses"] style G fill:#d4edda,stroke:#0a0

Visual animation — coming soon

Step 5: Verify no overlap. Each broadcast lands exactly one below the next network ID — 127→128, 191→192, 223→224, 227→228, 231→232 — confirming no overlap and no wasted gap. Alignment passes too: 0, 128, 192, 224, 228, 232 are each divisible by their block sizes (128, 64, 32, 4, 4, 4). The last link ends at .235, leaving 192.168.1.236–.255 — a clean, contiguous block of 20 addresses — free for future growth precisely because we allocated largest-first.

/30 vs. /31 for point-to-point links. The traditional /30 gives 4 total addresses, 2 usable, reserving 2 for network and broadcast — addresses that do nothing on a two-endpoint link. RFC 3021 permits a /31, which gives 2 usable addresses with zero waste (no reserved network or broadcast). Many designs still standardize on /30 for compatibility and troubleshooting familiarity, but the /31 is the maximally conservative option.

Post-Quiz: Worked VLSM Example

A 74-host Development LAN is being sized from 192.168.1.0/24. Which prefix does it receive and why?

/25 — 74 + 2 = 76 rounds up to 128, so it needs a 128-address block.
/26 — 74 hosts fit within 62 usable addresses.
/24 — any LAN over 50 hosts requires the full block.
/27 — 74 rounds down to 32 for efficiency.

After Development takes 192.168.1.0/25 (through .127), where does the Production /26 begin, and why there?

At 192.168.1.128 — the next address after Development's block, and 128 is divisible by 64.
At 192.168.1.126 — reusing Development's last host address.
At 192.168.1.192 — Production must skip a /27 for alignment.
At 192.168.1.64 — /26 blocks always start at .64.

In the worked plan, the overlap check confirms soundness because each subnet's broadcast:

Lands exactly one address below the next subnet's network ID.
Equals the next subnet's network ID.
Is two or more addresses below the next network ID, leaving a gap.
Is higher than the next subnet's first host address.

After allocating a /25, /26, /27, and three /30 links in 192.168.1.0/24, what remains, and why is that shape valuable?

A single contiguous block, 192.168.1.236–.255 (20 addresses), which is easy to reuse later.
Twenty scattered addresses spread between the subnets.
Nothing — the /24 is fully consumed.
A /28 block in the middle of the plan that cannot be used.

For a 2-endpoint point-to-point link, how does an RFC 3021 /31 compare to a /30?

A /31 gives 2 usable addresses with zero waste; a /30 gives 2 usable but reserves 2 more for network/broadcast.
A /31 gives 4 usable addresses, twice as many as a /30.
A /31 and /30 are identical in address usage.
A /31 wastes more addresses than a /30 on a two-node link.

Your Progress

Answer Explanations