How VLSM works
Variable-length subnet masking gives each subnet only the space it needs instead of cutting one block into equal pieces. Classless prefixes like this are defined in RFC 4632.
- Sort the subnets from most hosts to fewest.
- For each one, add 2 addresses (network and broadcast) and round up to the next power of 2. That size sets the prefix: a 100-host subnet needs 102 addresses, rounded up to 128, which is a /25.
- Place each subnet at the next free address that is a multiple of its size. Going largest first means nothing is wasted on alignment.
Worked example
From 192.168.1.0/24 with 100, 50, 20 and 2 hosts: 192.168.1.0/25 (126 usable), 192.168.1.128/26 (62), 192.168.1.192/27 (30) and 192.168.1.224/30 (2). That uses 228 of 256 addresses and leaves 192.168.1.228/30, 192.168.1.232/29 and 192.168.1.240/28 free. With the /31 option the router link takes only 2 addresses (RFC 3021). This example is one of our automated tests.
Need a single subnet's details instead? Use the subnet / CIDR calculator.
Sources
Logic checked against the sources above and our test cases on 2026-10-17. Planning aid, not legal, engineering or clinical advice.