# Cisco CCNA: variable length subnet mask, from start to finish.

Building an efficient network involves design, implementation and optimization. These three are merged together and called network engineering. Just like the foundation of a building, a badly designed network is not only a disaster to the engineer(s) who designed it, but also to the users of that network. Variable Length Subnet mask (VLSM) is a design strategy for effective and efficient utilization of IP addresses and for mitigating broadcast storm.Often times, inexperienced network engineers would go for classful addressing over VLSM. While this works, having a large network could create security issues, as well as make it difficult to isolate and narrow down a network issue to the right host on time. The following are some of the points to note about VLSM:

>> Saves IP address

>> Helps avoid broadcast storm on a network

>> Supports RIP version 2, OSPF and EIGRP

>> It is also known as classless addressing.

>> Aids in troubleshooting

### Example 1

Given 192.168.10.0/24, generate the best vlsm design that will address the following requirement: Sales(25), account(12), HSE(10), Security(6), WAN(2). See diagram below.

**Answer:**

To solve this problem, we are to start from the requirement with the highest number of hosts, using a subnetmask that will provide the number of required host without wasting much address. Because it may not be possible to get the exact number of hosts required on that subnet, getting the closest possible number is the aim.

For this question, the network with 25 users is the largest, so we start from there: 192.168.10.0/27. Because the number of users is 25, we look for a subnetmask that will provide it least 25 IPs. To get that, we say how many bits can we turn off so that 2 raised to that number can give us at least 25 IPs. For this, we will turn off 5 bits so that when we say 2^5-2=30. That is the closest since 4 bits off can not solve it. So we have

**192.168.10.0/27**for the subnet with 25 users.Next is the subnet with 12 users. First thing first, is to get the subnet address for this LAN, then the subnetmask that will provide at least 12 IPs. To get the subnet, we add the block size of the previous subnet to its subnet address. So, since the block size of the previous subnet is 32 (256-224=32), 32+0=32. Therefore, the next subnet is 192.168.10.32. Now, the subnetmask that will give us at least 12 IPs will be gotten when we turn off 4 bits. That will give us /28 (2^4-2=14). So we have

**192.168.10.32/28**for the subnet with 12 users.The subnet with 10 users has the same requirements as the one with 12 users. Since the block size of 192.168.10.32/28 is 16, we add 16 to 32 to get the next subnet. This will give us 192.168.10.48/28. So we have

**192.168.10.48/28**for the LAN with 10 users.For the LAN with 6 users, we need at least 6 IP addresses. To get that we find the next subnet then the subnetmask that will provide the closest possible number of addresses to 6. To get the subnet address, we add the block size of the last subnet to its subnet address, which is 48. That will be 48+16=64. If we turn off 3 bits, we will have 2^3-2=6. Three bits off is /29. So we have

**192.168.10.64/29**for the LAN with 6 users.Last is the subnet with the least number of users; 2 users. The WAN link requires only two IP addresses since it is a point to point link. 2 bits off will give 4. Subtracting the two IP addresses for the broadcast and subnet will leave us with the 2 needed IP addresses. This subnet will be 192.168.10.72/30. Remember that to get the next subnet, you are to add the block size of the previous subnet to its network address to get the next IP. Since the block size of the previous subnet is 8, I added 8 to 64 and that gave me 72. So, for the subnet with two users, we have

**192.168.10.72/30****Example 2:**

Give 192.168.0.0/24, using VLSM develop a suitable design that will address the following:

Sales: 67 users

Account: 54 users

IT: 23 users

HSE: 12 users

WAN: 2 users

**Answer:**

To address this, we start from the subnet with the highest number of hosts. If we turn off 7 bits, that will leave us with /25. 7 bits off will give us 2^7-2=126. Anything less than that will not solve the problem as it will provide less than the needed number of IP addresses. For sales, we have

**192.168.0.0/25**Account will be 192.168.0.128/26. Since the next subnet, using the block size of the previous subnet (192.168.0.0/25) is 128, when we add 128 to the previous subnet, which is the 0 subnet, we have 192.168.0.128. Turning of 6 bits will give us /26. 6 bits off will produce 62 valid hosts, which of course addresses the requirement of 54 users without wasting much IPs. Therefore, account will have**192.168.0.128/26.**IT with 23 users will be 192.168.0.192/27 HSE will be 192.168.0.224/28 while the WAN will be addressed with 192.168.0.240/30.

Sales with 67 users: 192.168.0.0/25

Account with 54 users: 192.168.0.128/26

IT with 23 users: 192.168.0.192/27

HSE with 12 users:192.168.0.224/28

WAN with 2 users 192.168.0.240/30