Old-school "fixed-length" subnetting splits a network into equal pieces — every subnet gets the same mask. That's wasteful: a link between two routers needs just 2 usable addresses, but a fixed /27 hands it 30. VLSM fixes that by letting subnets have different mask lengths.

The problem VLSM solves

Imagine you have 192.168.1.0/24 and these needs: a 100-host LAN, a 50-host LAN, a 25-host LAN, and two point-to-point router links (2 hosts each). Fixed-length subnetting forces one mask for all of them — and the biggest subnet (100 hosts) needs a /25, so every subnet would have to be a /25. You'd run out after two subnets. VLSM lets each be exactly as big as it needs.

How to do VLSM (largest first)

Always allocate from biggest to smallest so blocks line up and never overlap:

Network: 192.168.1.0/24

100 hosts -> /25  192.168.1.0/25     (.0   - .127)
 50 hosts -> /26  192.168.1.128/26   (.128 - .191)
 25 hosts -> /27  192.168.1.192/27   (.192 - .223)
  2 hosts -> /30  192.168.1.224/30   (.224 - .227)
  2 hosts -> /30  192.168.1.228/30   (.228 - .231)
                  ... .232 - .255 still free

One /24 covered every requirement and left room to grow. That's the whole point.

VLSM vs CIDR

They're related and both "classless," but not the same. VLSM is subnetting within your network using varied masks. CIDR is the bigger concept — classless addressing and route aggregation (summarizing many networks into one prefix) used across the internet. Think of VLSM as CIDR applied inside one organization.

Requirements

Because subnets no longer share a single mask, your routing protocol must carry the mask with each route. That means a classless protocol — OSPF, EIGRP, RIPv2 — and on legacy gear, turning off auto-summary. Classful protocols (RIPv1) can't do VLSM.