tip
~/geeksubnet/guides/vlsm

VLSM explained: design a real addressing plan

From requirements to a non-overlapping plan. Check the result in the VLSM solver.

Variable Length Subnet Masking (VLSM) is just subnetting where the pieces are different sizes. It matters because real networks are lopsided: a user VLAN might need 500 addresses while a router-to-router link needs two. Giving both a /24 wastes a thousand addresses. This guide treats VLSM as a repeatable design process and works a full example end to end.

Why fixed-size subnets waste space

Suppose you carve 10.0.0.0/24 into eight equal /27 subnets (30 hosts each). A point-to-point link between two routers uses 2 of those 30 addresses; the other 28 are stranded — you cannot lend them to the busy user segment next door, because they belong to a different subnet. Multiply that across dozens of links and you run out of space in a block that is mostly empty. VLSM fixes this by sizing each subnet to its actual need.

The algorithm: largest first

There is one rule that makes VLSM work without overlaps: allocate the largest subnet first, then the next largest, and so on. Each subnet is placed at the next free, correctly aligned boundary. Sorting largest-to-smallest guarantees alignment falls into place naturally; doing it in the wrong order leaves awkward gaps.

  1. List every segment with its required usable host count.
  2. For each, find the smallest prefix that fits: round the requirement (plus 2 for network and broadcast) up to the next power of two.
  3. Sort the list from largest block to smallest.
  4. Assign blocks in order, each starting where the previous one ended.

The VLSM formula: hosts to prefix

The only calculation in VLSM is turning a host count into a prefix. A subnet with n host bits has 2n addresses, two of which (network and broadcast) cannot be given to hosts. So you need the smallest n where 2n − 2 ≥ hosts, and the prefix is 32 − n:

prefix = 32 − ceil( log2(hosts + 2) )

hosts = 50  →  50 + 2 = 52  →  next power of two 64 = 2^6  →  /26

Nobody does the logarithm in an exam. Memorise this table instead:

Hosts needed (up to)PrefixMaskBlock size
2/30255.255.255.2524
6/29255.255.255.2488
14/28255.255.255.24016
30/27255.255.255.22432
62/26255.255.255.19264
126/25255.255.255.128128
254/24255.255.255.0256
510/23255.255.254.0512
1,022/22255.255.252.01,024
2,046/21255.255.248.02,048
4,094/20255.255.240.04,096

Find the first row whose host count is at least your requirement. A segment that needs 31 hosts does not fit a /27 (30 usable), so it gets a /26. The hosts to prefix tool does the lookup for any count.

Worked example 1: five segments in a /22

You are given 172.16.0.0/22 (1,024 addresses) and these requirements:

SegmentHosts neededSmallest prefixBlock size
Office LAN400/23512
Wi-Fi200/24256
Servers60/2664
Management20/2732
Router link2/304

A 400-host segment needs 402 addresses including network and broadcast; the next power of two is 512, a /23. Wi-Fi's 200 rounds up to 256, a /24. Now allocate largest first, starting at 172.16.0.0:

Office LAN  /23   172.16.0.0    →  172.16.1.255    (510 usable)
Wi-Fi       /24   172.16.2.0    →  172.16.2.255    (254 usable)
Servers     /26   172.16.3.0    →  172.16.3.63     ( 62 usable)
Management  /27   172.16.3.64   →  172.16.3.95     ( 30 usable)
Router link /30   172.16.3.96   →  172.16.3.99     (  2 usable)

Each block begins exactly where the last one ended, and each start address is a multiple of its own block size — that is what "aligned" means. Total consumed: 512 + 256 + 64 + 32 + 4 = 868 addresses out of 1,024, leaving 172.16.3.100 through 172.16.3.255 (156 addresses) free for growth. Efficiency: about 85%.

Always size to the realistic maximum, not today's count. A segment with 60 servers that grows past 62 forces a painful renumber. If you expect growth, give Servers a /25 (126 usable) now — VLSM is about deliberate sizing, not squeezing every address.

Worked example 2: six segments in a /24

This is the shape of most exam and lab questions. You are given 192.168.1.0/24 and asked to address two LANs, a guest network, a printer VLAN and two router-to-router links:

SegmentHosts neededPrefixMask
Sales100/25255.255.255.128
Engineering50/26255.255.255.192
Guest Wi-Fi25/27255.255.255.224
Printers10/28255.255.255.240
WAN link A2/30255.255.255.252
WAN link B2/30255.255.255.252

The list is already sorted largest first, so allocate from 192.168.1.0 and let each block start where the last one ended:

Segment      Network            First host      Last host       Broadcast
Sales        192.168.1.0/25     192.168.1.1     192.168.1.126   192.168.1.127
Engineering  192.168.1.128/26   192.168.1.129   192.168.1.190   192.168.1.191
Guest Wi-Fi  192.168.1.192/27   192.168.1.193   192.168.1.222   192.168.1.223
Printers     192.168.1.224/28   192.168.1.225   192.168.1.238   192.168.1.239
WAN link A   192.168.1.240/30   192.168.1.241   192.168.1.242   192.168.1.243
WAN link B   192.168.1.244/30   192.168.1.245   192.168.1.246   192.168.1.247

