A variable-length subnet mask (VLSM) is designed to allow greater use of IP address space by borrowing bits from the subnet mask and allocating them to host devices. To allow a greater number of devices to connect to the Internet and intranets, the standards bodies of various routing protocols designed an IP routing algorithm to cater to IP networks with a different subnet mask than the default used in classful networks.
NOTE Routing algorithms that support VLSM are as follows:
■ Intermediate System-to-Intermediate System (IS-IS)
Additionally, Cisco IOS allows the use of any 0 subnets (for example, subnet 126.96.36.199/24) with the global Cisco IOS command, ip subnet-zero. This can be very useful for networks that are running out of IP address space.
To effectively use any IP address space, use the least number of subnet bits and the least number of host bits. You could use a Class C mask or a mask that allows for 254 hosts. For a WAN link that will never use more than two hosts, this is a vast amount of wasted space. Applying different masks to cater to the exact requirement means that IP address space is not wasted unnecessarily.
Apply the formula to determine the best subnet to use to cater to two hosts on any given subnet and class of address. Remember that you must subtract two host addresses for the subnet address and broadcast address.
Applying the formula, you get 2n - 2 = 2, or 2n = 4, or n = 2. You need to borrow only 2 bits from the subnet mask to allow for two host addresses. The subnet mask is 30 bits in length, or 255.255.255.252 in binary. This is represented as 11111111.11111111.11111111.111111100. The last 2 bits (00) are available for host addresses. The subnet is 00, the first host address is 01, the second is 10, and the broadcast address is 11.
TIP Loopback interfaces configured on Cisco routers are typically configured with a host address using a 32-bit subnet mask. This allows, for example, a Class C network with 256 (from 0-255) hosts among 256 different routers and conserves valuable IP address space.
Was this article helpful?