Networking

IPv4 VLSM tutorial

Variable Length Subnet Masking (VLSM) lets you divide a parent network into subnets of different sizes rather than carving it into equal pieces. Each subnet gets exactly the size it needs, which drastically reduces wasted address space in real networks and is a common topic on networking certifications.

Fixed subnetting vs. VLSM

With fixed-length subnetting every subnet drawn from a parent block uses the same prefix length, so every subnet is the same size. This is simple but wasteful: a /27 assigned to a LAN that only needs 5 hosts wastes 25 addresses.

With VLSM, each of those LANs can get its own appropriately-sized subnet. A 5-host LAN gets a /29 (6 usable addresses), a 25-host LAN gets a /27 (30 usable), and a 50-host LAN gets a /26 (62 usable) — all living inside the same parent block with minimal gaps.

VLSM is standard practice in modern networks and is tested heavily on CompTIA Network+ and CCNA exams.

The VLSM workflow

  1. List every LAN and its host requirement.
  2. Sort largest to smallest by host count.
  3. Size each subnet: find the smallest prefix whose usable count is ≥ the requirement. Remember to add 2 for network and broadcast.
  4. Assign sequentially: place the first subnet at the start of the parent block. Each subsequent subnet starts immediately after the previous one ends.
  5. Verify boundaries: confirm each network address is a valid multiple of its block size.

Sizing reference: hosts needed → correct prefix

The key step in VLSM is picking the smallest subnet that still fits the host requirement. Usable hosts = total addresses − 2 (network + broadcast). Use this table to select the right prefix quickly.

Hosts needed Min. total addresses Prefix to use Usable hosts Block size
1–2 4 /30 2 4
3–6 8 /29 6 8
7–14 16 /28 14 16
15–30 32 /27 30 32
31–62 64 /26 62 64
63–126 128 /25 126 128
127–254 256 /24 254 256

A common exam trap: a LAN that needs exactly 30 hosts requires a /27 (30 usable), but a LAN that needs 31 hosts cannot use /27 — it must use /26 (62 usable).

Advertisement

Worked example — three LANs in a /24

Parent block: 10.10.50.0/24. LAN requirements: 60 hosts, 28 hosts, 12 hosts.

Step 1 — sort largest to smallest

60 hosts → 28 hosts → 12 hosts

Step 2 — size each subnet

  • 60 hosts → need at least 62 usable → /26 (block 64, usable 62)
  • 28 hosts → need at least 30 usable → /27 (block 32, usable 30)
  • 12 hosts → need at least 14 usable → /28 (block 16, usable 14)

Step 3 — assign sequentially

LAN Hosts Prefix Network address Broadcast Usable range
LAN A 60 /26 10.10.50.0 10.10.50.63 10.10.50.1 – .62
LAN B 28 /27 10.10.50.64 10.10.50.95 10.10.50.65 – .94
LAN C 12 /28 10.10.50.96 10.10.50.111 10.10.50.97 – .110

After all three LANs, the next free address is 10.10.50.112 — the remaining /24 space is available for future growth.

Second example — four LANs with a tight fit

Parent block: 172.16.20.0/24. Requirements: 100 hosts, 50 hosts, 20 hosts, 5 hosts.

LAN Hosts Prefix Network address Broadcast
LAN A 100 /25 172.16.20.0 172.16.20.127
LAN B 50 /26 172.16.20.128 172.16.20.191
LAN C 20 /27 172.16.20.192 172.16.20.223
LAN D 5 /29 172.16.20.224 172.16.20.231

Note that LAN B (50 hosts) needs a /26 — a /27 only gives 30 usable addresses, which is not enough. LAN D skips /28 and uses /29 because 5 hosts fits in 6 usable slots, and /29 is the smallest prefix that works.

Refreshable sample

Try one VLSM allocation question

Need a full set?

Use this sample to practice matching LAN host requirements to the correct prefix and network address inside a /24 parent block.

Advertisement

Common mistakes and what to watch for

  • Forgetting network and broadcast. A LAN needing 30 hosts requires at least 32 total addresses, not 30. Always add 2 before looking up the prefix.
  • Allocating smallest first. Small subnets placed first can misalign the boundaries needed by larger subnets that follow. Always sort largest to smallest.
  • Invalid boundary. A /26 subnet must start at a multiple of 64 in its octet: 0, 64, 128, or 192. Assigning it to 10.0.0.32 is invalid because 32 is not a multiple of 64.
  • Overlapping subnets. After assigning each subnet, the next free address is the one immediately after the broadcast. Use that as the starting point for the next subnet.
  • Choosing one prefix size too large. Picking /26 for a 62-host LAN is correct. Picking /25 wastes 64 addresses unnecessarily. Always choose the smallest prefix that fits.
Open IPv4 VLSM practice