Used: 128 + 64 + 32 + 16 + 4 + 4 = 248 of 256 addresses. 192.168.1.248/29 is left over, enough for one more small segment or two more /30 links. With fixed-size subnets the same job would need six /25s, three times the whole /24.

Verifying the plan

Two checks catch almost every mistake. First, no overlap: each subnet's broadcast address must be lower than the next subnet's network address. Second, alignment: each network address modulo its block size must be zero (e.g. a /26's network must be a multiple of 64). The VLSM solver enforces both and shows the allocation efficiency; the subnet splitter handles the simpler case where every segment is the same size.

How to tell whether VLSM subnets overlap

A favourite exam question gives you a list of subnets and asks which ones overlap. Turn each one into a range (network address to broadcast address) and compare the ranges. Take these four:

10.1.1.0/26    →  10.1.1.0   to 10.1.1.63
10.1.1.64/27   →  10.1.1.64  to 10.1.1.95
10.1.1.96/28   →  10.1.1.96  to 10.1.1.111
10.1.1.48/28   →  10.1.1.48  to 10.1.1.63    ← inside 10.1.1.0/26

10.1.1.48/28 overlaps, because its whole range sits inside the /26. The quick way to spot it: a /26 covers 64 addresses from its network address, so any other subnet starting between .0 and .63 collides with it. The membership checker answers "is this address inside that subnet?" for any pair.

Common mistakes

VLSM vs FLSM

FLSM (fixed length)VLSM (variable length)
Masksone mask for every subneta mask sized to each subnet
Address usewasteful on small segmentsclose to what each segment needs
Planningdivide by a power of two and you are donesort, size and align each block
Routing protocolworks even with classful ones (RIPv1)needs a classless one (OSPF, EIGRP, RIPv2...)

FLSM is the right tool when every segment really is the same size, and the subnet splitter does it in one step. As soon as sizes differ, VLSM wins.

Which routing protocols support VLSM

A VLSM plan only works if the routers can tell a /26 from a /27, so the routing protocol has to send the prefix length with every route. Protocols that do are called classless:

On older Cisco IOS releases RIPv2 and EIGRP summarise routes at the classful boundary by default. If your VLSM subnets of one major network are split across different parts of the topology, add no auto-summary under the routing process, or routers will advertise one summary route for subnets they cannot all reach.

Doing a VLSM lab in Packet Tracer

Lab exercises such as "design and implement a VLSM addressing scheme" follow the same three steps whatever the topology.

  1. Plan on paper first. Build the table from the worked examples above: segment, hosts, prefix, network, first and last host, broadcast. Every later step reads from it.
  2. Give each router interface the first usable address of its subnet, because that is what the hosts will use as their default gateway. For the Sales LAN above:
    Router(config)# interface g0/0
    Router(config-if)# ip address 192.168.1.1 255.255.255.128
    Router(config-if)# no shutdown
    On a /30 router-to-router link, one end takes .241 and the other .242.
  3. Configure the hosts and verify. Each PC gets an address from its range, the same mask as the router interface, and the router's address as gateway. Then check with show ip interface brief (every interface up with the right address), show ip route (each connected route with its own prefix length) and a ping from every PC to its gateway.

Most lab mistakes are a mask typed on the router that does not match the plan. The VLSM solver prints the whole table for any set of requirements, so you can check your paper version before you start typing.

VLSM and IPv6

IPv6 does not need VLSM to save addresses. Every LAN is a /64 however many hosts it has, router-to-router links can use a /127 (RFC 6164) and loopbacks a /128. Planning still happens, but it is about hierarchy: a site gets a /48, each building a /56 or /60, each VLAN a /64, ideally on 4-bit boundaries so prefixes stay readable in hex. The IPv6 guide covers the notation.

Frequently asked questions

What is VLSM in networking?

VLSM (Variable Length Subnet Masking) is subnetting one address block into subnets of different sizes, each with its own mask, so every segment gets roughly the number of addresses it needs instead of one fixed size for all.

How do you calculate VLSM?

For each segment add 2 to the required hosts and round up to the next power of two; that block size gives the prefix (32 minus the number of host bits). Sort the segments from largest to smallest and assign each block at the next free address, which is then automatically aligned.

What is the difference between VLSM and FLSM?

FLSM (Fixed Length Subnet Masking) uses the same mask for every subnet, which is simple but wastes addresses on small segments. VLSM uses a different mask per subnet, which saves space but needs planning and a classless routing protocol.

What is the difference between VLSM and CIDR?

VLSM is about dividing a block you own into subnets of different sizes. CIDR is the classless addressing scheme behind it, used to allocate and aggregate blocks of any prefix length, for example summarising several routes into one shorter prefix. VLSM goes down from a block, CIDR summarisation goes up.

Does OSPF support VLSM?

Yes. OSPF is a classless routing protocol: it carries the prefix length with every route, so subnets of different sizes are advertised correctly. RIPv2, EIGRP, IS-IS and BGP support VLSM too; RIPv1 and IGRP do not.

Why do you allocate the largest subnet first?

Every block must start at a multiple of its own size. Placing the largest blocks first means each smaller block lands on a boundary that is already aligned, so the plan has no gaps and no overlaps.

Open the VLSM solver → ← Subnetting basics Next: IPv6 → All guides