Computing, IT, Networking & Security IP Addressing & Subnetting CIDR (RFC 4632) with RFC 3021 /31 links

VLSM Subnet Design Calculator

Enter a parent block and how many hosts each segment needs, and this calculator builds the whole variable-length subnet plan: the network address, mask, usable host range and broadcast address for every subnet, plus what is left over. It allocates largest block first, which is the rule that keeps every subnet aligned on a boundary that is a multiple of its own size — the step hand-worked VLSM exercises get wrong most often. It also reports how much of the parent you have consumed and how efficiently, so you can see immediately whether a /24 is big enough or you need to ask for more.

Calculator

This calculator runs in your browser. Enable JavaScript for live results — the inputs, formula and worked example below remain fully readable without it.

Inputs this calculator takes, with typical values
InputWhat to enterExample
Parent network addressThe block you are dividing, in dotted decimal. Any address inside it works — the plan starts from the block boundary.10.0.0.0
Parent prefix lengthThe mask on the block you were given, for example 24 for a 256-address /24.24 /
Segment 1 hostsDevices needing an address on this segment, not counting the router interface's network and broadcast addresses.50
Segment 2 hostsSet any segment to zero to leave it out of the plan.20
Segment 3 hostsCount the hosts you expect at the end of the equipment's life, not the number on day one.10
Segment 4 hostsA router-to-router link needs 2 hosts; size mode below decides whether that becomes a /30 or a /31.2
Segment 5 hostsLeave at zero if you have fewer than five segments.0
Segment 6 hostsLeave at zero if you have fewer than six segments.0
How to size two-host linksA /31 halves the space used by each point-to-point link but requires equipment that implements RFC 3021./30 — 4 addresses, classic point-to-point

It returns

  • Share of the parent block allocated — Allocated addresses divided by the size of the parent block.
  • Subnets placed
  • Addresses allocated
  • Usable host addresses provided
  • Address efficiency — Hosts requested divided by addresses consumed — the cost of rounding each segment up to a power of two.
  • Addresses still free
  • Unallocated range

The formula

S=2log2(h+2),p=32log2S
E=hkSk

In plain text: size = 2^⌈log₂(h + 2)⌉, prefix = 32 − log₂(size), next network = previous network + size

  • SBlock size in addresses — always a power of two (addresses)
  • hHost addresses the segment needs (hosts)
  • pPrefix length of the resulting subnet (bits)

The +2 covers the network and broadcast addresses, which are not assignable to hosts on any block wider than a /31. On a /31 under RFC 3021 both addresses are assignable, so a two-host link needs only 2 addresses.

Updated Category IP Addressing & Subnetting Verified against published test cases Reading time 12 min

What variable-length subnet masking does

VLSM means cutting one address block into subnets of different sizes, each one matched to what its segment actually needs. The alternative — splitting a block into equal pieces — wastes an enormous amount of space the moment your segments differ. Divide a /24 into four equal /26s and every point-to-point link between routers gets 62 usable addresses to carry two. VLSM gives that link a /30 with two usable addresses and spends the remaining 60 elsewhere.

The design problem is simple to state and easy to get wrong. Every subnet has to be a power-of-two block, and every subnet has to start at an address that is a multiple of its own size. Those two rules together mean the order in which you allocate matters: place a small subnet first and you can end up with free space that is the right total size but in the wrong place, so a larger subnet no longer fits anywhere.

This calculator takes the host count for each of your segments, rounds each up to a legal block size, sorts them largest first, and lays them down end to end from the start of the parent block. The result is the addressing plan a network designer would draw on a whiteboard: network address, mask, first and last usable host, broadcast, and what is left. If you only need the properties of one fixed-size subnet, the IPv4 subnet calculator is the faster tool; if you want to convert between masks and prefix lengths, use the subnet mask and CIDR converter.

The formula, and why allocation order is part of it

Sizing a segment is one calculation. A subnet wide enough to hold h hosts must also hold the network address and the broadcast address, so it needs h + 2 addresses, rounded up to the next power of two:

size = 2⌈log₂(h + 2)⌉

A segment with 50 hosts needs 52 addresses, and the next power of two is 64, so it gets a /26. A segment with 62 hosts needs 64 exactly and still gets a /26. A segment with 63 hosts needs 65 and jumps to a /25 with 128 addresses — the step from 62 to 63 hosts doubles the block. That cliff is the single most useful thing to know about subnet sizing, and it is why growth estimates matter more than current device counts.

The prefix length follows from the size: p = 32 − log₂(size). A 64-address block is a /26 because 26 = 64 and 32 − 6 = 26.

Alignment is the rule that forces the order. A block of size S must begin at an address that is an exact multiple of S, because the mask has to be able to describe it. If you allocate largest first from an aligned parent, alignment takes care of itself: each block size divides every larger size, so the running pointer is always a multiple of whatever you place next. Allocate a /30 first from 10.0.0.0/24 and the pointer moves to 10.0.0.4, which is not a multiple of 64, so the next /26 cannot start there — you would have to skip to 10.0.0.64 and strand 60 addresses. Largest first is not a heuristic; it is what makes the greedy allocation optimal for powers of two.

