Kahibaro
Discord Login Register

7.7 VLSM

Introduction

Variable Length Subnet Masking, usually called VLSM, is a method of subnetting where you do not use a single fixed subnet size for an entire network. Instead, you create subnets of different sizes using different subnet masks, and you assign each subnet a size that matches the number of hosts it actually needs.

VLSM builds directly on your understanding of subnet masks, CIDR notation, and basic subnetting. The key idea is that VLSM lets you use your address space much more efficiently than simple, fixed size subnetting.

Fixed Length vs Variable Length

In traditional, fixed length subnetting, you pick one subnet mask for a whole network block and every subnet created from that block is the same size. If you choose a /26 mask for a /24 network, you always get subnets with 62 usable host addresses, even if some locations need only 10 hosts and others need 50.

With VLSM you are allowed to apply different subnet masks inside the same original block. One subnet might be /26, another /27, another /30, and so on. All of them still come from the same larger network, but they do not all have the same size.

Key statement: Fixed length subnetting uses one mask for all subnets. VLSM uses different masks inside the same address block to create different sized subnets.

Why VLSM Exists

VLSM solves a simple problem: wasting addresses. If you always use a single fixed mask, you often assign many more addresses than needed to small networks. Those addresses cannot be used anywhere else, so they are wasted.

VLSM lets you match subnet sizes to real requirements. A point to point link might need only 2 usable IPs, a small branch might need 14, and a main office might need 100. VLSM makes it possible to design subnets that fit each case, instead of forcing everything into one size.

This is especially important with IPv4 and limited address space. VLSM is one of the key tools for efficient IPv4 address planning.

Relationship with CIDR

CIDR is the idea of writing network prefixes as /length, for example /24, /27, and so on. You already use CIDR notation for both subnet masks and prefixes.

VLSM uses CIDR prefixes to split and re split networks into smaller parts. When you perform VLSM, you repeatedly take a network prefix and divide it into longer prefixes, such as splitting a /24 into two /25 networks, then splitting one of those /25 networks again into /26 networks.

You can think of VLSM as the practical use of CIDR for internal subnet planning. You start with a base prefix that has been allocated to you, and you subdivide it by choosing longer and longer prefix lengths where necessary.

Core VLSM Strategy

The most common approach to VLSM uses a simple rule: list your subnet requirements and then work from largest to smallest. This keeps the address space contiguous and prevents overlap.

A typical sequence looks like this:

First, you write down how many hosts are required in each subnet. Always remember to include infrastructure addresses, such as routers, printers, and servers, not only user devices.

Second, you sort the required subnets from the one with the largest number of hosts to the one with the smallest number of hosts.

Third, for each requirement, you choose the smallest prefix length that can support that many hosts. This is the same host capacity logic you use in normal subnetting.

Fourth, you assign each subnet to the next available block of addresses in your original network, always staying aligned with the chosen mask.

Fifth, you check that all subnets are non overlapping and that you have not run out of addresses in your base block.

Design rule: In VLSM, always allocate largest subnets first, then move to smaller ones, and never let subnets overlap.

Finding the Prefix Length for a VLSM Subnet

VLSM uses the same formulas as ordinary subnetting to decide how many hosts a given mask can support. For IPv4, if a subnet has $h$ host bits, the number of usable hosts is:

$$\text{usable hosts} = 2^{h} - 2$$

Here $h$ is the number of bits not used by the network prefix. For example, a /26 prefix has $32 - 26 = 6$ host bits, so it can support $2^6 - 2 = 62$ usable addresses.

When you have a host requirement, you search for the smallest $h$ that satisfies

$$2^{h} - 2 \ge \text{required hosts}$$

Once you know $h$, the prefix length is

$$\text{prefix length} = 32 - h$$

VLSM mask selection rule: For each subnet, choose the smallest prefix length where $2^{(32 - \text{prefix})} - 2$ is greater than or equal to the required hosts.

Allocation Order and Address Alignment

When you choose a prefix length for a VLSM subnet, you must assign it on boundaries that match the mask. This is the same alignment principle as normal subnetting.

For example, a /26 subnet in a /24 base network will always start at an address that increases in steps of 64, because a /26 block has 64 addresses in total. So within 192.168.10.0/24, the valid /26 blocks are:

SubnetAddress rangePrefix
192.168.10.0192.168.10.0 to 192.168.10.63/26
192.168.10.64192.168.10.64 to 192.168.10.127/26
192.168.10.128192.168.10.128 to 192.168.10.191/26
192.168.10.192192.168.10.192 to 192.168.10.255/26

If, using VLSM, you decide to split 192.168.10.64/26 further into /27 networks, they must align on multiples of 32 addresses inside that block, since a /27 network has 32 addresses in total. Inside 192.168.10.64/26, the /27 networks are:

SubnetAddress rangePrefix
192.168.10.64192.168.10.64 to 192.168.10.95/27
192.168.10.96192.168.10.96 to 192.168.10.127/27

VLSM does not remove alignment rules. It simply allows multiple mask lengths as long as each subnet starts at a correct boundary for its own mask and no ranges overlap.

Worked VLSM Design Example

Assume you receive 192.168.50.0/24 and you must create subnets for these needs:

A. 60 hosts
B. 30 hosts
C. 12 hosts
D. 2 hosts

First, sort them from largest to smallest:

  1. 60 hosts
  2. 30 hosts
  3. 12 hosts
  4. 2 hosts

Second, choose the smallest prefix for each requirement.

For 60 hosts, you need:

Find $h$ such that $2^h - 2 \ge 60$.
$2^5 - 2 = 30$ which is too small.
$2^6 - 2 = 62$ which works.

