VLSM – Part 2

In VLSM – Part 1, we looked at a quick way to do VLSM. This time, we’ll look at some more VLSM exercises, as well as examples in which VLSM won’t solve the problem. Of course, we’ll need the powers-of-two chart. In case you don’t have it memorized yet, here it is:

n = 8 7 6 5 4 3 2 1
2n = 256 128 64 32 16 8 4 2

Example 1

A HQ site is connected to 20 remote sales offices in a hub and spoke topology (using point-to-point Frame Relay subinterfaces). We’re given the address space We need to subnet to support a HQ LAN subnet of 100 hosts, 20 sales office LANs of 25 hosts each, and the 20 WAN links connecting HQ to the remote sites.

First, we find the total number of hosts, which is 100 + (20 x 25) + (20 x 2) = 640. Since we have a “/22” address space, we have ten bits to work with. Ten bits is off the chart, but if we extend the powers of two chart two more columns to the left, we see that two to the tenth is 1,024 (allowing for 1,022 hosts), so we’re good to proceed. Also, using the methods we developed in “Subnet Masking Shortcuts”, with a “/22” mask ( the subnets increment by four in the third octet, so the next subnet up would be In other words, we have the range of addresses from to available. Anything outside of that range is outside of our allowable address space.

We’ll start with the largest subnet, the HQ LAN, which requires 100 hosts (seven host bits), and therefore a “/25” mask:

  • 100 hosts =>

With a “/25” mask (seven host bits), the subnets increment by 128, so the next subnet begins at The next largest subnet, a sales LAN, contains 25 hosts, and therefore requires five host bits, or a “/27”. Thus, the next subnet is With a “/27” mask (five host bits), the subnets increment by 32, so the next subnet begins at In fact, all of the sales LANs require 25 hosts, and therefore “/27” masks. Thus, the twenty sales LANs could be:

  • (thirteen more subnets incrementing by 32 go here)

That takes care of the 21 LAN subnets (HQ and the 20 remote sites), so now let’s do the WAN links. Taking up where we left off at, with five host bits the subnets increment by 32, so the next available subnet begins at The WAN links need two hosts each, so we can use a “/30” for each (in which case they increment by four). Therefore, the twenty WAN subnets could be:

  • (4, 8 … 72, 76) /30

The next available subnet would be, but since we’ve covered all required subnets, we don’t need it at present. We could also have used “/31” masks on the WAN links, in which case they could be:

  • (2, 4 … 36, 38) /31

In this case, the address space starting at remains unused.

Example 2

Speaking of unused address space, with VLSM it’s common to have quite a bit of flexibility. For example, let’s say that given the address space, we need a HQ LAN subnet with 50 hosts, ten sales office LANs with five hosts each, and leased lines (running PPP) connecting HQ to the sales offices. In this case, the largest subnet is the HQ LAN (50 hosts), which requires six host bits, or a “/26” mask:

  • 50 hosts =>

With a “/26” mask (six host bits), the subnets increment by 64, so the next subnet begins at The next largest subnet is a sales office LAN, which contains five hosts, and there are ten of them, all requiring three host bits, or “/29” masks. Thus, the ten sales office LAN subnets could be:

  • (72, 80, 88 … 128, 136) /29

The next subnet starts at, and we still need to allocate address space for the ten WAN links. Because these are P2P links, we can use either “/30” or “/31” subnets. Let’s use “/30”, which increment by four:

  • (148, 152, 156 … 176, 180) /30

That takes care of that, with the addresses 184 and above currently unused. Now comes the “flexibility” part. Since we have quite a bit of unused address space, we could get fancy and allocate addresses below 100 for the HQ LAN, those in the range 100 to 199 for sales office LANs, and 200 and above for the WAN links, thus:

  • HQ LAN => (still allows for 62 hosts)
  • Sales LANs => (112, 120 … 168, 176) /29
  • WANs => (204, 208 … 236, 240) /30

With the scheme just outlined, the addresses in the ranges from to 103, and to 255 are unused.

If you’re going to be “elegant”, you also need to be careful. Because this is all using binary “behind the scenes”, there is a rule to be followed, and that rule is:

The starting address of a subnet must be evenly divisible by the increment for that subnet.

In other words, you can start a “/29” subnet (which increments by eight) at 104, but not at 100. Why? Because 104 is evenly divisible by eight, but 100 is not. If you’ve read my blog on “Address Summarization” (or if you’re a math genius), you may have already realized this. This is exactly why I recommend that you start with the largest subnet, and work your way down to the smallest. Why? Because:

  1. The mask must allow for the required number of hosts.
  2. The subnets must not overlap.
  3. The starting address of a subnet must be evenly divisible by the increment for that subnet.

If you start big and work down, you’ll meet all three rules (assuming that you don’t make any mistakes, that is). If you do anything else, it’s easy to mess it up.

Example 3

Just to expand a little further on the flexibility aspect, another strategy is to leave some room for growth on the HQ subnet, by using a “/25” mask (which would support up to 126 hosts). Since the next subnet available for a sales office LAN would begin at, we could do this:

  • Sales LANs => (136, 140 … 188, 196) /29

The next subnet would start at, so let’s allocate the WAN links accordingly:

  • WANs => (208, 212 … 240, 244) /30

Note that while VLSM can be quite handy in some circumstances, it isn’t magic. For example, if the total number of hosts required exceeds that supported by the address space, VLSM won’t help (more than 254 hosts on a Class “C” doesn’t compute). Also, it’s certainly possible that even if the total number of hosts will fit within the address space, the problem still can’t be solved using VLSM. Let’s look at an example …

We’ll slightly modify the first VLSM problem that we did, using the same address space, and still requiring four subnets, but with the following numbers of hosts:

  • 105 hosts
  • 50 hosts
  • 40 hosts
  • 10 hosts

The first subnet (105 hosts) is (increment of 128), the second (50 hosts) is (increment of 64), the third (40 hosts) is (increment of 64), and the fourth (10 hosts) and last subnet is

  • 105 hosts =>
  • 50 hosts =>
  • 40 hosts =>
  • 10 hosts =>

Too bad that 256 (the 192 from the third subnet, plus its increment of 64) is not a legal value for an octet (with eight bits, you can only go from zero to 255). What it comes down to is that because we were forced to waste address space on the larger subnets, we ran out of address space before we allocated it to all of the required subnets.

Having said all that, you should know that thanks to private addressing (RFC 1918) and NAT (RFC 1631), VLSM is not used as much as it used to be … but it still is used.

Well, that’s VLSM. Time to doff our beanies!

Author: Al Friebe

In this article

Join the Conversation


  1. raven Reply


    Why didn’t you use, in your first example? for remote sites (25 hosts each) ?


  2. raven Reply

    sorry typo error: it’s /27

  3. Al Friebe Reply

    You’re right! It was an oversight on my part. The blog entry has been updated and re-posted. Thanks!

    – Al

  4. Saadat Reply

    how do i fulfill the following requirement :-
    1. 120 hosts
    2. 105 hosts
    3. 100 hosts
    4. 50 hosts
    5. 25 hosts
    using any class B ip address.

  5. Al Friebe Reply

    If you mean that you have one subnet each for those numbers of hosts, for a total of five subnets, and you’re interested in conserving address space, then the masks required are:

    1. 120 hosts => /25
    2. 105 hosts => /25
    3. 100 hosts => /25
    4. 50 hosts => /26
    5. 25 hosts => /27

    Thus, on network, for example, you could use:

    1. 120 hosts =>
    2. 105 hosts =>
    3. 100 hosts =>
    4. 50 hosts =>
    5. 25 hosts =>

    Since you have a class B, and likely more address space than you need, it’s much easier to not bother with VLSM, and just use /24’s everywhere, something like this:

    1. 120 hosts =>
    2. 105 hosts =>
    3. 100 hosts =>
    4. 50 hosts =>
    5. 25 hosts =>

    That leaves plenty of room to grown on all subnets.

    – Al