The Waste That VLSM Solves
When you subnet a network with a single fixed mask, every resulting subnet is the same size. That size has to be large enough for your biggest subnet — so all the small ones are forced to be just as big, squandering addresses. The classic offender is a point-to-point link between two routers: it needs exactly two usable addresses, but under fixed subnetting it might be handed a block of 62, leaving 60 stranded and unusable elsewhere.
This was tolerable when addresses felt infinite, but with IPv4 space scarce, that waste is unacceptable. VLSM — Variable-Length Subnet Masking — removes the one-size-fits-all constraint. It lets you apply different mask lengths to different subnets carved from the same block, so each subnet is only as large as its host count requires. The result is dense, efficient allocation with addresses left over for growth.
The Core Idea: Subnet the Subnets
VLSM works by treating subnetting as recursive. You take your address block, slice off a piece big enough for your largest subnet, then take what remains and slice off a piece for the next, and so on — each cut sized independently using the block-size method. Because each subnet uses the smallest mask that fits, the leftover space stays contiguous and available rather than being pre-chopped into equal, mostly-empty blocks.
The discipline that makes this work cleanly is one rule: allocate largest first. If you place big subnets before small ones, every allocation lands on a natural boundary and nothing fragments. Do it out of order and you can paint yourself into a corner where a large subnet no longer fits in the gaps left behind.
A Worked Allocation
Suppose you are given 192.168.10.0/24 (256 addresses) and need four subnets:
- Sales — 100 hosts
- Engineering — 50 hosts
- Office — 25 hosts
- Router link — 2 hosts
Sort largest to smallest (already done), then for each pick the smallest mask whose usable count covers the need, and allocate from the next free address:
| Subnet | Need | Mask | Block | Range | Usable |
|---|---|---|---|---|---|
| Sales | 100 | /25 | 128 | .0 – .127 | 126 |
| Engineering | 50 | /26 | 64 | .128 – .191 | 62 |
| Office | 25 | /27 | 32 | .192 – .223 | 30 |
| Router link | 2 | /30 | 4 | .224 – .227 | 2 |
Walk it through: Sales needs 100, and a /25 gives 126 usable — the smallest fit — so it takes .0–.127. Engineering needs 50; a /26 gives 62, taking the next free block .128–.191. Office needs 25; a /27 gives 30, taking .192–.223. The router link needs 2; a /30 gives exactly 2, taking .224–.227. Total consumed: 228 of 256 addresses, with .228–.255 still free for future subnets. Under fixed subnetting sized for the 100-host subnet (/25), you could have fit only two subnets in the whole /24 — VLSM fit four and left room to spare.
Picking the Mask for Each Subnet
The only judgement call per subnet is choosing the mask, and the rule is mechanical: find the smallest mask whose usable-host count (2^host-bits − 2) is at least the number you need. Round up to the next power of two, then subtract for network and broadcast. A few common targets:
| Hosts needed | Mask | Usable |
|---|---|---|
| up to 2 | /30 | 2 |
| 3–6 | /29 | 6 |
| 7–14 | /28 | 14 |
| 15–30 | /27 | 30 |
| 31–62 | /26 | 62 |
| 63–126 | /25 | 126 |
Always leave a little headroom for growth — if a subnet has 30 hosts today and might reach 40, a /26 (62 usable) is wiser than a /27 (30 usable) that is already full. The point-to-point link deserves a note: a /30 is the traditional choice for exactly two hosts, and a /31 is even tighter, providing two usable addresses with no separate network or broadcast — purpose-built for router-to-router links.
What VLSM Requires Underneath
VLSM has one prerequisite that is worth understanding. When every subnet shared a single mask, a router could assume that mask everywhere. With variable masks, that assumption breaks — a router must be told the specific mask for each route, because it can no longer guess. This means the network's routing must carry the subnet mask alongside every advertised route, which is the defining feature of classless routing. All modern routing protocols do this, which is why VLSM is simply how networks are built today rather than a special technique.
It connects directly to CIDR: VLSM is essentially CIDR applied inside an organization's own address space, sizing internal subnets freely, while CIDR more broadly describes the classless allocation and route aggregation used across the whole internet. Both rest on the same shift away from rigid, fixed-size address classes toward masks chosen to fit the need. For the arithmetic each allocation relies on, see how to calculate a subnet.
Frequently Asked Questions
What is VLSM?
Variable-Length Subnet Masking — using different mask sizes within one network so each subnet fits the hosts it needs. Instead of equal pieces, a 2-address link can use a tiny subnet while a 100-user department gets a larger one, conserving address space.
Why is VLSM more efficient than fixed subnetting?
Fixed subnetting makes every subnet the same size — large enough for the biggest — wasting addresses on small ones. A 2-host link would still consume a whole block. VLSM sizes each subnet independently, so small subnets stay small and the saved space remains available.
How do you allocate subnets with VLSM?
Sort the subnets largest to smallest, then allocate each from the available space using the smallest mask that fits its host count, moving to the next free address each time. Working largest-first prevents fragmentation by keeping allocations on clean boundaries.
What mask do I use for a point-to-point link?
A /30 is traditional — two usable addresses plus a network and broadcast. A /31 is even more efficient, giving two usable addresses with no separate network or broadcast, and is widely supported for point-to-point links.
Does VLSM require a routing protocol that supports it?
Yes. Because masks differ per subnet, routers must exchange the mask with each route rather than assume one network-wide mask. That needs a classless routing protocol carrying mask information. All modern routing protocols support it, so VLSM is standard practice.