Variable Length Subnet Masks (VLSM) is nothing but having the flexibility to allot different sized subnetworks within a single network. That means that the number of subnet bits allotted to different subnetworks within a single network may not be the same for all subnetworks. VLSM is useful for partitioning the main network into different variable sized subnetworks, as would typically be the requirement in most of the organizations.
The example given below illustrates VLSM.
In the diagram given above, the ISP has allotted 256 IP addresses to the organization, with the common IP address prefix 188.8.131.52. The number of nodes inside each of the three departments in the organization are different, with the Engineering department being bigger and requiring 128 IP addresses and the Accounts and HR departments requiring 64 IP addresses each. So, a variable sized subnetting strategy is used within the organization. Out of the 8 bits available for the end hosts (4th byte of the IP address), one bit (25th alone) is used as the subnet bit for the Engineering Subnet(/25 subnet mask). For the Accounts and HR department, two bits (bits 25 and 26 of the IP address) are borrowed from the host bits to be used for subnetting purposes. This is just an example and we could even have subnets with just 4 addresses (/30 subnet mask).
The diagram given below illustrates the subnet masks represented in binary form for all the three subnets shown in the previous diagram.
As shown in the above diagram, the network prefix, consisting of the first 3 bytes is same for all the three subnetworks, namely 184.108.40.206. The variation comes in the 25th and 26th bits. For the Engineering subnet, 1 bit is allotted for the subnet and it has a value of 0. All the IP addresses in the Engineering subnet start with a value of 0 in bit position 25. For the Accounts and HR subnets, two bits are allotted for the subnet (bits 25 and 26). While bit 25 has a value 1 for both these subnets, bit 26 has a value of 0 for the HR subnet and bit 26 has a value of 1 for the Accounts Subnet. Since two bits are allotted for the subnet itself, only 6 bits are available for the end hosts for the Accounts and HR networks. This means that a total of 62 hosts (64 – 2 special addresses) can belong to each of these subnets. However, for the Engineering subnet, since 7 bits are available for the end hosts, there can be a total of 126 (128 – 2 special addresses) hosts in this subnet.
Thus, as illustrated in the above example, VLSM allows organizations to create different sized internal networks.