Understanding the VLSM subnet planner — concept and principle
VLSM (variable-length subnet masking) means splitting one address block into subnets of different sizes, each sized to its own need, instead of cutting it into equal pieces. The planner takes a base network and a list of required host counts and returns a non-overlapping network address and prefix for each subnet. It is used when designing office, branch or lab networks where a user LAN needs 100 addresses but a router-to-router link needs only 2.
How it is calculated
- Sort the requests from largest to smallest.
- For each request h, find the smallest number of host bits b with 2^b ≥ h + 2 (two extra addresses for network and broadcast): b = ⌈log2(h + 2)⌉. The prefix is 32 − b and the block size is 2^b.
- Round the current address up to the next multiple of the block size so the subnet is aligned.
- Assign that block, then move the pointer past it and continue.
Results are labelled with the original request number (#1, #2 …) so you can match them to your list.
The principle
A subnet of size 2^b must start on an address divisible by 2^b, otherwise its mask would cut through the middle. Placing the biggest blocks first keeps every later, smaller block naturally aligned and leaves no gaps, which is why largest-first is the standard VLSM method. Using the smallest prefix that fits each request avoids wasting addresses on oversized subnets.
Worked example
- Base 10.0.0.0, requests 100, 50, 20 and 2 hosts (already in descending order).
- 100 + 2 = 102 → 2^7 = 128, so /25. Assigned 10.0.0.0/25 (10.0.0.0–10.0.0.127).
- 50 + 2 = 52 → 2^6 = 64, so /26. Next aligned start is 10.0.0.128: 10.0.0.128/26.
- 20 + 2 = 22 → 2^5 = 32, so /27 at 10.0.0.192/27.
- 2 + 2 = 4 → 2^2 = 4, so /30 at 10.0.0.224/30.
- The plan uses 10.0.0.0 to 10.0.0.227; the rest of 10.0.0.0/24 is free for growth.
How to read the result
Each line gives the network address and prefix; usable hosts are 2^(32 − prefix) − 2, so a /25 holds 126, a /26 62, a /27 30 and a /30 2. Spare capacity inside each subnet is the difference from your request. Check that the last subnet still lies inside the block you actually own.
Common mistakes
- Forgetting the 2 reserved addresses: 62 hosts fit a /26, but 63 need a /25.
- Allocating small subnets first, which creates alignment gaps and wasted space.
- Not leaving room for growth; it is often wiser to round up one size.
Frequently asked questions
Why is the largest subnet allocated first?
Large blocks have the strictest alignment; placing them first lets smaller ones fill the remaining space without gaps.
What prefix fits 30 hosts?
A /27, which provides exactly 30 usable addresses.
Should point-to-point links use /30 or /31?
Both work. /30 is universal; /31 saves addresses where both devices support RFC 3021.
Sources: IETF RFC 1878, Variable Length Subnet Table for IPv4 · IETF RFC 4632, Classless Inter-domain Routing (CIDR)