One exception changes the arithmetic at the bottom end. RFC 3021 allows a /31 on point-to-point links, where the two addresses are both assignable and there is no broadcast address. Selecting that mode makes a two-host link cost 2 addresses instead of 4.

Worked example: 192.168.1.0/24 for 50, 20, 10 and 2 hosts

A branch office has four segments: 50 workstations, 20 phones, 10 servers, and one router-to-router link carrying two addresses. The site has 192.168.1.0/24, which is 256 addresses. Work the plan by hand.

  1. Size each segment. 50 + 2 = 52 → next power of two is 64 (/26). 20 + 2 = 22 → 32 (/27). 10 + 2 = 12 → 16 (/28). 2 + 2 = 4 → 4 (/30).
  2. Sort largest first. 64, 32, 16, 4 — already in order here.
  3. Place the /26. Starts at 192.168.1.0, covers 64 addresses, so it ends at 192.168.1.63. Usable hosts run .1 to .62; broadcast is .63. Mask 255.255.255.192.
  4. Place the /27. Starts at 192.168.1.64 — a multiple of 32, so it is aligned. Covers 32 addresses to 192.168.1.95. Usable .65 to .94, broadcast .95. Mask 255.255.255.224.
  5. Place the /28. Starts at 192.168.1.96, a multiple of 16. Covers 16 addresses to 192.168.1.111. Usable .97 to .110, broadcast .111. Mask 255.255.255.240.
  6. Place the /30. Starts at 192.168.1.112, a multiple of 4. Covers 4 addresses to 192.168.1.115. Usable .113 and .114, broadcast .115. Mask 255.255.255.252.
  7. Add it up. 64 + 32 + 16 + 4 = 116 addresses allocated of 256, which is 116 ÷ 256 = 45.31% of the parent. 256 − 116 = 140 addresses free, running from 192.168.1.116 to 192.168.1.255.
  8. Check the efficiency. You asked for 50 + 20 + 10 + 2 = 82 host addresses and consumed 116, so 82 ÷ 116 = 70.69%. The other 29.31% is the cost of rounding each segment up to a power of two plus the two reserved addresses in each block.

Note that the usable capacity you bought is 62 + 30 + 14 + 2 = 108 host addresses, not 116: each of the three larger blocks loses its network and broadcast address. That gap between allocated addresses and usable hosts is why a plan can look comfortable and still run out.

How to read the plan

Share of the parent allocated tells you whether the block you were given is the right size. Under about 50% and you have room for growth or for a second wave of segments. Above 90% and any new VLAN forces a renumber, because the free space left is fragmented into blocks too small to be useful. A design that lands near 100% is finished, not efficient.

Address efficiency measures something different: how much of what you consumed is actually requested host addresses. It falls whenever a segment sits just above a power of two — a 33-host segment takes a 64-address block and runs at barely half. If efficiency is low and space is tight, look for the segment that just crossed a boundary and ask whether the estimate can be trimmed below it, or whether two small segments could share one subnet.

Usable host addresses provided is the number to compare against your requirement. It is always at least two less than the allocated size for every block wider than a /31, and that subtraction is per subnet: split a /24 into eight /27s and you lose 16 addresses to network and broadcast overhead rather than 2.

The unallocated range is contiguous because the allocation is largest first, which is the property that makes the plan extensible. Whatever is free sits at the top of the block in one piece, so the largest new subnet you can add later is the biggest power of two that both fits in that space and is aligned to it — reported in the note above the table. Fragmented free space, by contrast, is the usual symptom of a plan that was allocated in request order rather than size order.

Subnet size reference for IPv4

Every legal block size, its prefix and mask, and how many hosts it actually carries. Usable hosts are size − 2 except on a /31 under RFC 3021 and a /32 host route.
PrefixMaskBlock sizeUsable hostsLargest requirement it serves
/22255.255.252.01,0241,0221,022
/23255.255.254.0512510510
/24255.255.255.0256254254
/25255.255.255.128128126126
/26255.255.255.192646262
/27255.255.255.224323030
/28255.255.255.240161414
/29255.255.255.248866
/30255.255.255.252422
/31255.255.255.25422 (RFC 3021)2, point-to-point only
/32255.255.255.25511Loopback or host route

Read it from the right: find the smallest row whose usable-host figure covers your requirement, and that is the block the sizing formula will choose.

