VLSM Explained: Worked Examples for the CCNA Exam

VLSM (Variable Length Subnet Masking) is the subnetting topic candidates dread — carving one address block into right-sized subnets with minimum waste. Below: what it is, the largest-first rule, a full four-network worked example, a second trickier example, the exam traps to avoid, and five practice questions with click-to-reveal answers.

Quick answer: VLSM (Variable Length Subnet Masking) lets you carve one IP network into subnets of different sizes, so each subnet's mask matches its host count — a /26 for 50 hosts, a /30 for a point-to-point link. The exam rule is largest-first: allocate the biggest subnet before the smaller ones, or you strand address space.

What VLSM actually is

With FLSM (Fixed Length Subnet Masking), every subnet carved out of a network uses the same mask. Chop 192.168.10.0/24 into /26s and you get four equal 62-host subnets. Simple — but look at the waste: a point-to-point link between two routers that needs just 2 addresses gets a 62-host subnet, and 60 addresses sit unused forever. Give that same /26 to a department of 50 hosts and it's a perfect fit. Fixed masks make some subnets perfect and others wildly wasteful.

VLSM fixes this by letting each subnet use the mask that fits its host count: a /26 for the 50-host department, a /29 (6 usable) for a 5-host team, a /30 (2 usable) for each point-to-point link. Different masks, same parent network — almost nothing wasted. That's the whole idea: right-sized subnets instead of equal-sized ones.

One catch the exam loves: VLSM only works with classless routing protocols, because the mask has to be advertised with each route. RIPv1 (and the ancient IGRP) are classful — they don't send mask information and just assume the classful mask — so they cannot support VLSM. RIPv2, EIGRP, OSPF, IS-IS and BGP all handle it. Expect a question on exactly that.

The largest-first rule (and why it matters)

VLSM questions always come with one non-negotiable ordering: allocate the largest subnet first, then work down to the smallest. Here's why. Imagine 192.168.10.0/24 with requirements of 50, 25, 10 and 5 hosts. If you place the 5-host /29 at 192.168.10.0 first, the 50-host /26 can no longer start at .0 — a /26 needs the uninterrupted range .0–.63, and you've already spent .0–.7. It has to jump to 192.168.10.64/26, and addresses .8–.63 are stranded: too small for the big subnet, broken into an awkward fragment. Allocate largest first and every subnet packs tightly with zero gaps.

The method, step by step:

  1. Sort requirements largest to smallest. 50, 25, 10, 5 — not the other way round.
  2. Pick the smallest mask that fits. For each requirement, find the first prefix where 2n − 2 (host bits n, minus network and broadcast) reaches the host count. 50 hosts needs a /26 (62 usable; a /27 gives only 30).
  3. Place it at the next free address, aligned to its block size. Subnets step in multiples of their block size (256 − the interesting mask octet), so the /26 goes at .0, the next subnet starts at .64, and so on.
  4. Repeat for the next requirement, always starting where the last subnet ended.

The block-size table you'll be reaching for constantly:

CIDRMask (last octet)Block sizeUsable hosts
/240256254
/25128128126
/261926462
/272243230
/282401614
/2924886
/3025242

Worked example 1: four departments out of 192.168.10.0/24

The classic exam question. You have 192.168.10.0/24 and four departments needing 50, 25, 10 and 5 hosts. Sort largest-first, then size and place each subnet:

DepartmentHosts neededSubnet / maskNetworkUsable rangeBroadcast
Sales50/26 255.255.255.192192.168.10.0/26.1 – .62192.168.10.63
Marketing25/27 255.255.255.224192.168.10.64/27.65 – .94192.168.10.95
Support10/28 255.255.255.240192.168.10.96/28.97 – .110192.168.10.111
Admin5/29 255.255.255.248192.168.10.112/29.113 – .118192.168.10.119

Watch the arithmetic: the /26 has block size 64, so it occupies .0–.63. The next free block starts at .64, where the /27 (block size 32) takes .64–.95. Next free: .96, where the /28 (block size 16) takes .96–.111. Next free: .112, where the /29 (block size 8) takes .112–.119. Total allocated: 64 + 32 + 16 + 8 = 120 addresses out of 256 — and 192.168.10.120–.255 remains free for future growth. Compare that with FLSM: four /26s would burn 248 addresses for the same four departments.

