# Variable Length Subnet Masking
## What is VLSM
Variable Length Subnet Masking, abbreviated as VLSM, is a technique that allows different subnets within the same network to have different subnet masks. Before VLSM, all subnets within a classful network had to use the same subnet mask, which meant all subnets were the same size. VLSM removes this restriction and allows subnet sizes to be tailored to match the actual number of hosts required in each subnet. This leads to much more efficient use of IP address space.
## Why VLSM is Important
In a network with departments of very different sizes, using a single subnet mask for all subnets wastes IP addresses. If the largest department has 100 hosts, you might use a /25 subnet with 126 usable addresses. But a department with only 5 hosts would also get a /25 subnet with 126 usable addresses, wasting 121 addresses. With VLSM, the large department gets a /25 and the small department gets a /29 with only 6 usable addresses, wasting very little address space.
## How VLSM Works
VLSM works by subdividing subnets further after initial subnetting. You start with the largest subnet requirement and allocate the smallest block that fits it. Then you move to the next largest requirement and allocate from the remaining address space. This process continues for each subnet required, allocating only as much space as each subnet needs.
## VLSM Example
Suppose you have the network 192.168.1.0/24 and need to create subnets for departments with 50, 25, 10, and 2 hosts respectively. First, allocate for the 50-host requirement. A /26 provides 62 usable hosts, which is the smallest that fits. Allocate 192.168.1.0/26, covering addresses 0 through 63. Next, allocate for the 25-host requirement. A /27 provides 30 usable hosts. Allocate 192.168.1.64/27, covering addresses 64 through 95. Next, allocate for the 10-host requirement. A /28 provides 14 usable hosts. Allocate 192.168.1.96/28, covering addresses 96 through 111. Finally, allocate for the 2-host requirement. A /30 provides exactly 2 usable hosts. Allocate 192.168.1.112/30, covering addresses 112 through 115.
## VLSM Requirements
VLSM requires classless routing protocols that carry subnet mask information with routing updates. Classful routing protocols like RIP version 1 assume all subnets within a major network use the same mask and cannot support VLSM. Modern protocols including OSPF, EIGRP, BGP, and RIP version 2 are classless and fully support VLSM.Back to Subject