So $h = 6$ and the prefix length is $32 - 6 = 26$.
This subnet will be /26, with 62 usable hosts.

For 30 hosts, you repeat:

$2^4 - 2 = 14$ too small.
$2^5 - 2 = 30$ exactly enough.

So $h = 5$, prefix length is /27.
This subnet will be /27, with 30 usable hosts.

For 12 hosts:

$2^3 - 2 = 6$ too small.
$2^4 - 2 = 14$ enough.

So $h = 4$, prefix length is /28.
This subnet will be /28, with 14 usable hosts.

For 2 hosts:

$2^1 - 2 = 0$ too small.
$2^2 - 2 = 2$ exactly enough.

So $h = 2$, prefix length is /30.
This subnet will be /30, with 2 usable hosts.

Third, assign address blocks inside 192.168.50.0/24, starting with the largest subnet.

The /24 base has 256 addresses, from 192.168.50.0 to 192.168.50.255.

Start with the /26 subnet for 60 hosts. A /26 covers 64 addresses and must start on a multiple of 64. The first possible block is:

192.168.50.0/26 which covers 192.168.50.0 to 192.168.50.63, with 62 usable addresses.

After you assign that, the next free block starts at 192.168.50.64.

Next, assign the /27 subnet for 30 hosts. A /27 covers 32 addresses and must start on a multiple of 32. The first multiple of 32 at or above 192.168.50.64 is 64 itself. So:

192.168.50.64/27 which covers 192.168.50.64 to 192.168.50.95, with 30 usable addresses.

After this, the next free address is 192.168.50.96.

Now assign the /28 subnet for 12 hosts. A /28 covers 16 addresses and starts on a multiple of 16. From 96 upward, the next multiple of 16 is 96. So:

192.168.50.96/28 which covers 192.168.50.96 to 192.168.50.111, with 14 usable addresses.

The next free address is 192.168.50.112.

Finally, assign the /30 subnet for 2 hosts. A /30 covers 4 addresses and starts on a multiple of 4. From 112 upward, 112 itself is a multiple of 4. So:

192.168.50.112/30 which covers 192.168.50.112 to 192.168.50.115, with 2 usable addresses.

When you are done, your design looks like this:

SubnetRequirementPrefixAddress rangeUsable hosts
A60 hosts/26192.168.50.0 to 192.168.50.6362
B30 hosts/27192.168.50.64 to 192.168.50.9530
C12 hosts/28192.168.50.96 to 192.168.50.11114
D2 hosts/30192.168.50.112 to 192.168.50.1152

You still have unassigned space from 192.168.50.116 up to 192.168.50.255. You can later split that remaining space into more VLSM subnets as needed, always following the alignment and non overlap rules.

VLSM and Address Utilization

You can see how VLSM improves efficiency by comparing the host requirements to the usable hosts per subnet in the example:

SubnetRequired hostsUsable hostsUnused addresses
A60622
B30300
C12142
D220

Total required hosts: 104.
Total reserved usable addresses: 108.

You only waste 4 addresses across all subnets. If instead you had chosen a single fixed mask that can handle 60 hosts, you would have had to use /26 for every subnet, so each subnet would have 62 usable hosts even when only 2 or 12 were needed. VLSM prevents that kind of waste.

Hierarchical Subnetting with VLSM

VLSM also allows you to keep subnets grouped in a logical hierarchy. You can first divide a large block into parts for different sites, then subdivide each site block again for different VLANs or departments, always using masks that match the real needs.

For example, you might start with 10.1.0.0/16 for an entire organization, then allocate 10.1.0.0/20 for one city, 10.1.16.0/20 for another city, and so on. Inside 10.1.0.0/20, you can perform another VLSM design for the local subnets. All of that is still VLSM, because each stage uses variable prefix lengths under a larger allocation.

Avoiding Overlaps and Design Errors

VLSM designs can become complex as you create more and more different sized subnets. Two mistakes are especially common:

The first mistake is overlapping subnets. If two assigned prefixes cover some of the same IP addresses, routing will become ambiguous. Always track the full range of every subnet and ensure that new allocations use only unassigned addresses.

The second mistake is fragmentation. If you assign subnets out of order without planning, you may leave small gaps that are too small to fit the larger subnets you need later. Sorting requirements from largest to smallest and assigning them in that order reduces this risk.

Many network engineers keep a table or a diagram of the address space as they work through a VLSM plan. They mark which parts are assigned and which parts are still free. This simple habit helps avoid overlaps and makes it easier to adjust the plan if requirements change.

Safety rule: In VLSM planning, always keep a clear record of used ranges and free ranges. Never assign a subnet unless you have confirmed that its entire address range is currently unassigned.

VLSM and Routing

Once you use VLSM, routers must understand and handle different prefix lengths. Modern routing protocols and devices support this, but historically some older protocols did not, which made VLSM impossible in those networks.

In a VLSM network, routers rely on the prefix length to know how large each subnet is. They do not assume that all subnets of a given major network have the same mask. This is sometimes described as classless routing behavior, which works naturally with VLSM.

The details of how routing protocols advertise these VLSM prefixes and how summarization works with them are handled at the routing level, not at the addressing level itself. From the perspective of VLSM, it is enough to know that each subnet is identified by both its network address and its prefix length, for example 192.168.50.64/27.

Summary

VLSM is the practice of using multiple subnet masks inside one address block so that each subnet is sized appropriately for its real host requirement. You pick the smallest prefix that can support each subnet, assign larger subnets first, follow alignment rules, and avoid overlaps. The result is efficient use of address space and flexible network designs that can scale as needs change.

Views: 33

Comments

Please login to add a comment.

Don't have an account? Register now!