Variable Length Subnet Masking (VLSM) is the practice of carving one IP network into subnets of different sizes — each mask sized to the exact number of hosts that subnet must hold — instead of forcing every subnet to the same fixed length. By allocating the largest subnet first and working down, VLSM packs your requirements into the smallest possible address range and typically recovers 60-80% of the addresses that fixed-length subnetting throws away. The one requirement: VLSM only works with classless routing protocols (OSPF, EIGRP, RIPv2, IS-IS, BGP) that carry the subnet mask in their routing updates — classful protocols like RIPv1 can't.
That's the summary an AI overview will give you. What it can't hand you is the procedure — the largest-first allocation walk, the alignment rules that make it work, and a worked example you can copy. That's the rest of this page.
Fixed-length vs. VLSM at a glance
Fixed-length subnetting (FLSM) picks one mask and stamps it on every subnet. That mask has to be big enough for your largest segment, so every smaller segment inherits the same oversized block. The diagram below shows the same six requirements allocated both ways — equal-width waste on top, right-sized on the bottom.
The blue represents addresses that actually get used; the amber is dead space nothing can touch. Fixed-length leaves the whole network drowning in amber. VLSM squeezes it out.
The problem with fixed-length subnetting
Scenario: you're subnetting 172.16.0.0/16 for a branch office with these segments:
| Segment | Hosts needed |
|---|---|
| Engineering | 120 |
| Sales | 60 |
| Guest Wi-Fi | 50 |
| HR | 25 |
| IT | 12 |
| Servers | 8 |
With fixed-length subnetting you pick one mask for everyone. Your largest segment (Engineering, 120 hosts) needs a /25 (126 usable), so every subnet becomes a /25 — even the 8-host Servers segment:
6 subnets × /25 = 6 × 128 = 768 addresses allocated
Actually used: 120 + 60 + 50 + 25 + 12 + 8 = 275
Wasted: 493 addresses (64%)
And that's the disciplined fixed-length plan. In the field, admins often reach for the familiar /24 on every VLAN, which balloons the allocation to 6 × 256 = 1,536 addresses — over 80% wasted. Either way, fixed-length forces the small segments to carry the largest segment's mask.
VLSM: right-sizing every subnet
VLSM gives each segment the smallest mask that still fits its host count. Round each requirement up to the next power of two, remembering that every subnet loses two addresses (network + broadcast):
| Segment | Hosts needed | Smallest mask | Usable hosts | Addresses consumed |
|---|---|---|---|---|
| Engineering | 120 | /25 | 126 | 128 |
| Sales | 60 | /26 | 62 | 64 |
| Guest Wi-Fi | 50 | /26 | 62 | 64 |
| HR | 25 | /27 | 30 | 32 |
| IT | 12 | /28 | 14 | 16 |
| Servers | 8 | /28 | 14 | 16 |
Total allocated: 128 + 64 + 64 + 32 + 16 + 16 = 320 addresses
Actually used: 275
Wasted: 45 addresses (14%)
Same six segments, same requirements — 320 addresses instead of 768 (or 1,536 with the sloppy all-/24 plan). VLSM cut the allocation by 58% versus disciplined fixed-length, and by 79% versus all-/24. Everything still fits inside 172.16.0.0/23, leaving the rest of the /16 free for future growth.
The worked example: largest-first allocation
VLSM only works if you allocate in a specific order. Here is the exact procedure, applied to the scenario above.
Step 1 — Sort requirements largest to smallest
Engineering (120) → Sales (60) → Guest (50) → HR (25) → IT (12) → Servers (8). This ordering is not optional. Larger subnets have stricter alignment: a /25 must begin on a 128-address boundary, a /26 on a 64-address boundary, and so on. Place a small subnet first and it can leave a gap too small or misaligned to hold a large one later.
Step 2 — Walk the address space, assigning smallest-fitting masks
Start the pointer at 172.16.0.0 and give each segment its block, then advance the pointer by that block's size:
| Segment | Network | Mask | Usable range | Broadcast | Hosts used |
|---|---|---|---|---|---|
| Engineering | 172.16.0.0 | /25 | 172.16.0.1 – 172.16.0.126 | 172.16.0.127 | 120 |
| Sales | 172.16.0.128 | /26 | 172.16.0.129 – 172.16.0.190 | 172.16.0.191 | 60 |
| Guest Wi-Fi | 172.16.0.192 | /26 | 172.16.0.193 – 172.16.0.254 | 172.16.0.255 | 50 |
| HR | 172.16.1.0 | /27 | 172.16.1.1 – 172.16.1.30 | 172.16.1.31 | 25 |
| IT | 172.16.1.32 | /28 | 172.16.1.33 – 172.16.1.46 | 172.16.1.47 | 12 |
| Servers | 172.16.1.48 | /28 | 172.16.1.49 – 172.16.1.62 | 172.16.1.63 | 8 |
Notice how each network address lands exactly where the previous subnet's broadcast leaves off — .127 then .128, .191 then .192 — with zero gaps. That contiguity is the payoff of allocating largest-first.
Step 3 — Verify no overlaps
Every subnet's range must be disjoint from the others. Punch each network and mask into a calculator and confirm the ranges never touch. This is exactly the kind of check that's easy to get wrong by hand and trivial to confirm with a tool:
Why VLSM needs classless routing
VLSM only works if your routers can advertise which mask goes with each subnet. Classful protocols assume one mask per major network and drop that information — so 172.16.1.0/28 and 172.16.0.0/25 look like the same "172.16 network" to them. You need a classless (VLSM-aware) protocol that carries the mask in every update.
Protocols that support VLSM: OSPF, EIGRP, RIPv2, IS-IS, BGP. Protocols that do NOT: RIPv1, IGRP (classful — one mask per network).
With a classless protocol, a routing table happily holds variable-length masks side by side:
172.16.0.0/25 via Router A
172.16.0.128/26 via Router B
172.16.1.0/27 via Router B
172.16.1.32/28 via Router C
VLSM vs. CIDR vs. supernetting
These three terms all describe classless masking, applied at different scopes — which is why they're easy to confuse:
| Concept | What it does | Where it's used |
|---|---|---|
| VLSM | Divides one network into variable-sized subnets | Inside your organization |
| CIDR | Variable-length masking for allocating/aggregating blocks between networks | Across the internet (ISPs, registries) |
| Supernetting | Combines several smaller networks into one larger block | ISPs aggregating customer routes |
VLSM slices a block downward into right-sized pieces; supernetting merges blocks upward into a summary route. CIDR is the internet-wide framework that makes both possible. They're complementary, not competing.
Implementation considerations
Planning is stricter. With one uniform mask you can eyeball allocations; with VLSM you must know real device counts, add growth headroom, and keep the largest-first ordering. Get the order wrong and you fragment the address space.
Leave room for growth. Right-sizing to today's exact count is a trap. If HR has 25 hosts and you give it a /27 (30 usable), one new printer bank pushes you over. Add 20-30% headroom — or bump to the next mask when a segment is close to a power-of-two boundary.
Documentation is not optional. Non-standard subnet sizes are easy to forget six months later. Keep a living allocation table like the one above, including the gateway for each subnet, so nobody re-uses a range or misaligns the next one.
When not to use VLSM
VLSM buys address efficiency at the cost of complexity. Skip it when:
- Address space is effectively unlimited — an IPv6 design or an internal RFC 1918
/8where clean, uniform/24s are worth more than saved addresses. - Your routing can't support it — legacy gear running RIPv1 or classful IGRP.
- Simplicity matters more than density — small networks, or teams still learning subnetting, where readable uniform blocks reduce mistakes.
If you have plenty of addresses, the readability of fixed-length subnetting can outweigh the waste. VLSM earns its keep when address space is scarce, expensive, or public.
Conclusion
VLSM turns subnetting from rigid one-size-fits-all allocation into flexible right-sizing. By sorting requirements largest-first and giving each segment the smallest mask that fits, you fold the same six-segment design from 768 (or 1,536) addresses down to 320 — freeing the rest of the parent network for growth. The trade-offs are real: more careful planning, disciplined documentation, and a classless routing protocol. For most IPv4 networks, where addresses are finite and the routing already supports it, that trade is well worth making. Verify every allocation with a subnet calculator so your VLSM design is mathematically correct and overlap-free before it ever touches production.