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:

256 bit block

64 bit 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”:

256 bit block

And chop it into the blocks we just specified:

VLSM Block Sizes

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:

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

If you like to keep on reading, Become a Member Now!

  • 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!
  • Full Access to our 799 Lessons. More Lessons Added Every Week!
  • Content created by Rene Molenaar (CCIE #41726)
567 Sign Ups in the last 30 days
satisfaction-guaranteed

  • 100% Satisfaction Guaranteed!
  • You may cancel your monthly membership at any time.
  • No Questions Asked!

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)

    network address: 10.0.0.0/22
    netmask: 255.255.252.0
    first host: 10.0.0.1
    last host: 10.0.3.254
    broadcast add

    ... Continue reading in our forum

  2. Hi Gabriel,

    Your example is correct, good job! Also thanks for reporting those errors, just fixed them.

    Rene

  3. Hi Rene,

    Can you pls elaborate on how you got this subnet mask? I didn’t get it. thanks
    <>

  4. Sure, which exact subnet mask do you refer to?

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