Mistakes that break a VLSM plan

  • Allocating in request order rather than size order. Place a /30 before a /26 and the free space fragments, so a block that would have fitted no longer does even though the total space is available.
  • Forgetting the network and broadcast addresses. A segment with exactly 64 devices does not fit in a /26; it needs 66 addresses and takes a /25. The +2 in the formula is where most hand-worked exercises go wrong.
  • Sizing to today's device count. The block doubles at every power of two, so a segment at 60 hosts is one printer away from needing twice the space. Size to the expected count at the end of the equipment's life.
  • Starting from an address that is not a block boundary. 10.0.0.5/24 is not a network address. This calculator quietly rebuilds the plan from the block that contains it and tells you which one that is.
  • Deploying /31 links on equipment that does not support them. RFC 3021 is widely implemented on modern routers, but a device that treats the lower address as a network number will reject the configuration or drop traffic. Verify before you commit the plan.
  • Ignoring what the routing protocol can carry. VLSM requires the mask to travel with the route, so it needs a classless protocol — OSPF, EIGRP, IS-IS, BGP or static routes. Original RIPv1 cannot carry it.
  • Leaving no summarisable gap. A plan packed tight to 100% cannot be aggregated into a shorter prefix later. Reserve a contiguous tail so the site can be advertised as one route.

Where VLSM sits among addressing methods

VLSM is the subnetting half of classless addressing. RFC 4632 defines CIDR, which removed the fixed class A/B/C boundaries and made the prefix length an explicit part of every route. VLSM is what you do inside your own allocation once prefixes are arbitrary; route summarisation is the same idea running in the opposite direction, collapsing several contiguous prefixes into one advertisement. A plan built largest-first with a contiguous free tail summarises cleanly; a plan built ad hoc does not.

Two related tools finish the job. The wildcard mask calculator converts each of these subnets into the inverse mask Cisco access lists and OSPF network statements expect, which is the next thing you need after the plan exists. The IPv4 host count calculator answers the reverse question — given a prefix, how many hosts does it carry.

On IPv6 the exercise largely disappears. Every LAN gets a /64 regardless of how many hosts sit on it, because the interface identifier is fixed at 64 bits, so there is nothing to right-size. The IPv6 subnet calculator works out how many of those /64s your allocation contains and where the block starts and ends. Dual-stack networks therefore carry two very different addressing disciplines side by side: scarcity management on the IPv4 side, and structural clarity on the IPv6 side.

Finally, treat the output as a design, not a configuration. It says nothing about which VLAN ID or interface each subnet belongs to, about DHCP scopes and reservations, or about whether the addresses conflict with something already deployed. Record the plan in an IPAM system before you configure anything, because the expensive mistake in addressing is never the arithmetic — it is two engineers allocating the same block on different days.

Frequently asked questions

Why do you allocate the largest subnet first?

Because every block must start at an address that is a multiple of its own size, and allocating largest first guarantees that automatically. Each block size divides every larger size, so after placing a 64-address block the running pointer is still a multiple of 32, 16, 8 and 4. Place a /30 first and the pointer sits at .4, which no /26 can start from, so you strand 60 addresses to reach the next aligned boundary.

How many hosts fit in a /26?

62. A /26 has 232−26 = 64 addresses, and the first is the network address while the last is the broadcast address, leaving 62 assignable to hosts. The same subtraction applies to every block from /8 to /30: a /27 gives 30, a /28 gives 14, a /29 gives 6 and a /30 gives 2. Only a /31 under RFC 3021 escapes it, because a point-to-point link has no broadcast address.

What is the difference between VLSM and CIDR?

VLSM divides one block into unequal subnets inside your network; CIDR is the wider architecture that made prefix lengths arbitrary in the first place and lets routes be aggregated between networks. They rely on the same mechanism — carrying the mask with every route — so both need a classless routing protocol. In practice you use VLSM to design an internal plan and CIDR summarisation to advertise it outward as few routes as possible.

Can I really use a /31 on a point-to-point link?

Yes, on equipment that implements RFC 3021. A /31 has two addresses and no broadcast address, so both are assigned to the two router interfaces. It halves the address cost of every link, which matters on a network with dozens of WAN circuits. Check support on both ends first: a device that still treats the lower address as a network number will refuse the configuration, and mixed support across a link is worse than using /30 everywhere.

What does address efficiency below 60% mean?

It means most of the addresses you consumed are rounding waste rather than requested hosts. The usual cause is one segment sitting just above a power of two — asking for 33 hosts takes a 64-address block and wastes half of it before the network and broadcast addresses are counted. Efficiency is a diagnostic, not a target: a plan at 60% efficiency with plenty of free space is fine, while the same figure in a nearly full block tells you where to look for savings.

Why does my segment not fit even though there is enough free space?

Because the free space is not aligned to the size the segment needs, or is split across the block. In this calculator every plan is allocated largest first, so free space is always one contiguous run at the top of the parent, and the largest block you can still add is the biggest power of two that both fits in that run and starts on its own multiple. If a segment is reported as not fitting, the parent block is genuinely too small for the set of requirements.

Should I count the router interface as a host?

Yes. The router's own address on the segment consumes one of the usable host addresses, as does every switch management interface, printer, wireless access point and virtual IP. Count everything that answers to an address on that subnet, then add growth. The two addresses you do not count are the network and broadcast addresses — the formula adds those for you.

Does this plan work with private address space?

Yes, and that is the normal case. RFC 1918 reserves 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 for private use, and all three are divided by exactly the same arithmetic as public space. The one thing to check is overlap: if the network will ever be joined to a partner or acquired company, pick a block that is unlikely to collide, because renumbering after the fact costs far more than choosing carefully now.

References