Skip to content

VLSM - Variable Length Subnet Masking

VLSM (Variable Length Subnet Masking) is the ability to use different prefix lengths (subnet masks) for different subnets within the same supernet. This is what CIDR enables.

Without VLSM (classful routing), every subnet in a network had to use the same mask. With VLSM, you can carve out exactly the right size subnet for each use case from a single allocated block.


You have been allocated 192.168.10.0/24 (256 addresses total). You need to subdivide it for:

  • 1 subnet for 60 servers
  • 2 subnets for 26 workstations each
  • 2 point-to-point WAN links (2 hosts each)

Classfully you’d need 5 separate /24 networks. With VLSM you carve them all out of one /24:

192.168.10.0/24 (total: 256 addresses)
├── 192.168.10.0/26 → 62 hosts (servers)
├── 192.168.10.64/27 → 30 hosts (workstations A)
├── 192.168.10.96/27 → 30 hosts (workstations B)
├── 192.168.10.128/30 → 2 hosts (WAN link 1)
├── 192.168.10.132/30 → 2 hosts (WAN link 2)
└── 192.168.10.136/24 remainder → unallocated, available for future use

Only 192.168.10.0–135 are committed. The rest stays available.


Always allocate largest subnets first to avoid fragmentation.

Requirements: Plan subnets using 10.0.0.0/16 for:

  • Data center: 2000 servers
  • Office A: 500 workstations
  • Office B: 200 workstations
  • DMZ: 30 servers
  • Voice: 100 phones
  • Management: 10 devices
  • 3 WAN links (2 hosts each)

Step 1: Sort by size (largest first)

SubnetHosts NeededBits RequiredPrefixBlock Size
Data center200011 bits (2048)/21/21 = 2046 usable
Office A50010 bits (1024)/22/22 = 1022 usable
Office B2008 bits (256)/24/24 = 254 usable
Voice1007 bits (128)/25/25 = 126 usable
DMZ305 bits (32)/27/27 = 30 usable
Management104 bits (16)/28/28 = 14 usable
WAN x32 each2 bits (4)/30/30 = 2 usable

Step 2: Allocate sequentially

SubnetNetwork AddressBroadcastUsable Range
Data center10.0.0.0/2110.0.7.25510.0.0.1 – 10.0.7.254
Office A10.0.8.0/2210.0.11.25510.0.8.1 – 10.0.11.254
Office B10.0.12.0/2410.0.12.25510.0.12.1 – 10.0.12.254
Voice10.0.13.0/2510.0.13.12710.0.13.1 – 10.0.13.126
DMZ10.0.13.128/2710.0.13.15910.0.13.129 – 10.0.13.158
Management10.0.13.160/2810.0.13.17510.0.13.161 – 10.0.13.174
WAN Link 110.0.13.176/3010.0.13.17910.0.13.177 – 10.0.13.178
WAN Link 210.0.13.180/3010.0.13.18310.0.13.181 – 10.0.13.182
WAN Link 310.0.13.184/3010.0.13.18710.0.13.185 – 10.0.13.186

Terminal window
# ipcalc (Linux) - calculate subnet details
ipcalc 10.0.0.0/21
# Network: 10.0.0.0/21
# Netmask: 255.255.248.0
# Broadcast: 10.0.7.255
# HostMin: 10.0.0.1
# HostMax: 10.0.7.254
# Hosts/Net: 2046
# Check if an IP is in a subnet
ipcalc 10.0.5.100/21
# If it shows the same Network address as above, it's in the same subnet
# sipcalc - more detailed output
sipcalc 10.0.8.0/22
# Python one-liner
python3 -c "import ipaddress; n = ipaddress.ip_network('10.0.0.0/21'); print(f'Hosts: {n.num_addresses-2}, First: {n.network_address+1}, Last: {n.broadcast_address-1}')"
# See all usable IPs in a subnet
python3 -c "import ipaddress; [print(ip) for ip in ipaddress.ip_network('10.0.13.176/30').hosts()]"
# 10.0.13.177
# 10.0.13.178

VLSM also works in reverse - supernetting combines multiple contiguous subnets into a single summary route, reducing routing table size.

Individual routes:
192.168.0.0/24
192.168.1.0/24
192.168.2.0/24
192.168.3.0/24
Summary route (supernet):
192.168.0.0/22 ← covers all four /24s
Router only needs 1 entry instead of 4

Condition: Subnets must be contiguous and the block must start on a boundary aligned to the summary prefix.

Terminal window
# Find summary route in Python
python3 -c "
import ipaddress
nets = ['192.168.0.0/24', '192.168.1.0/24', '192.168.2.0/24', '192.168.3.0/24']
objs = [ipaddress.ip_network(n) for n in nets]
print(list(ipaddress.collapse_addresses(objs)))
# [IPv4Network('192.168.0.0/22')]
"

AspectFLSM (classful)VLSM (classless)
Subnet sizeAll same within a networkEach subnet can be different
Routing protocolRIPv1OSPFv2, EIGRP, BGP, RIPv2
Address wasteHigh (must fit everyone in same /mask)Minimal (allocate to fit)
ComplexitySimpleRequires planning
Route tableLarger (one entry per subnet)Smaller (with aggregation)