# Variable Length Subnet Mask (VLSM)

**URL:** https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219
**Category:** Lessons Discussion
**Created:** [December 29, 2016, 5:11pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219 "2016-12-29T17:11:01Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [December 29, 2016, 5:11pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/1 "2016-12-29T17:11:01Z")

</div>

This topic is to discuss the following lesson:

> **[Variable Length Subnet Mask (VLSM)](https://networklessons.com/subnetting/variable-length-subnet-mask-vlsm)**
>
> Variable Length Subnet Mask (VLSM) allows us to create subnets with different sizes. This lesson explains how to quickly calculate these subnets.

---

<div class="post-metadata">

### Author: ![gabrielba](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gabrielba](https://forum.networklessons.com/u/gabrielba)
#### Post date: [May 17, 2015, 3:26am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/2 "2015-05-17T03:26:45Z")

</div>

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 address: 10.0.3.255

Subnet 2: (size 250)

network address: 10.0.4.0/24  
netmask: 255.255.255.0  
first host: 10.0.4.1  
last host: 10.0.4.254  
broadcast address: 10.0.4.255

Subnet 3: (size 120)

network address: 10.0.5.0/25  
netmask: 255.255.255.128  
first host: 10.0.5.1  
last host: 10.0.5.126  
broadcast address: 10.0.5.127

Subnet 4: (size 30)

network address: 10.0.5.128/27  
netmask: 255.255.255.224  
first host: 10.0.5.129  
last host: 10.0.5.158  
broadcast address: 10.0.5.159

Subnet 5: (size 2)

network address: 10.0.5.160/30  
netmask: 255.255.255.252  
first host: 10.0.5.161  
last host: 10.0.5.162  
broadcast address: 10.0.5.163

I hope I’m right…

When you have a free time, please, fix the details below.  
“Subnet 2: 256 – 32 = \<\>” so the subnet mask is 255.255.255.224"  
and  
on subnet2 the last host IP should be 172.16.2.254

Hug and more a time, thanks for excellent work!!!

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [May 18, 2015, 12:15pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/3 "2015-05-18T12:15:24Z")

</div>

Hi Gabriel,

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

Rene

---

<div class="post-metadata">

### Author: ![gabrielba](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/g/e79b87/32.png) [@gabrielba](https://forum.networklessons.com/u/gabrielba)
#### Post date: [May 20, 2015, 3:11am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/4 "2015-05-20T03:11:46Z")

</div>

Rene,

Thanks!!!

Hug

---

<div class="post-metadata">

### Author: ![rajmannar](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/r/eb8c5e/32.png) [@rajmannar](https://forum.networklessons.com/u/rajmannar)
#### Post date: [July 13, 2015, 1:24pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/5 "2015-07-13T13:24:00Z")

</div>

Hi Rene,

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

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 13, 2015, 1:48pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/6 "2015-07-13T13:48:42Z")

</div>

Sure, which exact subnet mask do you refer to?

---

<div class="post-metadata">

### Author: ![rajmannar](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/r/eb8c5e/32.png) [@rajmannar](https://forum.networklessons.com/u/rajmannar)
#### Post date: [July 13, 2015, 2:03pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/7 "2015-07-13T14:03:20Z")

</div>

Subnet 1. 255.255.254.0

Subnet 1: this subnet is a block of “512” which is a combination of 2x “256”. A subnet with a size of 256 addresses normally has a subnet mask of 255.255.255.0 (/24). When we combine 2x 256 to get a 512 block, we give back one host bit so that means we have a /23 which is a subnet mask of 255.255.254.0.

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [July 13, 2015, 2:13pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/8 "2015-07-13T14:13:15Z")

</div>

Let me describe it this way, we know that a subnet mask of 255.255.255.0 has 256 addresses in total:

255.255.255.0 / 24 - 256 addresses

When we create smaller subnets, the list will be like this:

255.255.255.0 /24 - 256 addresses  
255.255.255.128 /25 - 128 addresses  
255.255.255.192 /26 - 64 addresses  
255.255.255.224 /27 - 32 addresses

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:

255.255.240.0 /21 - 2048 addresses  
255.255.248.0 /22 - 1024 addresses  
255.255.254.0 /23 - 512 addresses  
255.255.255.0 /24 - 256 addresses

Does this help?

Rene

---

<div class="post-metadata">

### Author: ![Iynkaran.Tharmakulas](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/i/3da27b/32.png) [@Iynkaran.Tharmakulas](https://forum.networklessons.com/u/Iynkaran.Tharmakulas)
#### Post date: [November 14, 2015, 8:08am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/9 "2015-11-14T08:08:39Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [November 14, 2015, 8:24am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/10 "2015-11-14T08:24:25Z")

</div>

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 in total. You can use this formula for this:

210 - 2 = **1024**.

You need to remove 2 since one address is the network address and the other one is the broadcast address.

What subnets do we have? There’s a quick way to calculate this. Take number 256 - subnet mask = size of subnet:

256 - 252 = **4**

Now we can write down the subnets, I’ll start with 0:

#1 112.10. **0**.0/22  
#2 112.10. **4**.0/22  
#3 112.10. **8**.0/22  
#4 112.10. **12**.0/22  
#5 112.10. **16**.0/22  
#6 112.10. **20**.0/22  
#7 112.10. **24**.0/22  
…and so on

You can see it increases with **4** every time, you now have your network addresses. What about the broadcast address? That’s the last address in each subnet.

For subnet #1 that will be 112.10. **3**. **255** and for subnet #5 it’s 112.10.1 **9.255**.

See if you can do the other examples on your own with these steps. All you need is practice, practice, practice.

Hope this helps.

Rene

---

<div class="post-metadata">

### Author: ![Iynkaran.Tharmakulas](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/i/3da27b/32.png) [@Iynkaran.Tharmakulas](https://forum.networklessons.com/u/Iynkaran.Tharmakulas)
#### Post date: [November 14, 2015, 8:48am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/11 "2015-11-14T08:48:35Z")

</div>

WOW! Awesome explanation! Thank you so much 🙂

---

<div class="post-metadata">

### Author: ![Iynkaran.Tharmakulas](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/i/3da27b/32.png) [@Iynkaran.Tharmakulas](https://forum.networklessons.com/u/Iynkaran.Tharmakulas)
#### Post date: [November 14, 2015, 8:56am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/12 "2015-11-14T08:56:51Z")

</div>

Quick question how did you get this answer when the slash value is /22?

first 8 bits = 11111111 (255 in decimal)  
next 8 bits = 11111111 (255 in decimal)  
next 8 bits = 11110000 (240 in decimal)  
next 8 bits = 00000000 (0 in decimal)

So now we know the **subnet mask is 255.255.240.0**

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [November 14, 2015, 11:40am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/13 "2015-11-14T11:40:30Z")

</div>

The value behind the slash are the number of bits that we use for the subnet mask:

11111111 11111111 11111100 00000

Those are 22 bits, when you convert it to decimal you get 255.255.252.0

---

<div class="post-metadata">

### Author: ![Iynkaran.Tharmakulas](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/i/3da27b/32.png) [@Iynkaran.Tharmakulas](https://forum.networklessons.com/u/Iynkaran.Tharmakulas)
#### Post date: [November 14, 2015, 4:20pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/14 "2015-11-14T16:20:41Z")

</div>

Wouldnt it be 255.255.252.0?

The nearest classfull mask that is bigger then our /22 is /24. So we subtract 22 from 24 and we get 2. This digit is the power of 2 we need.  
So as we get 2 we have to power up 2 by our result - 2.  
2^2=4  
Now we have to subtract this result (4) from 256(this is maximum quantity of subnet that we can get from 255 in netmask)  
256-4=252.  
So the result is /22 prefix is 255.255.252.0 netmask it is not the 255.255.240.0

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [November 14, 2015, 6:02pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/15 "2015-11-14T18:02:21Z")

</div>

Whoops, early morning error 🙂 You are totally right, I just edited my calculations.

---

<div class="post-metadata">

### Author: ![vikki1990agarwal12](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/v/e19b73/32.png) [@vikki1990agarwal12](https://forum.networklessons.com/u/vikki1990agarwal12)
#### Post date: [April 16, 2016, 10:55pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/16 "2016-04-16T22:55:51Z")

</div>

Hi Rene,  
Why do you always consider the subnet with the largest number of hosts first ?  
And then decide the block sizes of the smaller ones.  
Why cant we do the other way round ?

---

<div class="post-metadata">

### Author: ![ReneMolenaar](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/renemolenaar/32/488_2.png) [@ReneMolenaar](https://forum.networklessons.com/u/ReneMolenaar)
#### Post date: [April 17, 2016, 12:27pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/17 "2016-04-17T12:27:12Z")

</div>

Hi Vikas,

We do this because you can have issues with overlapping subnets. If you start with the largest subnets first and move on to the smaller ones then you won’t run into issues with overlapping addresses.

Rene

---

<div class="post-metadata">

### Author: ![apurvap69](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/a/3ab097/32.png) [@apurvap69](https://forum.networklessons.com/u/apurvap69)
#### Post date: [August 17, 2016, 9:26am UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/18 "2016-08-17T09:26:28Z")

</div>

Hi,

Thank you for awesome explanation. It is helping me a lot for my ccna studies

I was solving a problem as stated:-

Network ip- 172.16.0.0  
No. of host needed-120

subnet mask will be 255.255.255.128  
CIDR notation will be /25

so ip address range will be from 172.16.0.0 to 172.16.0.128

have I solved problem correctly.

---

<div class="post-metadata">

### Author: ![lagapidis](https://cdn-forum.networklessons.com/user_avatar/forum.networklessons.com/lagapidis/32/4949_2.png) [@lagapidis](https://forum.networklessons.com/u/lagapidis)
#### Post date: [August 17, 2016, 4:58pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/19 "2016-08-17T16:58:40Z")

</div>

Hello Apurva.

That is exactly correct! Keep in mind as well that the first and last addresses in the range are the network and broadcast addresses respectively so you will have 126 addresses available for hosts.

I hope this has been helpful!

Laz

---

<div class="post-metadata">

### Author: ![gersonordena](https://cdn-forum.networklessons.com/letter_avatar_proxy/v4/letter/g/3be4f8/32.png) [@gersonordena](https://forum.networklessons.com/u/gersonordena)
#### Post date: [September 4, 2016, 3:26pm UTC](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219/20 "2016-09-04T15:26:05Z")

</div>

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!

"  
255.255.255.0 /24 – 256 addresses  
255.255.255.128 /25 – 128 addresses  
255.255.255.192 /26 – 64 addresses  
255.255.255.224 /27 – 32 addresses

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:

255.255.240.0 /21 – 2048 addresses  
255.255.248.0 /22 – 1024 addresses  
255.255.254.0 /23 – 512 addresses  
255.255.255.0 /24 – 256 addresses"

Thanks!

[Next page](https://forum.networklessons.com/t/variable-length-subnet-mask-vlsm/1219.md?page=2)
