Variable Length Subnet Masking (VLSM) allows a single IP address block to be divided into subnets of different sizes, allocating addresses efficiently based on each network's actual host requirements. This example walks through subnetting a Class C address across five networks with varying host counts.
VLSM Example
Let's go over an example of VLSM and talk through the steps of how to do variable length subnet masking.
In this example we're going to be working with a Class C address. I know it's a Class C because it's the 192, so that is a Class C, which is a /24 by default, so we have a 255.255.255.0 default subnet mask.
I'm going to be subnetting this, but I'm going to do variable length subnet masking. I have five networks that I need to plan for. The first one has 102 hosts in it. The second one has 60 hosts in it. And then I have three networks that have just two hosts, which is actually not uncommon, because if you have a router with just the link, then often you would have a need for just two different IP addresses there.
So how are we going to subnet this? First of all, we require 102 addresses for this first network, so if I were to go through and find how many we need, it would be this network right here. We borrow one bit for this.
So the first network is, we're going to divide and put the line right here — that's where the line is going to be. I'm going to say that this is going to start with 0, so I'm going to put a 0 in there. Now the first network address of this is going to be all zeros, so I can put that in there: the network address for this is .0. Then I can do all ones for this, which, if I were to add that up, 64 plus 32 plus 16 plus 8 plus 4 plus 2 plus 1, is .127, and that's the broadcast address for that. So the usable host range for that is going to be anywhere from .1 through .126. That's the usable range.
We've used up that whole range, so no other addresses can have a zero at the beginning of this, because we've used up all of the addresses there.
So the next address has to start with a one. If you have multiple networks like this, usually it's easiest to start with the largest network first, so that's why we're starting with this 102. Now we're going down to the 60.
Let's see what that looks like. I'll remove some of my marks here and we're going to do it all over again. For this we need 60 addresses, so I'll go up to where we can fit 60 in there, which is right there, so this is where I'm going to draw the line. I'm going to call this a one zero for the network, because that would be the next logical step there.
If I had all zeros for the host bits, then I would have .128 right there. If I had all ones for the host bits — so switch these all to ones here — I'd add up 128 plus 32, 16, 8, 4, 2 and 1, and that would come up with 191. So my usable range for that is 129 through .190.
I'm going to delete some of my markings here. The next thing we need to do is for these little twos right here, which we can meet with drawing a line right here.
I've already used up all of the zeros here — I've used up the whole range right here. I have used up the range of all of the one zero, so this took up that whole range there. So the next one has to be one one; I don't have any other options.
I've got one one, and I'm going to add zeros across here, and that's my first network. So for the network address I'll put two zeros here: the next address is .192. If I were to change these to ones — so I'm going to switch these out and put ones there — then it's 192 plus 2 is 194, plus one is 195. So my usable range here is .193 to .194, just two addresses, which is what I was planning for. There is that next network, that's my third network.
Next, what I need to do is add one to this binary number to come up with that right there, so this next network is .196. If I were to put ones in here, then that would be .199, is what the total adds up to there. So my usable address range is 197 through .198.
I've got that now taken care of. Now my next network address that I can use is one one zero zero one zero. If I were to put 0 0 in here, this would equate to .200, and then the last of this range, I'm going to put ones in here, would be .203. So my usable range is .201 to .202, just two addresses.
There you have it — now I've met all of the needs using variable length subnet masks. Notice that now it all makes sense from a sequence standpoint. I've got from .0 through .127, and then I've got 128 through 191, 192 through 195, 196 through 199, and 200 to .203. So all those ranges make sense. There's nothing that's overlapping. I wouldn't want anything to overlap here; I can't have the same IP address in two different spots, so that wouldn't make sense. Nothing is overlapping and everything works out.
So that is the answer to this problem right here, and we just variable length subnet masked this network right here.
TechKnowSurge builds IT and cybersecurity professionals through hands-on, concept-first training built around real understanding — not memorization. Free interactive tools, structured programs, and 25+ years of real-world experience, all in one place.
Explore free tools and programs →