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 are the broadcast 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.

Let’s answer these questions. We’ll start with the network addresses:

Subnet 1: (size of 64)

network address: 192.168.1.0

Subnet 2: (size of 32)

network address: 192.168.1.64

Subnet 3: (size of 16)

network address: 192.168.1.96

Subnet 4: (size of 4)

network address: 192.168.1.112

Subnet 5: (this is where the free space starts)

network address: 192.168.1.116

Now we can fill in the broadcast addresses:

Subnet 1: (size of 64)

network address: 192.168.1.0

broadcast address: 192.168.1.63

Subnet 2: (size of 32)

network address: 192.168.1.64

broadcast address: 192.168.1.95

Subnet 3: (size of 16)

network address: 192.168.1.96

broadcast address: 192.168.1.111

Subnet 4: (size of 4)

network address: 192.168.1.112

broadcast address: 192.168.1.115

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)

network address: 192.168.1.0

first host: 192.168.1.1

last host: 192.168.1.62

broadcast address: 192.168.1.63

Subnet 2: (size of 32)

network address: 192.168.1.64

first host: 192.168.1.65

last host: 192.168.1.94

broadcast address: 192.168.1.95

Subnet 3: (size of 16)

network address: 192.168.1.96

first host: 192.168.1.97

last host: 192.168.1.110

broadcast address: 192.168.1.111

Subnet 4: (size of 4)

network address: 192.168.1.112

first host: 192.168.1.113

last host: 192.168.1.114

broadcast address: 192.168.1.115

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:

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.