VLSM Calculator

Last updated

Splits a parent CIDR block into variable-length subnets sized to each host count. Every count plus the reserved addresses, two for network and broadcast or the four or five a cloud provider keeps, is rounded up to a power-of-two block, never below the provider's smallest subnet; an option gives point-to-point links a /31. Blocks are sorted largest first and packed from the parent's first address, keeping each aligned. IPv6 mode cuts a prefix into equal subnets of a chosen length.

Address family
Subnet plan
Parent block –
Allocated –
Share of parent used –
Free space –

List the subnets you need as names and host counts, give the block they must fit in, and the calculator sizes each subnet, packs them into the parent without gaps and shows what is left. You choose how many addresses each subnet loses: the network and broadcast addresses, the same with /31 and /32 allowed for point-to-point links, or the reservations of AWS, Azure or Google Cloud. With the defaults, five subnets in 192.168.1.0/24 take a /25, a /26, a /27, a /28 and a /30. They use 244 of the 256 addresses, 95.31%, and leave 192.168.1.244/30 and 192.168.1.248/29 free. IPv6 mode divides a prefix into equal subnets instead.

How the allocation works

Each subnet's block must hold its hosts plus the addresses the network reserves. Under the plain IPv4 rule that is two: the first address names the subnet and the last is its broadcast. Block sizes are powers of two, so the total is rounded up, and the smallest subnet allowed sets a floor: a /30 under the plain rules, a /28 on AWS and a /29 on Azure and Google Cloud.

size = max(2⌈log2(hosts + reserved)⌉, smallest block)

prefix = 32 − log2 size

A 100-host subnet needs 102 addresses, which round up to 128, a /25. Its mask is 25 one bits followed by 7 zeros. The last octet, 10000000 in binary, is 128, so the mask reads 255.255.255.128. With /31 and /32 allowed, a subnet of two hosts takes a /31 and a single host takes a /32, a host route.

The calculator then sorts the subnets by host count, largest first, and places each one directly after the one before:

networkk = parent + size1 + … + sizek−1

A block has to start on a multiple of its own size. Every block before it in the sorted list is at least as large, and every size is a power of two, so the sum of the earlier blocks is always a multiple of the current one. The plan therefore runs from the parent's first address with no gaps, and it fits whenever the block sizes add up to no more than the parent. If they add up to more, no arrangement can fit, and the calculator says how many addresses are needed. Whatever is left at the end is split into the fewest aligned blocks that cover it, each listed with its prefix.

Planning the default /24

The default list asks for Engineering 100, Sales 50, Support 25, HR 12 and a WAN link of 2. Engineering's 102 addresses round up to 192.168.1.0/25, with hosts .1 through .126 and 26 spare. Sales takes 192.168.1.128/26 with 62 usable addresses for its 50 hosts, Support 192.168.1.192/27 with 30, HR 192.168.1.224/28 with 14, and the WAN link 192.168.1.240/30, whose 2 usable addresses leave none spare. The blocks total 128 + 64 + 32 + 16 + 4 = 244 addresses. The 12 left over start at 192.168.1.244, a multiple of 4 but not of 8, so they split into 192.168.1.244/30 and 192.168.1.248/29. Enter 192.168.1.130 with a /26 in the subnet calculator and it reports the Sales row's network, 192.168.1.128, and broadcast, 192.168.1.191.

Order matters. Placed one after another in typed order, without going back to fill gaps, Sales' /26 would take 192.168.1.0 to .63. Engineering's /25 would then have to start at the next multiple of 128, 192.168.1.128, and fill the /24 to its end. HR, Support and the WAN link would find no room after it, while the 64 addresses from .64 to .127 sat unused. Sorting first avoids the gap, so every order you type the list in gives the plan above.

Cloud subnets reserve more

