Variable-Length Subnet Masks (VLSM)
Fixed-length subnetting is tidy but wasteful: every subnet is forced to the size of your largest requirement. VLSM lets each network take exactly the space it needs, then packs them back-to-back so the whole block is used. This is how real designs fit dozens of networks into one assigned range.
Why VLSM? The waste in fixed-length
Fixed-length subnetting (FLSM), covered in Lesson 6, divides a block into subnets that are all the same size. It is simple to plan and easy to document, which is why exam design questions often start there. But real networks are not all the same size. A floor with 400 users, a branch with 20 staff, and a router-to-router link with exactly two interfaces are wildly different sizes — yet a fixed-length scheme forces every one of them to take the same prefix.
Suppose you are assigned 192.168.20.0/24 and you must serve five networks of 100, 50, 20, 10, and 2 hosts. The largest requirement is 100 hosts, and the smallest prefix that fits 100 is a /25 (126 usable). Fixed-length subnetting therefore makes every network a /25. Five /25s would need 5 × 128 = 640 addresses, which does not fit inside the 256 addresses of the /24 at all. The design literally cannot be built that way.
VLSM removes the “one size fits all” constraint. Instead of a /25 everywhere, the 100-host network gets a /25, the 50-host a /26, the 20-host a /27, the 10-host a /28, and the two-host link a /30. Their sizes are 128 + 64 + 32 + 16 + 4 = 244 addresses — comfortably inside the /24, with room left over. The same address space now supports the whole design.
Two things make VLSM work. First, every larger block size is an exact multiple of every smaller one: a 64-address /26 can be tiled from 128-address /25 halves, and so on. Second, the routing protocol must be classless so that each interface can advertise its own mask. We return to that requirement in the traps section, because it is a favourite exam point.
The allocation rule: largest first
The single rule that makes VLSM reliable is this: always allocate the largest subnet first. New engineers often allocate in the order the networks appear on the requirements sheet, then discover the large subnet no longer has anywhere to sit. Here is why.
A block of a given size must start on a boundary that is a multiple of its size. A /23 (512 addresses) must begin on a multiple of 512; a /26 (64 addresses) must begin on a multiple of 64. Those are called aligned boundaries. If you first drop a small /28 into the middle of where a /23 needs to live, you have broken the large block’s alignment and it can no longer be placed. Allocating largest-first reserves the big aligned holes while they are still free, and the small subnets fill the leftover gaps afterwards.
A quick way to convert a host requirement to a prefix is the ladder 2, 6, 14, 30, 62, 126, 254, 510, which corresponds to /30, /29, /28, /27, /26, /25, /24, /23. Read it left to right: if a network needs 50 usable hosts, the first value at least 50 is 62, so the prefix is /26. If it needs 400, the first value at least 400 is 510, so the prefix is /23. This ladder is built from 2h − 2 for each host-bit count.
Worked example: VLSM inside a /22
A campus is assigned 172.16.4.0/22. That block contains 210 = 1024 addresses (1022 usable). The design requirements are below. Follow the method: sort largest-first, convert to prefixes, then allocate from the start of the block.
| Network | Hosts needed | Smallest prefix | Usable |
|---|---|---|---|
| Engineering | 400 | /23 | 510 |
| Sales | 200 | /24 | 254 |
| HR | 100 | /25 | 126 |
| Guest Wi-Fi | 50 | /26 | 62 |
| Management | 20 | /27 | 30 |
| WAN link A | 2 | /30 | 2 |
| WAN link B | 2 | /30 | 2 |
Convert each requirement. For 400 hosts, 29 − 2 = 510 is the first count that fits, so 9 host bits remain and the prefix is 32 − 9 = /23. For 200, 28 − 2 = 254 gives a /24. The rest follow the ladder: /25, /26, /27, and /30 for each two-host router link.
Now allocate from 172.16.4.0, largest first, respecting each block’s alignment:
- Engineering /23 must start on an even third octet.
172.16.4.0/23covers172.16.4.0 – 172.16.5.255. - Next free is
172.16.6.0. Sales /24 takes172.16.6.0/24. - Next free is
172.16.7.0. HR /25 takes172.16.7.0/25(0 is a multiple of 128). - Next free is
172.16.7.128. Guest /26 takes172.16.7.128/26. - Next free is
172.16.7.192. Management /27 takes172.16.7.192/27. - Next free is
172.16.7.224. WAN A /30 takes172.16.7.224/30; WAN B /30 takes172.16.7.228/30. - Next free is
172.16.7.232, leaving.232 – .255(24 addresses) spare for growth.
| Network | Prefix | Subnet | Usable range | Broadcast |
|---|---|---|---|---|
| Engineering | /23 | 172.16.4.0/23 | .4.1 – .5.254 | 172.16.5.255 |
| Sales | /24 | 172.16.6.0/24 | .6.1 – .6.254 | 172.16.6.255 |
| HR | /25 | 172.16.7.0/25 | .7.1 – .7.126 | 172.16.7.127 |
| Guest Wi-Fi | /26 | 172.16.7.128/26 | .7.129 – .7.190 | 172.16.7.191 |
| Management | /27 | 172.16.7.192/27 | .7.193 – .7.222 | 172.16.7.223 |
| WAN link A | /30 | 172.16.7.224/30 | .7.225 – .7.226 | 172.16.7.227 |
| WAN link B | /30 | 172.16.7.228/30 | .7.229 – .7.230 | 172.16.7.231 |
| Spare | — | 172.16.7.232/29 + .240/28 | .7.232 – .7.255 | — |
Check the arithmetic: 512 + 256 + 128 + 64 + 32 + 4 + 4 = 1000 addresses used, and 1024 − 1000 = 24 left over. The first ten bits of every subnet match the parent 172.16.4.0/22, so no subnet strays outside the assigned block.
Where does that boundary fall? A /22 uses 16 bits for the first two octets, six bits of the third octet, and two bits of the fourth — so 8 + 2 = 10 host bits in total, giving 210 = 1024 addresses (1022 usable). In the third octet the parent runs 4, 5, 6, 7, which is why Engineering and Sales each start on an even third octet and the last five subnets all live inside 172.16.7.0.
A second walkthrough: VLSM inside a /24
The same method works from any parent. Take 192.168.5.0/24 and four requirements: 120 hosts, 60 hosts, 30 hosts, and one router link of 2 hosts.
- 120 hosts:
27 − 2 = 126fits → /25 (128 addresses). - 60 hosts:
26 − 2 = 62fits → /26 (64 addresses). - 30 hosts:
25 − 2 = 30fits exactly → /27 (32 addresses). - 2 hosts:
22 − 2 = 2→ /30 (4 addresses).
| Purpose | Need | Prefix | Subnet | Usable | Broadcast |
|---|---|---|---|---|---|
| LAN A | 120 | /25 | 192.168.5.0/25 | .1 – .126 | .127 |
| LAN B | 60 | /26 | 192.168.5.128/26 | .129 – .190 | .191 |
| LAN C | 30 | /27 | 192.168.5.192/27 | .193 – .222 | .223 |
| WAN link | 2 | /30 | 192.168.5.224/30 | .225 – .226 | .227 |
| Spare | — | — | 192.168.5.228 onwards | .228 – .255 | — |
Every boundary is aligned: 0 is a multiple of 128, 128 of 64, 192 of 32, and 224 of 4. The used space is 128 + 64 + 32 + 4 = 228 addresses, leaving 28 free. A fixed-length scheme here would have had to make every LAN a /25, which fits only two of the three LANs plus the WAN — another design that the wasteful approach cannot build.
Route summarisation and aggregation
VLSM and summarisation are two halves of the same idea. Once a whole design lives inside a parent block, a router does not need to advertise every subnet separately. Route summarisation (also called route aggregation or supernetting) advertises many contiguous subnets as a single, shorter-prefix route. That shrinks routing tables, hides internal topology changes from the rest of the network, and speeds convergence.
The method is to find the longest common prefix. Write the candidate networks in binary, count how many leading bits they all share, and that count is the summary prefix length. The summary address keeps those shared bits and zeroes everything after them.
| Subnets to advertise | Common prefix | Summary route |
|---|---|---|
| 192.168.0.0/24 + 192.168.1.0/24 | 23 bits | 192.168.0.0/23 |
| 192.168.0.0/24 – 192.168.3.0/24 (four /24s) | 22 bits | 192.168.0.0/22 |
| 192.168.4.0/24 – 192.168.7.0/24 (four /24s) | 22 bits | 192.168.4.0/22 |
There is a shortcut worth memorising: to summarise N contiguous, aligned blocks of the same size, subtract log2(N) from the original prefix length. Four /24s become a /24 − 2 = /22. Eight /24s become a /21. Two /25s become a /24. The blocks must be contiguous and start on the correct boundary, or the arithmetic lies.
In the /22 worked example, every subnet — Engineering, Sales, HR, Guest, Management, and both WAN links — sits inside 172.16.4.0/22. A single summary route for 172.16.4.0/22 therefore represents the entire campus, and one static route or one OSPF/EIGRP advertisement can send all that traffic toward the site:
! One route covers every VLSM subnet of the campus block R1(config)# ip route 172.16.4.0 255.255.252.0 172.16.7.1
Summarisation is the practical reason to keep a VLSM design contiguous inside its parent: if the subnets are scattered across unrelated blocks, no single summary route can cover them.
Design checklist and common traps
Use this checklist every time you are asked to design subnets from a required host count:
- List every requirement and sort it descending by host count.
- Convert each host count to its smallest fitting prefix using the ladder 2, 6, 14, 30, 62, 126, 254, 510.
- Starting at the parent network address, allocate largest-first, checking that each block begins on an aligned boundary.
- Write down each subnet’s network, first usable, last usable, and broadcast.
- Summarise the parent block so the rest of the network sees one route.
network + size of one subnet equals the network of the next, with no shared addresses.| Protocol | Carries the subnet mask? | Can it advertise VLSM and a summary route? |
|---|---|---|
| RIPv1 | No — classful | No |
| RIPv2 | Yes | Yes |
| EIGRP | Yes | Yes |
| OSPF | Yes | Yes |
| BGP | Yes | Yes |
Two more numbers are worth locking in. A /30 is the traditional point-to-point link mask: it holds 4 addresses and 2 usable hosts, one per router interface. RFC 3021 allows a /31 on a point-to-point link, giving 2 usable addresses with no network or broadcast reserved, but classic CCNA designs still show /30. And a /32 is a single host route, used for loopbacks and host-specific entries.
Key terms
VLSM
Variable-Length Subnet Masking; using different masks on different subnets of one parent block.
FLSM
Fixed-Length Subnet Masking; dividing a block into equal-sized subnets.
Largest-first allocation
Reserving the biggest blocks before the smaller ones so each lands on an aligned boundary.
Aligned boundary
A network address that is a multiple of its block size; required for a valid subnet.
Route summarisation
Advertising many contiguous subnets as one shorter-prefix (supernet) route.
Summary route
The single route whose prefix is the longest common prefix of the subnets it represents.
Classless protocol
A routing protocol that carries a subnet mask in its updates (RIPv2, EIGRP, OSPF, BGP).
Point-to-point link
A two-router connection, traditionally a /30 (2 usable hosts) or a /31 under RFC 3021.
Review
Check what you have learned with these review questions.
Sources & references
- Fuller, V. & Li, T. RFC 4632: Classless Inter-Domain Routing (CIDR) (2006) (prefix aggregation and summarisation). rfc-editor.org/rfc/rfc4632.
- Pummill, R. & Manning, B. RFC 1878: Variable Length Subnet Table For IPv4 (1995) (the canonical VLSM host-count table). rfc-editor.org/rfc/rfc1878.
- Rekhter, Y. et al. RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links (2000). rfc-editor.org/rfc/rfc3021.
- Cisco. CCNA (200-301) Exam Topics, Network Fundamentals — IPv4 Addressing, VLSM, and route summarisation. cisco.com.
Target exams: CCNA 200-301 v1.1 · CyberOps Associate 200-201. Last content verification: 2026-10-11.