VLSM design guide
How to divide one address block into subnets of different sizes: sizing each segment from its host count, allocating the largest subnets first, and checking that nothing overlaps.
Why uniform subnets waste space
Plain subnetting divides a block into equal pieces. That is fine when your segments are the same size, but real networks are not. A typical site has a 100-device office, a 50-device lab, a 20-camera video segment and a handful of switch management addresses. Splitting a /24 into four equal /26s gives each of them 62 usable addresses: the office is short and the management segment has 52 addresses it will never use.
VLSM — Variable Length Subnet Masking — solves this by allowing a different prefix length for each subnet. The same /24 can be divided as one /25, one /26, one /27 and one /28, which fits the real requirements almost exactly and leaves a 16-address reserve. The total address count never changes; only how it is divided does.
Sizing each subnet
Every allocation starts from a host count. Convert it to a prefix in three steps: reserve the network and broadcast addresses, find the next power of two, and subtract its exponent from 32.
required addresses = hosts + 2 addresses = next power of two ≥ required prefix = 32 − log2(addresses) 50 hosts → 52 required → 64 addresses → 2^6 → 32 − 6 = /26 100 hosts → 102 required → 128 addresses → 2^7 → 32 − 7 = /25 20 hosts → 22 required → 32 addresses → 2^5 → 32 − 5 = /27
The two-address reservation is why a 30-device segment cannot use a /27: 32 addresses minus network and broadcast leaves exactly 30 usable, with no room for the segment to grow at all. In practice you should size for the device count you expect in a couple of years, not the count you have on the day you write the plan.
| Hosts needed | Addresses reserved | Addresses required | Prefix | Usable |
|---|---|---|---|---|
| 0 | 0 | 1 (host route) | /32 | 1 |
| 1 | 0 | 2 (RFC 3021) | /31 | 2 |
| 2 | 2 | 4 | /30 | 2 |
| 10 | 2 | 16 | /28 | 14 |
| 20 | 2 | 32 | /27 | 30 |
| 25 | 2 | 32 | /27 | 30 |
| 50 | 2 | 64 | /26 | 62 |
| 100 | 2 | 128 | /25 | 126 |
| 200 | 2 | 256 | /24 | 254 |
| 500 | 2 | 512 | /23 | 510 |
Requirements of zero or one are special cases. A /32 is a single host route, useful for a loopback or a management address. A /31 is a two-address point-to-point link defined by RFC 3021, which wastes nothing at all. Note how the rounding is harsh at the boundaries: 25 hosts and 20 hosts both need a /27, and 100 hosts needs a /25 because a /26 offers only 62.
Allocating largest-first
Once every requirement has a prefix, order them from largest subnet to smallest and place them at increasing offsets in the block. This is not a stylistic preference — it is what makes the plan always succeed. A subnet must start at an offset that is a multiple of its own size, so a /25 can only sit at offset 0 or 128, while a /28 can sit at any multiple of 16.
Why smallest-first fails
Take a /24 (offsets 0 to 255) with requirements of 100 hosts, 50 hosts and 50 hosts. Those are a /25, a /26 and a /26.
Place the two /26s first, at offsets 0 and 64. Each is 64 addresses, so together they consume 0 to 127. The remaining space is offsets 128 to 255 — only 128 addresses, which is exactly enough for the /25, so this particular ordering happens to work. Now try 100 hosts, 50 hosts and 20 hosts: a /25, a /26 and a /27. Place the /27 at offset 0 (0 to 31) and the /26 at offset 64 (64 to 127). The free space is now 32 to 63 and 128 to 255. The first gap is 32 addresses — too small for a /25 — and the second is the only place it fits, leaving offsets 32 to 63 stranded.
Sorting largest-first avoids this entirely: the /25 takes 0 to 127, the /26 takes 128 to 191, and the /27 takes 192 to 223. Nothing is stranded.
The reason is simple. After placing a block of size n at an aligned offset, the remaining space is a multiple of n, and every subsequent block is no larger than n, so a valid aligned offset always exists. That invariant is what the planner relies on, and it is why the allocation is deterministic.
A complete plan for 10.0.0.0/24
Here is a full worked allocation. The base block is 10.0.0.0/24 — 256 addresses from offsets 0 to 255, which is 10.0.0.0 to 10.0.0.255.
Office 100 hosts → 128 addresses → /25
Development 50 hosts → 64 addresses → /26
Camera 20 hosts → 32 addresses → /27
Management 10 hosts → 16 addresses → /28
--------------------
240 of 256 addressesSorted largest-first the order is already correct. Each subnet must start at a multiple of its own size, so the planner walks the cursor forward and aligns it before each placement.
The resulting allocation
Office 10.0.0.0/25 .0 to .127 100 hosts
Development 10.0.0.128/26 .128 to .191 50 hosts
Camera 10.0.0.192/27 .192 to .223 20 hosts
Management 10.0.0.224/28 .224 to .239 10 hosts
Free 10.0.0.240/28 .240 to .255 16 addresses
Each subnet lands exactly on its block boundary. The office /25 begins at offset 0, which is a multiple of 128. The development /26 begins at 128, a multiple of 64. The camera /27 begins at 192, a multiple of 32, and the management /28 begins at 224, a multiple of 16.
The 16 addresses from .240 to .255 are unallocated. They form a contiguous run and happen to be exactly a /28, so they can be handed to a new segment without disturbing anything already in place. That spare block is the practical benefit of sizing honestly instead of rounding everything up to a /24.
Compare what uniform subnetting would have done. Four /26s give the office only 62 usable addresses, so the 100-device requirement does not fit at all, and three of the four subnets carry 40-plus unused addresses each. VLSM fits a larger office and still finds room to spare.
Design rules worth following
- Size for growth, not for today. Round the device count up before deriving the prefix. Going from a /27 to a /26 costs 32 addresses; renumbering a production segment costs a maintenance window.
- Keep segments of similar size adjacent. Grouping the /26s together and the /28s together makes the plan easier to read and leaves larger contiguous gaps rather than scattered small ones.
- Reserve a management block deliberately. Loopbacks and switch management interfaces are easy to forget and awkward to retrofit. Carve out a /28 or /27 for them near the top of the block.
- Document the allocation before you deploy it. The plan is only useful if the next person can read it. Record the base block, each subnet, its prefix, its range and its purpose.
- Consider route summarisation. If you will advertise the block externally, keeping it contiguous means a single summary route covers every subnet. Breaking the plan across two unrelated ranges doubles the number of entries your upstream sees.
Common VLSM mistakes
- Allocating smallest-first. This is the classic error and the cause of most plans that “do not fit”. The largest subnet is the least flexible, so it must be placed first.
- Starting a subnet off its boundary. A /27 must start on a multiple of 32. 10.0.0.192/27 is valid; 10.0.0.200/27 is not, and it overlaps the .192 and .224 blocks at the same time.
- Sizing on host count instead of address count. A 30-device segment needs 32 addresses, not 30, because the network and broadcast addresses are not assignable. Deriving the prefix from 30 instead of 32 is the single most common arithmetic slip.
- Forgetting the point-to-point links. Router-to-router links are usually the last thing added and the first thing to break a tight plan. Use /31s per RFC 3021 or /30s, and count them in the requirement list from the start.
- Overlapping ranges. A subnet that overlaps its neighbour will behave unpredictably — some hosts reachable, some not, depending on which route each router installs. Always verify the plan by checking that no address appears in two subnets.
- Planning on the wrong base. Confirm the base block before dividing it. Discovering that you have a /25 rather than a /24 after allocation means redoing the whole plan.
Where to go next
Run your own requirements through the VLSM calculator — enter the base block and the host counts and it returns the aligned allocation, the leftover space and the per-subnet host ranges. The subnet calculator verifies any single subnet in detail, and the subnetting guide covers the block-size arithmetic that VLSM builds on. If any of the requirements are larger than a /24, the CIDR reference table shows exactly how many addresses each prefix provides.
Quick reference
| Prefix | Addresses | Usable hosts | Typical use |
|---|---|---|---|
| /31 | 2 | 2 (RFC 3021) | Router-to-router and switch-to-switch point-to-point links |
| /30 | 4 | 2 | Point-to-point links where RFC 3021 is not supported |
| /32 | 1 | 1 | Loopback interfaces and single management addresses |
| /28 | 16 | 14 | Small segments: management interfaces, printers, a small test rack |
| /27 | 32 | 30 | Small offices and camera segments |
| /26 | 64 | 62 | Medium segments and departmental LANs |
| /25 | 128 | 126 | Large departments and floor-level segments |
| /24 | 256 | 254 | Standard flat LAN, the default building block |
| /23–/22 | 512–1,024 | 510–1,022 | Campus LANs and large wireless pools |
| /20–/16 | 4,096–65,536 | 4,094–65,534 | Site summary blocks and hosting allocations |
Host counts are the usable figure after reserving the network and broadcast addresses, so a /27 provides 30 usable hosts from 32 addresses. The two exceptions are /31, which RFC 3021 defines as a two-host link with no reserved addresses, and /32, which is a single address with no subnet structure at all.
Frequently asked questions
What is VLSM?
Variable Length Subnet Masking means using different prefix lengths inside the same address block. Instead of splitting a /24 into four equal /26s of 62 hosts each, VLSM lets you carve out a /25 for the 100-device office, a /26 for the 50-device lab, a /27 for 20 cameras and a /28 for 10 management interfaces — all from the same /24. The block is divided into subnets of the size each segment actually needs.
Why must subnets be allocated largest-first?
Because the largest subnet needs the most strictly aligned block. A /25 must start on a multiple of 128, so it can only go at offset 0 or 128. If you allocate a /28 at offset 0 first, the only aligned /25 left is at offset 128 and the /26 and /27 that follow may no longer fit. Placing the largest block first guarantees a home for every block, because the space remaining after it is always a multiple of the next block's size.
How do I work out the prefix from a host count?
Add two to the host count for the network and broadcast addresses, then find the smallest power of two that covers the total. That power of two is the number of addresses, and the prefix is 32 minus the exponent. For 50 hosts: 52 needed, the next power of two is 64, so 2^6 = 64 and the prefix is 32 − 6 = a /26.
Why does the calculator sometimes say the plan does not fit?
Usually because the base block is too small, or because a single requirement is too large for it. Six /26s cannot fit in a /24, and a /23 requirement can never fit inside a /24. The other cause is a requirement of zero or one host, which needs a /32 and can only be placed in a block large enough to hold a single address at an aligned position.
Should I leave room for growth?
Yes, and VLSM makes it cheap. Size each subnet for the number you expect in two years rather than the number you have today, and then leave the tail of the block unallocated. In a plan that consumes 240 of 256 addresses, the free 16-address gap is a spare /28 for the next camera or test rack — you do not have to renumber anything to use it.
Does VLSM work with public addresses too?
The arithmetic is identical; only the source of the block changes. With private RFC 1918 space you can be generous because the address pool is effectively free. With a delegated public block you generally want to keep the plan tight and to keep contiguous space in reserve so you can summarise the routes you advertise to your ISP later.
What happens to the addresses the plan does not use?
They stay unallocated inside the block. They are not wasted in any meaningful sense — they cost nothing and they remain available as a contiguous gap if you need a larger subnet later. The one thing to avoid is leaving a small unusable sliver in the middle of the block, which is exactly the fragmentation that largest-first allocation prevents.