What is a VLSM Calculator?
Variable Length Subnet Masking (VLSM) lets network engineers divide a single IP block into subnets of different sizes, matching each subnet to its actual host requirement. This avoids wasting addresses that fixed-length subnetting would squander. This calculator takes a base network address and a list of host counts, then allocates contiguous subnets from largest to smallest.
How to Use It
Enter the starting network address (for example 192.168.1.0) and a comma-separated list of how many hosts each subnet must support (for example 50, 20, 10, 2). The tool sorts requirements from largest to smallest, then assigns each one the smallest subnet that fits, packing them end to end so no address space is wasted.
The Formula Explained
For each host requirement h, you need room for h hosts plus a network address and a broadcast address, so h + 2 addresses total. The prefix is $$\text{Prefix} = 32 - \left\lceil \log_{2}\!\left( h + 2 \right) \right\rceil$$ and the block size is \(2^{32 - \text{Prefix}}\). For example, 50 hosts needs 52 addresses; \(\lceil \log_{2}(52) \rceil = 6\), so the prefix is /26 with a block of 64 addresses and 62 usable hosts.
Worked Example
Base network 192.168.1.0 with requirements 50, 20, 10, 2: the /26 (64 addresses) goes to the 50-host LAN at 192.168.1.0, the /27 (32 addresses) for 20 hosts starts at 192.168.1.64, the /28 (16 addresses) for 10 hosts starts at 192.168.1.96, and a /30 (4 addresses) for the 2-host point-to-point link starts at 192.168.1.112. Total used: 116 addresses.
CIDR Prefix, Subnet Mask and Host Capacity Lookup Table
This table applies to IPv4. Total addresses = \(2^{32-n}\) for a /n prefix. Usable hosts are normally total \(-\) 2, because the network address and broadcast address cannot be assigned to hosts. /31 and /32 are special cases. The last-octet block increment applies when the prefix falls within the last octet (/24 to /30).
| Prefix | Subnet mask | Wildcard mask | Total addresses | Usable hosts | Last-octet block increment |
|---|---|---|---|---|---|
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 | n/a (steps of 4 in the third octet) |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 | n/a (steps of 2 in the third octet) |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 | 256 (whole octet) |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 | 128 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 | 64 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 | 32 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 | 16 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 | 8 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 | 4 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 (special case: point-to-point links per RFC 3021, no network/broadcast address) | n/a (2) |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 (special case: a single host route) | n/a (1) |
To pick a prefix for a host requirement, find the smallest block where usable hosts are at least the requirement: \(\text{Prefix} = 32 - \lceil \log_2(\text{Hosts}+2) \rceil\). For example, 50 hosts: \(\lceil \log_2 52 \rceil = 6\), so the prefix is \(32 - 6 = 26\).
VLSM Terminology and Glossary
- VLSM (Variable Length Subnet Mask)
- A technique that splits one address block into subnets of different sizes, so each subnet gets a prefix matched to its host requirement instead of one uniform mask.
- CIDR notation
- Writing an IPv4 address followed by a slash and the number of leading network bits, such as 192.168.1.0/26.
- Subnet mask
- A 32-bit value whose leading 1-bits mark the network portion of an address and whose 0-bits mark the host portion, such as 255.255.255.192 for /26.
- Network address
- The first address of a subnet, with all host bits set to 0. It identifies the subnet and is not assigned to a host (except in /31 and /32 cases).
- Broadcast address
- The last address of a subnet, with all host bits set to 1. Traffic sent to it reaches all hosts in that subnet.
- Usable host range
- The addresses between the network address and the broadcast address, i.e. network + 1 through broadcast − 1.
- Block size
- The number of addresses in a subnet, \(2^{32-n}\). Subnets must start at an address that is a multiple of their block size, which is why VLSM allocation normally proceeds from the largest subnet to the smallest.
- Summarization (aggregation)
- Combining several contiguous subnets into one shorter-prefix route, for example two adjacent /25 networks aggregated into one /24. It reduces routing table size and works best when VLSM allocations are contiguous.
- Point-to-point link (/31, RFC 3021)
- A link between exactly two devices. Traditionally a /30 is used (2 usable hosts of 4 addresses); RFC 3021 allows a /31 where both addresses are usable, saving addresses, provided the equipment supports it.
VLSM vs Fixed-Length Subnetting Comparison
Scenario 1: 50, 20, 10 and 2 hosts in 192.168.1.0/24
With fixed-length subnetting, the largest requirement (50 hosts) forces a /26 (62 usable) for every subnet. Four /26 subnets use all 4 × 64 = 256 addresses. With VLSM each subnet receives the smallest suitable block.
| Requirement | Fixed /26: block (usable) | Fixed: unused usable addresses | VLSM prefix | VLSM block (usable) | VLSM: unused usable addresses | VLSM subnet |
|---|---|---|---|---|---|---|
| 50 hosts | 64 (62) | 12 | /26 | 64 (62) | 12 | 192.168.1.0/26 |
| 20 hosts | 64 (62) | 42 | /27 | 32 (30) | 10 | 192.168.1.64/27 |
| 10 hosts | 64 (62) | 52 | /28 | 16 (14) | 4 | 192.168.1.96/28 |
| 2 hosts | 64 (62) | 60 | /30 | 4 (2) | 0 | 192.168.1.112/30 |
| Total | 256 addresses used; 0 remaining | 166 | 64 + 32 + 16 + 4 = 116 used; 256 − 116 = 140 remaining | 26 | Free: 192.168.1.116 – 192.168.1.255 |
Fixed /26 subnets do fit the four requirements, but they consume the whole /24 and leave no room for growth. VLSM uses 116 addresses and leaves 140 contiguous addresses free for future subnets.
Scenario 2: 100, 50, 25 and 2 hosts in 192.168.1.0/24
| Requirement | Fixed /25: block (usable) | VLSM prefix | VLSM block (usable) | VLSM subnet |
|---|---|---|---|---|
| 100 hosts | 128 (126) | /25 | 128 (126) | 192.168.1.0/25 |
| 50 hosts | 128 (126) | /26 | 64 (62) | 192.168.1.128/26 |
| 25 hosts | 128 (126) | /27 | 32 (30) | 192.168.1.192/27 |
| 2 hosts | 128 (126) | /30 | 4 (2) | 192.168.1.224/30 |
| Total | 4 × 128 = 512 addresses: does NOT fit in a /24 | 128 + 64 + 32 + 4 = 228 used; 28 remaining | Free: 192.168.1.228 – 192.168.1.255 |
Here a uniform mask sized for the 100-host subnet needs 512 addresses, twice what a /24 provides, while VLSM fits all four subnets with 28 addresses to spare. Always allocate the largest subnet first so every block starts on a boundary that is a multiple of its size.
FAQ
Why +2 hosts? Every IPv4 subnet reserves one address for the network ID and one for broadcast, so usable hosts equal block size minus two.
Why sort largest first? Allocating the biggest subnets first keeps blocks aligned to their natural boundaries and prevents fragmentation.
What is the smallest practical subnet? A /30 gives 2 usable hosts, ideal for router-to-router links; /31 is sometimes used for point-to-point with no broadcast.