Almost every real network has subnets of very different sizes: a few hundred laptops in one office, a dozen servers in another and a handful of two-address links between routers. Giving each the same size wastes addresses and sometimes makes the design impossible. VLSM is the technique that fixes that, and it is a staple of subnetting questions on Cisco CCNA and CompTIA Network+. If basic subnetting is still new to you, start with our subnetting guide and come back; this article assumes you know that a prefix length such as /26 means 26 network bits. The subnetting guide covers CIDR and general subnet maths; this page is the dedicated VLSM method, with two complete allocation tables you can follow line by line.
What is VLSM?
VLSM is the use of more than one subnet mask within the same classful or CIDR network. Plain subnetting divides a network into equal pieces; VLSM divides it into unequal pieces. Technically you take a subnet and subnet it again, and again, until every piece fits a requirement. The result is a set of non-overlapping subnets, each with the prefix length that best suits its host count, which all fit inside the address block you were given.
VLSM became practical with classless routing. Once routing protocols began to carry the subnet mask with every route, there was no longer any reason for a router to assume that every subnet of a network shares one mask. The wider system of dropping Class A/B/C boundaries is CIDR, described in RFC 4632; VLSM is how you apply it inside your own allocation.
Why use VLSM?
The reasons are practical, and exam questions test all of them:
- Address efficiency. A point-to-point link needs two addresses. Giving it a /24 (254 hosts) throws away 252. A /30 uses exactly what is needed.
- Room to grow. Addresses saved on small subnets stay in the pool for new sites and VLANs, which matters most when you are working within a private range or a small public allocation.
- Cleaner summarization. If you allocate sequentially from one block, a whole site can be advertised as a single summary route, which keeps routing tables small.
- Better fit to the design. VLANs, server segments, management networks and WAN links all have different sizes. VLSM lets the addressing plan follow the design instead of the other way round.
Private ranges are large (see our guide to private IP address ranges), so you can often afford to be generous inside a company. VLSM still matters because a clean, hierarchical plan is easier to summarize and troubleshoot, because overlapping ranges between sites cause real problems when networks merge, and because public IPv4 space is scarce. Comparing address sizes is also a good way to appreciate why IPv6 was designed with so much more room.
Prefix, mask and block size: the lookup table
Block size = 256 minus the mask value in the interesting octet. For /26 the mask value is 192, so the block size is 64. Memorize or rebuild this table; every VLSM problem uses it. Block size is the number of addresses in the subnet (2^n) and is also the step between consecutive subnet addresses in the interesting octet.
| Prefix | Subnet mask | Block size | Usable hosts (2^n - 2) |
|---|---|---|---|
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
Quick formulas to keep in your head: usable hosts = 2^n - 2 (n is the number of host bits); block size = 256 - the mask value in the interesting octet (for /26, 256 - 192 = 64); broadcast = next subnet address - 1; first usable = network + 1; last usable = broadcast - 1. To find the right prefix for a host count, find the smallest power of two that is at least hosts + 2.
How do you do VLSM step by step?
- List every subnet and its host requirement. Include router-to-router links (2 hosts each) and plan for growth if the brief says so.
- Sort from largest to smallest. This is the step that keeps blocks aligned and prevents waste.
- Choose the prefix for each. The smallest 2^n - 2 that is at least the requirement.
- Allocate in order. The first subnet starts at the first address of your block. Each next subnet starts at the address right after the previous broadcast, which is always a valid multiple of its own block size when you go largest to smallest.
- Verify. Check that no ranges overlap, that every subnet fits inside the original block, and that the sum of block sizes does not exceed the block.
Why largest first?
A subnet must begin at a multiple of its own block size. Suppose you give a /30 to 192.168.10.0 first (it uses .0 to .3). A 100-host /25 cannot start at .4; the next legal start is .128, so addresses .4 to .127 become unusable for it. Placing the /25 first at .0 and the /30 later in the leftover space wastes nothing.
Worked example 1: one /24 split six ways
Task: you are given 192.168.10.0/24. You need LAN A with 100 hosts, LAN B with 50, LAN C with 25, LAN D with 10, and two router-to-router links with 2 hosts each.
Choose prefixes. 100 hosts needs 7 host bits (2^7 - 2 = 126), so /25. 50 hosts needs 6 bits (62), so /26. 25 hosts needs 5 bits (30), so /27. 10 hosts needs 4 bits (14), so /28. A link needs 2 bits (2), so /30.
| Subnet | Hosts needed | Network / prefix | Mask | Usable range | Broadcast |
|---|---|---|---|---|---|
| LAN A | 100 | 192.168.10.0/25 | 255.255.255.128 | 192.168.10.1 - .126 | 192.168.10.127 |
| LAN B | 50 | 192.168.10.128/26 | 255.255.255.192 | 192.168.10.129 - .190 | 192.168.10.191 |
| LAN C | 25 | 192.168.10.192/27 | 255.255.255.224 | 192.168.10.193 - .222 | 192.168.10.223 |
| LAN D | 10 | 192.168.10.224/28 | 255.255.255.240 | 192.168.10.225 - .238 | 192.168.10.239 |
| Link 1 | 2 | 192.168.10.240/30 | 255.255.255.252 | 192.168.10.241 - .242 | 192.168.10.243 |
| Link 2 | 2 | 192.168.10.244/30 | 255.255.255.252 | 192.168.10.245 - .246 | 192.168.10.247 |
Verify. The blocks are 128 + 64 + 32 + 16 + 4 + 4 = 248 addresses, so the allocation ends at 192.168.10.247 and 192.168.10.248 to 192.168.10.255 (8 addresses) remains free for a future /29 or smaller. Each network address is a multiple of its block size (128, 64, 32, 16, 4, 4) and each next network equals the previous broadcast plus one, so nothing overlaps. With a single fixed mask the same job fails: six subnets need at least a /27 (8 subnets of 30 hosts), which cannot hold the 100-host LAN, while a /25 mask would give only two subnets.
Worked example 2: a larger design inside a /22
Task: you are given 172.16.0.0/22 (1,024 addresses, 172.16.0.0 to 172.16.3.255). Requirements: Sales 500 hosts, Engineering 250, HR 120, Guest Wi-Fi 60, Management 28, and three WAN links with 2 hosts each.
Choose prefixes. 500 hosts needs 9 host bits (2^9 - 2 = 510), so /23. 250 needs 8 bits (254), so /24. 120 needs 7 bits (126), so /25. 60 needs 6 bits (62), so /26. 28 needs 5 bits (30), so /27. Links use /30.
| Subnet | Hosts needed | Network / prefix | Mask | Usable range | Broadcast |
|---|---|---|---|---|---|
| Sales | 500 | 172.16.0.0/23 | 255.255.254.0 | 172.16.0.1 - 172.16.1.254 | 172.16.1.255 |
| Engineering | 250 | 172.16.2.0/24 | 255.255.255.0 | 172.16.2.1 - .254 | 172.16.2.255 |
| HR | 120 | 172.16.3.0/25 | 255.255.255.128 | 172.16.3.1 - .126 | 172.16.3.127 |
| Guest Wi-Fi | 60 | 172.16.3.128/26 | 255.255.255.192 | 172.16.3.129 - .190 | 172.16.3.191 |
| Management | 28 | 172.16.3.192/27 | 255.255.255.224 | 172.16.3.193 - .222 | 172.16.3.223 |
| WAN 1 | 2 | 172.16.3.224/30 | 255.255.255.252 | 172.16.3.225 - .226 | 172.16.3.227 |
| WAN 2 | 2 | 172.16.3.228/30 | 255.255.255.252 | 172.16.3.229 - .230 | 172.16.3.231 |
| WAN 3 | 2 | 172.16.3.232/30 | 255.255.255.252 | 172.16.3.233 - .234 | 172.16.3.235 |
Verify. The blocks total 512 + 256 + 128 + 64 + 32 + 4 + 4 + 4 = 1,004 addresses out of 1,024. The allocation ends at 172.16.3.235, so 172.16.3.236 to 172.16.3.255 (20 addresses) is free. Notice the /23 spans two third-octet values: its range is 172.16.0.1 to 172.16.1.254 and the broadcast is 172.16.1.255, which is why you work in the octet where the mask changes. Because everything sits inside 172.16.0.0/22, the whole site can be advertised to the rest of the network as one summary route.
Practice VLSM under exam conditions
The free CCNA practice mode gives you 30 questions per session, no card needed, and includes subnetting and addressing scenarios. Network+ candidates can do the same on the Network+ bank.
Check yourself
Check 1. How many usable host addresses does a /28 provide?
14. A /28 leaves 4 host bits, so 2^4 - 2 = 16 - 2 = 14.
Check 2. A LAN needs 200 hosts. What is the smallest prefix that fits it?
/24. A /25 gives only 126 usable hosts; a /24 gives 254.
Check 3. Why should you allocate the largest subnet first?
Because each subnet must start at a multiple of its own block size. Largest-first keeps big blocks aligned and lets smaller ones pack into the remainder without gaps.
VLSM vs FLSM vs CIDR: what is the difference?
| Term | What it means | Key point |
|---|---|---|
| FLSM | Fixed Length Subnet Masking: every subnet uses the same mask. | Simple, but the largest requirement sets the size of every subnet, wasting addresses. Typical of old classful designs. |
| VLSM | Variable Length Subnet Masking: different masks within one network. | Sizes subnets to need. Requires a classless routing protocol. |
| CIDR | Classless Inter-Domain Routing: prefix-length notation and no fixed Class A/B/C boundaries. | The addressing system that makes VLSM and route aggregation (supernetting) possible. See RFC 4632. |
| Summarization | Advertising several contiguous subnets as one shorter-prefix route. | Works best when VLSM allocation is sequential and hierarchical. |
A useful way to remember the relationship: CIDR is the rule that any prefix length is allowed; VLSM is you using several prefix lengths on purpose inside one block; summarization is the same idea in reverse, combining many small prefixes into a shorter one. CIDR and VLSM questions often appear in the same exam item, so do not treat the terms as interchangeable.
What are the common VLSM mistakes?
- Forgetting the -2. A /26 holds 64 addresses but only 62 are usable. Choosing a prefix by raw block size causes off-by-two failures at exact boundaries (a 62-host LAN fits a /26; a 63-host LAN does not).
- Allocating small subnets first. This misaligns later blocks and leaves holes, as the callout above showed.
- Overlapping ranges. Two subnets that share any address break routing. Always compare each new network with the previous broadcast.
- Misaligned network addresses. 192.168.10.100/26 is not a valid network address; /26 networks start at .0, .64, .128 and .192. If the address is not a multiple of the block size, it is a host address inside a subnet, not the subnet itself.
- Ignoring links. The router-to-router segments need subnets too, and on a design with many sites they add up quickly.
- Leaving no room to grow. Fitting hosts exactly is fine for an exam, but a real plan reserves headroom, often by rounding up or leaving free space after each tier.
- Using VLSM with a classful protocol. RIPv1 is classful and cannot carry variable masks. Older EIGRP and RIPv2 configurations with auto-summary enabled can also break discontiguous designs, so turn auto-summary off with
no auto-summaryon those routers.
Which routing protocols support VLSM, and what about summarization?
VLSM works when each route update includes the mask. OSPF, EIGRP, IS-IS, BGP and RIPv2 are classless and support it. RIPv1 is classful and does not; our RIP guide explains why. Static routes always carry a mask, so they work with any design.
When a router holds overlapping routes, it uses the longest prefix match: the most specific route that contains the destination wins. That is why a /30 link route beats a /24 summary for traffic to the link, and why an accidental overlap can silently steal traffic. If you design sequentially, you can also summarize cleanly. The four LAN subnets in worked example 1 (192.168.10.0/25, .128/26, .192/27 and .224/28) together cover 192.168.10.0 to 192.168.10.239, which sits inside 192.168.10.0/24, so the whole site can be advertised upstream as that single /24.
How do you check your VLSM work?
Do the arithmetic by hand until it is automatic, so you do not rely on a calculator in the exam. For real designs, double-check with a tool. Oursubnet calculator shows network, range and broadcast for any prefix, and the Python standard library does the same in a few lines:
import ipaddress
net = ipaddress.ip_network("192.168.10.128/26")
hosts = list(net.hosts())
print(net.netmask, hosts[0], hosts[-1], net.broadcast_address)
# 255.255.255.192 192.168.10.129 192.168.10.190 192.168.10.191Sanity checks that catch most errors: every network address is a multiple of its block size; each network starts exactly one address after the previous broadcast (or at a deliberate gap); and the sum of the block sizes is no larger than the parent block.
VLSM practice questions with answers
Work each out on paper before opening the answer. For a larger bank of subnetting and addressing scenarios use the CCNA practice exam or the CCNA practice questions article, and keep the CCNA cheat sheet open for the prefix table.
1. How many usable hosts are in a /27 subnet, and what is its block size?
30 usable hosts, block size 32. A /27 has 5 host bits: 2^5 = 32 addresses, minus the network and broadcast addresses leaves 30. Subnets in a /27 start at multiples of 32 (.0, .32, .64 and so on). The wrong options usually offer 32 (forgets the two reserved addresses) or 62 (that is a /26).
2. A department needs 60 hosts. Which prefix length should you assign?
/26. A /26 provides 62 usable hosts. A /27 provides only 30, which is too small, and a /25 provides 126, which wastes 64 addresses that VLSM exists to save.
3. You hold 10.0.0.0/24 and need subnets for 100, 50 and 20 hosts. What are the three subnets in the correct VLSM order?
10.0.0.0/25 (100 hosts, .0 to .127), 10.0.0.128/26 (50 hosts, .128 to .191) and 10.0.0.192/27 (20 hosts, .192 to .223). The next free address is 10.0.0.224. Largest-first is the safe habit because it always keeps blocks aligned.
4. Do 192.168.1.0/25 and 192.168.1.64/26 overlap?
Yes. 192.168.1.0/25 covers .0 to .127, and 192.168.1.64/26 covers .64 to .127, so the /26 sits entirely inside the /25. Overlapping subnets are the classic VLSM mistake and cause unpredictable routing because the more specific /26 wins for its range.
5. What is the broadcast address of 172.16.5.96/27, and what is the usable host range?
Block size is 32, so the subnet runs 172.16.5.96 to 172.16.5.127. Broadcast is 172.16.5.127 and usable hosts are 172.16.5.97 to 172.16.5.126 (30 hosts). Take the network address, add the block size, subtract 1.
6. Which prefix is best for a point-to-point link between two routers, and why can RIPv1 not carry it?
/30 (2 usable hosts) is the traditional answer; /31 is also valid on point-to-point links under RFC 3021 where the platform supports it. RIPv1 is classful and sends no subnet mask in updates, so it cannot advertise a /30 carved from a larger network. VLSM requires a classless protocol such as OSPF, EIGRP or RIPv2.
Frequently asked questions
What is VLSM in networking?
VLSM (Variable Length Subnet Masking) is the practice of dividing one IP network into subnets that use different subnet masks, so each subnet is sized to the number of hosts it actually needs. A 100-host LAN gets a /25, a 10-host LAN gets a /28 and a router-to-router link gets a /30, instead of every subnet using the same mask. It reduces wasted addresses and is supported by all classless routing protocols.
What is the difference between VLSM and CIDR?
CIDR (Classless Inter-Domain Routing, RFC 4632) abandons the old Class A, B and C boundaries and writes any network as an address plus a prefix length such as 10.4.0.0/14, which also allows many routes to be aggregated into one. VLSM is the specific technique of using several different prefix lengths inside one network you own. CIDR is the addressing system; VLSM is how you carve up an allocation under it.
What is the difference between VLSM and FLSM?
FLSM (Fixed Length Subnet Masking) gives every subnet the same mask, so every subnet has the same size even when the needs are very different. VLSM allows a different mask on each subnet. With FLSM a 100-host LAN forces a /25 (126 hosts) for every subnet, including point-to-point links that need only 2 addresses; VLSM avoids that waste.
Why do you allocate the largest subnet first in VLSM?
A subnet must start on an address that is a multiple of its own block size. Allocating the largest blocks first keeps them aligned at the start of the address space and leaves the smaller blocks to fill the remainder without gaps or overlaps. Allocating small subnets first can push a large subnet to the next aligned boundary and strand a chunk of unused addresses in between.
How do I calculate the number of hosts in a subnet?
Usable hosts = 2^n - 2, where n is the number of host bits (32 minus the prefix length). A /26 has 6 host bits, so 2^6 - 2 = 62 usable hosts. The two subtracted addresses are the network address (all host bits 0) and the broadcast address (all host bits 1). Point-to-point links may use a /31 under RFC 3021, which has two usable addresses and no broadcast.
Does VLSM work with every routing protocol?
No. VLSM needs a classless routing protocol that carries the subnet mask with each route. OSPF, EIGRP, RIPv2, IS-IS and BGP all do. RIPv1 is classful and does not send masks, so it cannot support VLSM. Static routes always include a mask and work with VLSM.
Is VLSM on the CCNA and Network+ exams?
Subnetting with variable masks is tested in the IP addressing sections of both CCNA 200-301 and CompTIA Network+ N10-009, usually as scenario questions: pick the right prefix for a host count, find the next free subnet, or spot an overlap. Check the current official exam objectives for the exact wording, as blueprints are revised.
How we wrote and checked this
CertSharp is a practice-exam provider, and we sell the CCNA practice questions linked in this guide. We wrote this article from RFC 4632, RFC 950, RFC 1918 and RFC 3021 and the exam topic pages, all linked in Sources. Every network, range and broadcast address in the worked tables was verified with a script using Python's ipaddress module, as were the totals and free ranges. Last reviewed October 2026. Cisco and CompTIA update their exam topics, so confirm scope on the official pages.
Sources and further reading
- RFC 4632: Classless Inter-domain Routing (CIDR)
- RFC 1918: Address Allocation for Private Internets
- RFC 950: Internet Standard Subnetting Procedure
- RFC 1519: CIDR, an Address Assignment and Aggregation Strategy (obsoleted by RFC 4632)
- Cisco Learning Network: CCNA 200-301 exam topics
- CompTIA Network+ certification page
Turn subnetting practice into exam points
30 free questions per session in practice mode on CCNA and Network+, no signup and no credit card. The full 500-question bank with exam mode is $11.99 lifetime per certification, or $9.99/month Pro unlocks every CertSharp certification.