Now see the largest-first rule in action. If you'd placed the Admin /29 at 192.168.10.0/29 first (.0–.7), the Sales /26 couldn't start at .0 — it needs .0–.63 whole — so it would have to begin at 192.168.10.64/26, stranding .8–.63 (56 addresses) as a useless fragment. The rule exists to prevent exactly that.

Worked example 2: crossing an octet boundary

Exams like to test whether your block arithmetic survives a rollover into the next octet. Take 172.16.0.0/23 (512 addresses: 172.16.0.0–172.16.1.255) with departments needing 200, 90, 40 and 12 hosts:

Hosts neededSubnet / maskNetworkUsable rangeBroadcast
200/24 255.255.255.0172.16.0.0/24172.16.0.1 – 172.16.0.254172.16.0.255
90/25 255.255.255.128172.16.1.0/25172.16.1.1 – 172.16.1.126172.16.1.127
40/26 255.255.255.192172.16.1.128/26172.16.1.129 – 172.16.1.190172.16.1.191
12/28 255.255.255.240172.16.1.192/28172.16.1.193 – 172.16.1.206172.16.1.207

The key move is at the start: the 200-host department needs a /24 (254 usable — a /25's 126 is too small), which consumes the entire 172.16.0.x range, so the next subnet begins at 172.16.1.0. From there it's the same block-size stepping as before, and 172.16.1.208–172.16.1.255 stays free. Note that the /24's broadcast is 172.16.0.255 — that trailing .255 is just an ordinary broadcast of its own subnet, not the end of the whole /23. If you can do the rollover, you can do anything the exam throws at you.

Want to check your own allocations? Run each subnet through our free subnet calculator to verify network, broadcast and usable range before the exam — never walk in guessing.

Exam traps to avoid

Quick-fire practice questions

Five exam-style VLSM questions. Work each one out, then click to reveal the answer.

Q1. A branch office needs 60 usable host addresses. Out of 10.10.10.0/24, what is the smallest subnet that fits, and where should it start?

/26 (255.255.255.192), starting at 10.10.10.0/26. A /26 gives 62 usable addresses — a /27 only gives 30, which is too small. Start at the beginning of the range so nothing is stranded: 10.10.10.0/26, usable .1–.62, broadcast .63.

Q2. You carve 192.168.20.0/29 first for a 5-host team, then need a /26 for 50 hosts out of the same /24. What goes wrong?

The /26 can no longer start at .0. The /29 occupies .0–.7, breaking the .0–.63 range a /26 needs, so the /26 must jump to 192.168.20.64/26 — stranding addresses .8–.63 as a useless fragment. This is exactly why the largest-first rule exists.

Q3. Which two of these subnets overlap: 172.16.4.0/26, 172.16.4.64/26, 172.16.4.96/27?

172.16.4.64/26 and 172.16.4.96/27. The /26 spans .64–.127 and the /27 spans .96–.127, so the /27 sits entirely inside the /26. Overlapping subnets are never valid — 172.16.4.0/26 (.0–.63) is clean.

Q4. A point-to-point link between two routers needs 2 usable addresses. What is the most efficient mask?

/30 (255.255.255.252) — 4 total addresses, 2 usable, zero waste. A /31 (RFC 3021) also works on point-to-point links with no waste at all, but /30 is the safe exam answer unless /31 is explicitly offered.

Q5. Two subnets of 192.168.1.0/24 use different masks, and the routers run RIPv1. What breaks?

RIPv1 can't support VLSM. It's a classful protocol — it doesn't advertise subnet masks, so it assumes the classful mask and misroutes traffic between the differently-sized subnets. You need a classless protocol: RIPv2, EIGRP or OSPF.

VLSM on the CCNA 200-301 exam

VLSM questions sit in Network Fundamentals and bleed into routing and troubleshooting scenarios. The exam rewards speed: know the block sizes and usable hosts for /24–/30 cold, always allocate largest-first, and always sanity-check for overlaps and off-by-two sizing errors. Drill against the clock with our subnetting drill and subnetting practice questions, and keep our CCNA subnetting cheat sheet handy until the maths is reflex.

Can you do VLSM under exam pressure?

VLSM is one topic of six on the CCNA 200-301. Take the free 25-question mock test — no sign-up — and find out where you stand. One subscription (£5/month or £39/year) unlocks all 370 exam-style questions, 20 in-browser labs and 300 flashcards across all 10 certifications.

Start the free mock test →