VLSM Calculator with Steps - Variable Length Subnet Planner
VLSM Calculator
Split an IPv4 block into variable-length subnets: enter the base network and the hosts each subnet needs. The calculator allocates largest-first and shows every step, the free blocks left, and a CSV you can download.
Subnets
Result
What this VLSM calculator does
VLSM (Variable Length Subnet Masking) gives every subnet its own mask, sized to the hosts it really needs, instead of cutting a block into equal pieces. This VLSM calculator takes one base IPv4 network and a list of subnets with their host counts, picks the smallest prefix for each, allocates them largest-first without overlaps, and shows the network, first and last host, broadcast, mask, usable and wasted addresses for every subnet. It also lists the free blocks that are left as CIDR prefixes, explains every step, and lets you copy the plan, download it as CSV or share it with a link (the plan is stored in the URL after the #).
How it works
1. Prefix length for each subnet
A normal subnet loses two addresses: the all-zeros host part is the network address and the all-ones host part is the directed broadcast (RFC 950, RFC 1878). With h host bits a subnet has 2^h addresses, so the calculator picks the smallest h where
hosts + 2 <= 2^h and then prefix = 32 - h
Example: 28 hosts need 30 addresses. 2^4 = 16 is too small and 2^5 = 32 is enough, so h = 5 and the prefix is /27. The smallest normal subnet is a /30 (2 usable hosts).
2. Special cases: /31 and /32
- /31 (option): RFC 3021 allows a 31-bit prefix on point-to-point links. The two addresses are the two endpoints; there is no network or broadcast address. When the option is on, a subnet that needs exactly 2 hosts gets a /31 instead of a /30. Cisco IOS accepts a /31 on Ethernet but prints "% Warning: use /31 mask on non point-to-point interface cautiously", so use it only where exactly two devices share the link.
- /32 (option): a single address with no network or broadcast address. Cisco documents /32 for interfaces that have only one address, such as a loopback. When the option is on, a subnet that needs 1 host gets a /32.
3. Largest-first allocation
The subnets are sorted by block size, largest first; subnets of the same size keep the order you entered. Each block is then placed at the next free address. Because every block is a power of two and the bigger blocks come first, each new block starts on its own boundary, so there are no gaps. This is why the whole plan fits whenever the sum of the block sizes is not larger than the base network. If it does not fit, the calculator shows how many addresses are missing and the shortest base prefix that would hold the plan.
The calculator uses subnet zero and the all-ones subnet. RFC 1878 calls excluding them obsolete, and Cisco IOS has ip subnet-zero enabled by default since release 12.0.
4. Summary numbers
- Usable hosts = 2^h - 2 for /30 and shorter, 2 for /31, 1 for /32.
- Wasted = usable hosts - needed hosts (spare host addresses inside that subnet).
- Utilization = allocated addresses / addresses in the base network x 100.
- Free blocks = the unallocated rest of the base network, written as the smallest list of aligned CIDR blocks.
If the base address has host bits set (for example 10.0.0.5/24), the calculator warns you and uses the network address (10.0.0.0/24).
Sources: RFC 950 (Internet Standard Subnetting Procedure), RFC 1878 (Variable Length Subnet Table for IPv4), RFC 3021 (Using 31-Bit Prefixes on IPv4 Point-to-Point Links), RFC 4632 (CIDR), Cisco "Configure IP Addresses and Unique Subnets for New Users" (Document ID 13788: VLSM example, 31-bit and 32-bit subnets) and Cisco "Configure Subnet Zero and All-Ones Subnet" (Document ID 13711).
Worked examples
- Cisco's VLSM example, 192.168.5.0/24. netA 14, netB 28, netC 2, netD 7 and netE 28 hosts. Prefixes: 28 hosts -> /27, 14 -> /28, 7 -> /28 (a /29 has only 6 usable), 2 -> /30. Largest first: netB 192.168.5.0/27, netE 192.168.5.32/27, netA 192.168.5.64/28, netD 192.168.5.80/28, netC 192.168.5.96/30. 100 of 256 addresses are used (39.06 %); free blocks: 192.168.5.100/30, 192.168.5.104/29, 192.168.5.112/28, 192.168.5.128/25. This is the default example above.
- Campus in 10.0.0.0/22. Sales 300 hosts (302 addresses -> /23), Engineering 120 (/25), Mgmt 50 (/26), two WAN links with 2 hosts each (/30). Result: Sales 10.0.0.0/23, Engineering 10.0.2.0/25, Mgmt 10.0.2.128/26, WAN1 10.0.2.192/30, WAN2 10.0.2.196/30. 712 of 1,024 addresses used (69.53 %), free: 10.0.2.200/29, 10.0.2.208/28, 10.0.2.224/27, 10.0.3.0/24.
- Same campus with the /31 option. WAN1 becomes 10.0.2.192/31 (usable 10.0.2.192 and 10.0.2.193) and WAN2 10.0.2.194/31. Only 708 addresses are used and 10.0.2.196/30 joins the free list.
- Loopback and three point-to-point links in 172.16.0.0/28 with both options on. The three /31 links come first (172.16.0.0/31, 172.16.0.2/31, 172.16.0.4/31), then the loopback 172.16.0.6/32. 7 of 16 addresses used; free: 172.16.0.7/32 and 172.16.0.8/29.
- A plan that does not fit. 192.168.10.0/24 with A 100, B 100 and C 60 hosts needs /25 + /25 + /26 = 128 + 128 + 64 = 320 addresses. The /24 has 256, so 64 addresses are missing. The smallest block that holds 320 addresses is a /23 (512), for example 192.168.10.0/23.
Hosts per prefix (quick reference)
| Prefix | Mask | Addresses | Usable hosts | Fits host counts |
|---|---|---|---|---|
| /32 | 255.255.255.255 | 1 | 1 | 1 (loopback, option) |
| /31 | 255.255.255.254 | 2 | 2 | 2 (point-to-point, option) |
| /30 | 255.255.255.252 | 4 | 2 | 1-2 |
| /29 | 255.255.255.248 | 8 | 6 | 3-6 |
| /28 | 255.255.255.240 | 16 | 14 | 7-14 |
| /27 | 255.255.255.224 | 32 | 30 | 15-30 |
| /26 | 255.255.255.192 | 64 | 62 | 31-62 |
| /25 | 255.255.255.128 | 128 | 126 | 63-126 |
| /24 | 255.255.255.0 | 256 | 254 | 127-254 |
| /23 | 255.255.254.0 | 512 | 510 | 255-510 |
| /22 | 255.255.252.0 | 1,024 | 1,022 | 511-1,022 |
| /21 | 255.255.248.0 | 2,048 | 2,046 | 1,023-2,046 |
| /20 | 255.255.240.0 | 4,096 | 4,094 | 2,047-4,094 |
| /16 | 255.255.0.0 | 65,536 | 65,534 | 32,767-65,534 |
FAQ
What is VLSM?
VLSM (Variable Length Subnet Masking) means using different subnet masks inside the same address block, so each subnet is only as large as it needs to be. A 2-host WAN link gets a /30 while a 100-host LAN gets a /25, instead of giving every subnet the same mask and wasting addresses.
How do I calculate the prefix length for a number of hosts?
Add 2 for the network and broadcast addresses and find the smallest power of two that is at least that big. If that power is 2^h, the prefix is 32 - h. For 50 hosts: 50 + 2 = 52, 2^6 = 64 is enough, so the prefix is /26 with 62 usable hosts.
Why does VLSM allocate the largest subnet first?
Every subnet must start on a multiple of its own size. If the biggest blocks are placed first, each following block automatically starts on a valid boundary, so no addresses are lost in gaps and the plan fits whenever the total of the block sizes fits in the base network.
Should I use /30 or /31 for point-to-point links?
A /31 (RFC 3021) uses 2 addresses instead of 4, because both addresses are host addresses on a point-to-point link. Use it when both routers support it; Cisco IOS accepts it and warns when it is configured on an Ethernet interface. A /30 works everywhere but wastes the network and broadcast addresses.
What happens if my subnets do not fit in the base network?
The calculator shows the total addresses required, how many are missing, and the shortest base prefix that would hold the whole plan. You can then use a larger base network or lower the host counts.
Does the calculator use subnet zero?
Yes. The first subnet starts at the base network address. RFC 1878 calls the old rule against subnet zero and the all-ones subnet obsolete, and Cisco IOS enables ip subnet-zero by default since release 12.0.
What does wasted mean in the result table?
Wasted is the number of usable host addresses in a subnet that you did not ask for: usable hosts minus needed hosts. For example, 7 hosts need a /28 with 14 usable addresses, so 7 addresses are wasted.
Comments
Post a Comment