# Variable Length Subnet Mask (VLSM)

In previous subnetting lessons here and here all our subnets had a “fixed size”. Each subnet had the same size. For example we took a class C network 192.168.1.0 and divided it 4 blocks:

Is this really an efficient way of creating subnets? Let’s say I would have the following requirements:

• One subnet for 12 hosts.
• One subnet for 44 hosts.
• One subnet for 2 hosts (point-to-point links are a good example where you only need 2 IP host addresses).
• One subnet for 24 hosts.

I have 4 subnets so it’s no problem, but I’m still wasting a lot of IP addresses. If we use a block of 64 for our subnet where I only need 2 IP addresses I’m throwing 62 IP addresses away.

Now you might think why we could care about this because we are using a private network address (192.168.1.0) and we have plenty of space. This is true, but what about the Internet? We don’t want to throw away valuable public IP addresses.

Let’s say I want to subnet my 192.168.1.0 network in the most efficient way, let’s take another look at the requirements I just showed you:

• One subnet for 12 hosts.
• One subnet for 44 hosts.
• One subnet for 2 hosts.
• One subnet for 24 hosts.

What kind of subnets would we need to fit in these hosts? Let’s see:

• 12 hosts, the smallest subnet would be a block of 16.
• 44 hosts, the smallest subnet would be a block of 64.
• 2 hosts, the smallest subnet would be a block of 4.
• 24 hosts, the smallest subnet would be a block of 32.

Let’s create the subnets. We take our block of “256”:

And chop it into the blocks we just specified:

We just saved ourselves some valuable IP addresses, now the next thing to do is answer the following questions:

• What are the network addresses?
• What is the subnet mask?
• What are the usable host IP addresses?
When using VLSM, make sure you start with the biggest subnet first or you will have overlapping address space.

• Subnet 1: (size of 64)
• Subnet 2: (size of 32)
• Subnet 3: (size of 16)
• Subnet 4: (size of 4)
• Subnet 5: (this is where the free space starts)

• Subnet 1: (size of 64)
• Subnet 2: (size of 32)
• Subnet 3: (size of 16)
• Subnet 4: (size of 4)

Because we have different subnet sizes, we need to calculate the subnet mask for each subnet. To find the subnet mask you can use this trick:

256 – subnet size = subnet mask

• Subnet 1: 256 – 64 = 192 so the subnet mask is 255.255.255.192
• Subnet 2: 256 – 32 = 224 so the subnet mask is 255.255.255.224
• Subnet 3: 256 – 16 = 240 so the subnet mask is 255.255.255.240
• Subnet 4: 256 – 4 = 252 so the subnet mask is 255.255.255.252

The only thing left to do is fill in the usable host IP addresses:

• Subnet 1: (size of 64)
• first host: 192.168.1.1
• last host: 192.168.1.62
• Subnet 2: (size of 32)
• first host: 192.168.1.65
• last host: 192.168.1.94
• Subnet 3: (size of 16)
• first host: 192.168.1.97
• last host: 192.168.1.110
• Subnet 4: (size of 4)
• first host: 192.168.1.113
• last host: 192.168.1.114

Here we go, we just subnetted our 192.168.1.0 /24 by using VLSM.

Let’s try another example but this time we use a Class B 172.16.0.0 network with different requirements:

• One subnet for 340 hosts.
• One subnet for 250 hosts.
• One subnet for 31 hosts.
• One subnet for 20 hosts.
• One subnet for 8 hosts.

To solve this question first we need to determine the “block” that we require:

### We're Sorry, Full Content Access is for Members Only...

If you like to keep on reading, Become a Member Now! Here is why:

• Learn any CCNA, CCNP and CCIE R&S Topic. Explained As Simple As Possible.
• Try for Just \$1. The Best Dollar You’ve Ever Spent on Your Cisco Career!
• Content created by Rene Molenaar (CCIE #41726)

100% Satisfaction Guaranteed!
You may cancel your monthly membership at any time.

## Forum Replies

1. Rene,

A good way to explain this subject that is a little confuse.
About challenge, I tried to solve it…

A network 10.0.0.0

One subnet for 600 hosts -> It’s need a block 1024
One subnet for 250 hosts. -> It’s need a block 256
One subnet for 120 hosts. -> It’s need a block 128
One subnet for 30 hosts. -> It’s need a block 32
One subnet for 2 hosts. -> It’s need a block 4

A block of 1024 is like 4x256, which is need 10 hosts bits.

So…

Subnet 1: (size 1024)

first host: 10.0.0.1
last host: 10.0.3.254

... Continue reading in our forum

2. Hi I’m having hard time figuring out the Subnet Mask, Hosts, Subnets, Network ID and Broadcast ID for the following IP Address. I hope someone can help me answers. Cheers!

150.12.110.10/25

112.10.78.40/22

50.1.112.10/21

28.10.145.10/18

150.50.50.50/23

100.10.185.10/20

172.16.221.10/19

3. Hi Lynkaran,

I’ll explain how to do the first example, see if you can solve them with my technique. Let’s start with 112.10.78.40/22:

First we need to figure out what the subnet mask since /22 doesn’t tell us much. You need to write this down in binary and convert it to decimal:

first 8 bits = 11111111 (255 in decimal)
next 8 bits = 11111111 (255 in decimal)
next 8 bits = 11111100 (252 in decimal)
next 8 bits = 00000000 (0 in decimal)

So now we know the subnet mask is 255.255.252.0

How many hosts do we have per subnet? There are 2 + 8 host bits so 10 host bits

... Continue reading in our forum

4. Hi Rene,

I was trying to figure out a way of “knowing” the amount of bits needed for huge hosts without the need of a calculator, like:

• 2^X-2= hosts (too complicated).

This way sorts the problem!

"

You can see that whenever the subnet becomes smaller, we can only use half of the addresses. I can apply the same logic if I move into the other direction:

2

... Continue reading in our forum

5. Hello Rahul

If you were to use three separate subnets to accommodate 600 hosts then you could create them, but they would still be separate subnets. For example, you could use

192.168.0.0/24
192.168.1.0/24
192.168.2.0/24

That would give you 256*3 = 768 IP addresses.

However, you would still have three SEPARATE subnets each requiring a network address, a broadcast address and a default gateway. You would also require routing to communicate between the subnets. For example, a host at 192.168.0.26 needs to go through a router to reach 192.168.2.26.

If you want

... Continue reading in our forum

30 more replies! Ask a question or join the discussion by visiting our Community Forum