What is VLSM?
Variable Length Subnet Masking (VLSM) is an IP network subdivision technique that allows using subnet masks of different lengths within the same main network. Unlike traditional classful addressing (Classes A, B, and C), VLSM assigns network prefixes of variable length based on the number of hosts each subnet requires, eliminating address waste.
VLSM is the foundation of CIDR (Classless Inter-Domain Routing), introduced by the IETF in 1993 (RFC 1518 and RFC 1519) to replace the classful network addressing architecture. Its goal was to slow IPv4 address exhaustion and reduce the size of global routing tables. The classful system only offered three possible network sizes (256, 65,536, or 16,777,216 addresses), causing enormous waste. VLSM allows each subnet to be exactly the size it needs, optimizing address space utilization.
Step-by-Step VLSM Example
The best way to understand VLSM subnetting is with a real example. Let's design an addressing plan for a 192.168.1.0/24 network that needs to be divided into four subnets with different requirements:
| Subnet | Hosts required |
|---|---|
| Main LAN | 50 |
| Secondary LAN | 25 |
| WAN Link 1 | 2 |
| WAN Link 2 | 2 |
Step 1: Sort subnets from largest to smallest
The first rule of VLSM subnetting is to sort all subnets by host count in descending order. Large blocks need contiguous space, and assigning them first prevents addressing fragmentation. Our order is: Main LAN (50) → Secondary LAN (25) → WAN 1 (2) → WAN 2 (2).
Step 2: Calculate the CIDR prefix and block size for each subnet
Each subnet needs a mask that provides at least required_hosts + 2 addresses (one for the network address and one for broadcast). The block size must be a power of 2.
- Main LAN (50 hosts): Needs 52 addresses → next power of 2 = 64 → /26 (255.255.255.192). Provides 62 usable addresses.
- Secondary LAN (25 hosts): Needs 27 addresses → next power of 2 = 32 → /27 (255.255.255.224). Provides 30 usable addresses.
- WAN 1 and WAN 2 (2 hosts): Need 4 addresses → block of 4 → /30 (255.255.255.252). Provides 2 usable addresses each.
Step 3: Assign address ranges sequentially
Starting from 192.168.1.0, we assign blocks in descending size order:
- Main LAN (/26): 192.168.1.0 → 192.168.1.63. The block occupies the first 64 addresses.
- Secondary LAN (/27): 192.168.1.64 → 192.168.1.95. The next block starts right where the previous one ended.
- WAN 1 (/30): 192.168.1.96 → 192.168.1.99.
- WAN 2 (/30): 192.168.1.100 → 192.168.1.103.
Step 4: Final result
The complete VLSM plan looks like this:
| Subnet | Network | CIDR | Mask | IP Range | Broadcast | Hosts |
|---|---|---|---|---|---|---|
| Main LAN | 192.168.1.0 | /26 | 255.255.255.192 | 192.168.1.1 – 192.168.1.62 | 192.168.1.63 | 62 |
| Secondary LAN | 192.168.1.64 | /27 | 255.255.255.224 | 192.168.1.65 – 192.168.1.94 | 192.168.1.95 | 30 |
| WAN 1 | 192.168.1.96 | /30 | 255.255.255.252 | 192.168.1.97 – 192.168.1.98 | 192.168.1.99 | 2 |
| WAN 2 | 192.168.1.100 | /30 | 255.255.255.252 | 192.168.1.101 – 192.168.1.102 | 192.168.1.103 | 2 |
We used 104 addresses out of 256 available in the /24 block, wasting only 17 addresses total. We still have 152 free addresses for future expansion — more than half the original block. This is the efficiency a good VLSM calculator delivers.
VLSM vs FLSM: Detailed Comparison
To truly appreciate the advantage of VLSM, let's compare the previous result with what would happen if we used FLSM (Fixed Length Subnet Mask) for the same four subnets.
What would have happened with FLSM?
With FLSM, dividing 192.168.1.0/24 into 4 equal subnets means creating four /26 subnets (64 addresses each, 62 usable):
| Subnet | CIDR | Available IPs | Required IPs | Wasted IPs |
|---|---|---|---|---|
| Main LAN | /26 | 62 | 50 | 12 |
| Secondary LAN | /26 | 62 | 25 | 37 |
| WAN 1 | /26 | 62 | 2 | 60 |
| WAN 2 | /26 | 62 | 2 | 60 |
Efficiency comparison
| Metric | FLSM (fixed /26) | VLSM (variable) |
|---|---|---|
| Total IPs used | 256 (100% of /24) | 104 (40.6%) |
| Wasted IPs | 169 | 17 |
| Free IPs for growth | 0 | 152 |
| Allocation efficiency | 34% | 83.7% |
The cost of FLSM waste
With FLSM, the two WAN links that only need 2 IP addresses each receive a full /26 subnet with 62 usable addresses. That means 60 out of every 62 addresses are wasted per WAN link. In total, FLSM wastes 169 addresses — over 66% of the original /24 block — to meet the exact same requirements.
With VLSM, the WAN links use /30 (only 4 addresses each, zero waste), and each LAN receives exactly the size it needs. The net savings amount to 152 recovered addresses that remain available for new segments, future growth, or additional networks.
This comparison demonstrates why VLSM subnetting is indispensable in modern network administration and why protocols like RIP v2, OSPF, and EIGRP natively support it, while classful protocols like RIPv1 became obsolete.
Common Use Cases
- Enterprise addressing planning: Design efficient IP schemes for organizations with departments requiring different host counts, such as offices with 50 employees and server rooms with 10 devices.
- Network space optimization: Maximize the use of assigned IPv4 addresses, especially critical in environments with scarce public IPs or limited allocation ranges.
- IT infrastructure segmentation: Divide networks into specific subnets for servers, network equipment, end users, and IoT devices, allocating exactly the addresses each segment needs.
- University campus networks: Campuses are a classic VLSM use case. An Engineering department may need 200 addresses, while a small administrative office needs only 10 and an inter-building link requires 2. Without VLSM, every department would get the same subnet size, wasting hundreds of addresses. With VLSM, each faculty, lab, and access point receives exactly the block it needs.
- Cloud infrastructure (AWS VPC / Azure VNet): Cloud providers recommend VLSM when designing VPCs and VNets. For example, in AWS you can have a 10.0.0.0/16 VPC and split it using VLSM into public subnets for load balancers (/27), private app subnets (/24), database subnets (/26), and Transit Gateway attachment subnets (/30). Each workload type gets exactly the space it needs, optimizing address usage in multi-VPC environments.
Tips and Best Practices
- Always sort subnets from largest to smallest host count before assigning addresses; this minimizes wasted addressing space.
- Remember that each subnet loses 2 addresses: one for the network address (all host bits set to 0) and one for the broadcast address (all host bits set to 1).
- When designing your VLSM plan, consider future growth: leave free space in the base block to add more subnets or expand existing ones without having to redesign the entire scheme.