AWS reserves the first four and the last address of every subnet. In 10.0.0.0/24, .0 is the network address, .1 belongs to the VPC router, .2 is reserved by AWS (the VPC's DNS server sits at the base of the VPC range plus two), .3 is kept for future use, and .255 is reserved because VPCs do not support broadcast. AWS subnets run from /16 to /28, and a VPC's IPv4 block has the same limits, so the AWS option rejects a parent outside them. Azure also reserves the first four and the last address, with /29 as its smallest subnet. Google Cloud keeps the first two and the last two addresses of each primary range and allows ranges as small as eight addresses, a /29.

The reservations change the plan. Under AWS's rules HR's 12 hosts no longer fit a /28, which keeps 11 usable addresses, so HR needs a /27, and the WAN link is raised to the /28 minimum. The list then needs 272 addresses, more than the /24 holds. Azure's rules need 264. Google Cloud's fit in 248, with HR filling its /28 exactly. Under AWS the same list fits in 192.168.0.0/23, using 272 of its 512 addresses, 53.13%. Sizing matters even more on Amazon EKS, whose VPC CNI plugin gives every Pod its own address from the VPC, so a subnet's size limits how many Pods it can hold.

From one mask per network to VLSM

Subnetting began with one size per network. RFC 950, written by Mogul and Postel in August 1985, made the width of the subnet field "constant for a given network", so every subnet of a network used the same mask. It also said the all-zeros and all-ones subnet numbers should not be assigned. In June 1987, RFC 1009, Braden and Postel's requirements for Internet gateways, relaxed the rule: "we allow a particular subnetted network to use more than one subnet mask," with a separate mask configurable on each interface of a gateway.

For that to work, routing protocols had to carry the masks. The first version of RIP sent none, which G. Malkin, the author of version 2, called "a particularly serious problem for routers." His RFC 1388, in January 1993, added a subnet mask to every route entry of RIP version 2, which RFC 2453 now defines. That September, RFC 1519 defined classless inter-domain routing, superseding RFC 1338's 1992 supernetting proposal. It argued that "the judicious use of variable-length subnetting techniques" should help defer the exhaustion of the 32-bit address space, and assumed that organizations importing supernet routes would run interior protocols such as OSPF that support classless routes. In December 1995 RFC 1878 published a table of variable-length subnets and called the old exclusion of the all-zeros and all-ones subnets obsolete. RFC 3021, in December 2000, went further for point-to-point links: both addresses of a /31 are host addresses, so a link consumes two addresses instead of four.

IPv6: equal splits instead of host counts

IPv6 subnets are sized by prefix length, not host count. RFC 4291 gives IPv6 no broadcast addresses and fixes interface identifiers at 64 bits for unicast addresses, apart from those that begin with binary 000. RFC 7421 calls 64 bits the de facto interface-identifier length, with RFC 6164's /127 for router-to-router links the only documented exception. It notes that stateless autoconfiguration is honored only on a 64-bit prefix, so a longer prefix needs manual addresses or DHCPv6. RFC 6177 replaced RFC 3177, which had argued for a /48 for most end sites, and suggests giving home users "less than /48, such as a /56," and at least one /64.

IPv6 mode takes a parent prefix, a new prefix length and a number of subnets, and lists that many consecutive subnets from the start of the parent. Addresses are printed the way RFC 5952 recommends: lowercase, no leading zeros, and the longest run of zero groups shortened to ::. The default parent, 2001:db8:1234:1a00::/56, is the example VPC block in AWS's documentation, inside the 2001:db8::/32 prefix RFC 3849 reserves for documentation. Split into /64s, it gives 2001:db8:1234:1a00::/64 through 2001:db8:1234:1a03::/64. That is 4 of its 256 /64s, 1.56%, with 252 more starting at 2001:db8:1234:1a04::/64. On AWS, IPv6 subnets can be /44 to /64 in steps of 4 bits, and Azure requires exactly /64.

Assumptions and limits

The plain rules reserve only the network and broadcast addresses, so count the router interface as one of a subnet's hosts; the cloud options already reserve their gateways. The Google Cloud option applies primary-range rules, while secondary ranges have every address usable. Ranges brought to AWS through BYOIP also use every address, which the AWS option does not model. Write host counts as whole numbers without thousands separators, and keep the list on one line, separated by commas or semicolons. Lists are capped at 100 subnets and 2,000 characters, and names at 40 characters. IPv4 mode has no equal split; for one, enter the same host count several times. IPv4 parents run from /8 to /32, so Azure's largest subnet, /2, and Google Cloud's shortest mask, /4, are out of reach. IPv6 output never uses the mixed dotted form that RFC 5952 recommends for well-known IPv4-embedding prefixes such as ::ffff:0:0/96.

Frequently asked questions

What is VLSM?

Variable Length Subnet Masking gives each subnet carved from one parent block its own prefix length. A 100-host department gets a /25 while a two-address router link gets a /30, instead of every subnet taking the same size. With the defaults, 192.168.1.0/24 becomes a /25, a /26, a /27, a /28 and a /30, uses 244 of its 256 addresses and leaves 12 free. RFC 1009 relaxed the earlier one-mask-per-network rule in June 1987.

Why does VLSM allocate the largest subnet first?

Every block has to start on a multiple of its own size. Taken largest first, each block ends on a boundary the next block, never a larger one, can start on, so the plan packs into one run with no gaps and fits whenever the block sizes add up to no more than the parent. Placed one after another in typed order instead, without going back to fill gaps, the default Sales /26 takes 192.168.1.0 and Engineering's /25 must jump to 192.168.1.128, leaving no room for HR, Support or the WAN link while 64 addresses sit unused.

How many usable addresses does an AWS subnet have?

Five fewer than its size. AWS reserves the network address, the next three (the VPC router, an address AWS reserves and one kept for future use) and the last address, because VPCs do not support broadcast. A /28, the smallest subnet AWS allows, keeps 11 usable addresses, a /24 keeps 251 and a /16, the largest, keeps 65,531. Azure also reserves five addresses per subnet, while Google Cloud reserves four in each primary range.

Should a point-to-point link use a /30 or a /31?

A /31 if both routers support RFC 3021, which treats both addresses of a 31-bit prefix as hosts with no broadcast address, so a link consumes two addresses instead of four. Choose the option with /31 and /32 allowed, and the default WAN link moves from 192.168.1.240/30 to 192.168.1.240/31, raising the free space from 12 to 14 addresses. With plain network and broadcast reservation, one- and two-host subnets get a /30.

What size should an IPv6 subnet be?

A /64 for any network with hosts. RFC 4291 fixes interface identifiers at 64 bits for almost all unicast addresses, and stateless autoconfiguration works only on a 64-bit prefix, so longer prefixes need manual addressing or DHCPv6. RFC 6164 allows /127 prefixes on links between two routers. RFC 6177 suggests giving home users less than a /48, such as a /56, which holds 256 /64s, while a /48 holds 65,536.

What happens if the parent address has host bits set?

The calculator clears them and says so in the Parent block line, so 192.168.1.130/24 is planned as 192.168.1.0/24 and gives the same plan as the default. AWS does the same when a subnet or VPC is created from the command line or the API, turning 100.68.0.18/18 into 100.68.0.0/18.

Sources

  1. RFC 950: Internet Standard Subnetting Procedure, IETF, 1985
  2. RFC 1009: Requirements for Internet Gateways, IETF, 1987
  3. RFC 1388: RIP Version 2 Carrying Additional Information, IETF, 1993
  4. RFC 1519: Classless Inter-Domain Routing (CIDR): an Address Assignment and Aggregation Strategy, IETF, 1993
  5. RFC 1878: Variable Length Subnet Table For IPv4, IETF, 1995
  6. RFC 2453: RIP Version 2, IETF, 1998
  7. RFC 3021: Using 31-Bit Prefixes on IPv4 Point-to-Point Links, IETF, 2000
  8. RFC 3849: IPv6 Address Prefix Reserved for Documentation, IETF, 2004
  9. RFC 4291: IP Version 6 Addressing Architecture, IETF, 2006
  10. RFC 5952: A Recommendation for IPv6 Address Text Representation, IETF, 2010
  11. RFC 6164: Using 127-Bit IPv6 Prefixes on Inter-Router Links, IETF, 2011
  12. RFC 6177: IPv6 Address Assignment to End Sites, IETF, 2011
  13. RFC 7421: Analysis of the 64-bit Boundary in IPv6 Addressing, IETF, 2015
  14. Subnet CIDR blocks, Amazon Web Services, Amazon VPC User Guide
  15. VPC CIDR blocks, Amazon Web Services, Amazon VPC User Guide
  16. Assign IPs to Pods with the Amazon VPC CNI, Amazon Web Services, Amazon EKS User Guide
  17. Azure Virtual Network FAQ, Microsoft Learn, 2026
  18. Subnets, Google Cloud