LogicGates.org Open the simulatorSimulator

VLSM calculator

Give a network and the number of hosts each subnet needs. The calculator sizes every subnet, packs them largest first so each block is aligned, and shows what is left. Or split a network into equal subnets.

A network and prefix, such as 192.168.10.0/24 or 10.0.0.0 255.255.252.0. It has 256 addresses.

Subnets and the hosts each needs

Plan for 192.168.10.0/24 5 subnets, 120 of 256 addresses used 136 addresses left free, starting at 192.168.10.120. /31 links for the 2 subnets of 1 or 2 hosts would save 4 more.
The subnets, largest first, then the free space
# Name Network and mask Needs Usable Host range Broadcast Unused
1 Sales 192.168.10.0/26255.255.255.192 50 62 192.168.10.1to 192.168.10.62 192.168.10.63 12
2 HR 192.168.10.64/27255.255.255.224 20 30 192.168.10.65to 192.168.10.94 192.168.10.95 10
3 IT 192.168.10.96/28255.255.255.240 10 14 192.168.10.97to 192.168.10.110 192.168.10.111 4
4 Link A 192.168.10.112/30255.255.255.252 2 2 192.168.10.113to 192.168.10.114 192.168.10.115 0
5 Link B 192.168.10.116/30255.255.255.252 2 2 192.168.10.117to 192.168.10.118 192.168.10.119 0
Free (8) 192.168.10.120/29255.255.255.248 192.168.10.120 to 192.168.10.127
Free (128) 192.168.10.128/25255.255.255.128 192.168.10.128 to 192.168.10.255

Unused counts usable addresses a subnet has beyond what it asked for. Select a network to see its bits in the subnet calculator.

How VLSM works

The calculator's opening example, step by step: 192.168.10.0/24 shared between three departments and two router links.

  1. Size each subnet. A subnet needs its hosts plus two addresses, for the network and broadcast address, rounded up to a power of two. 50 hosts need 52 addresses, so a block of 64, a /26.
  2. Sort largest first. Every block has to start at a multiple of its own size: a /26 at .0, .64, .128 or .192, a /30 at any multiple of 4.
  3. Place them one after another. Because each block is no bigger than the one before, it always starts on its own boundary, and nothing is wasted between blocks.
Subnet Hosts Hosts + 2 Block Placed at Next free
Sales 50 52 64 (/26) 192.168.10.0/26 192.168.10.64
HR 20 22 32 (/27) 192.168.10.64/27 192.168.10.96
IT 10 12 16 (/28) 192.168.10.96/28 192.168.10.112
Link A 2 4 4 (/30) 192.168.10.112/30 192.168.10.116
Link B 2 4 4 (/30) 192.168.10.116/30 192.168.10.120

The five subnets use 120 of 256 addresses, leaving 192.168.10.120/29 and 192.168.10.128/25 free for later. Placed in the reverse order, smallest first, the same blocks would span 128 addresses, because each larger block has to skip ahead to its next boundary. With /31 links the plan needs 116.

Each subnet's network address is its first address AND its mask; the subnet calculator draws that AND bit by bit.

Which prefix for how many hosts

The smallest block for a host count: two addresses go to the network and broadcast, so each prefix covers up to its size minus two.

Hosts needed Prefix Mask Addresses
1 to 2 /30 255.255.255.252 4
3 to 6 /29 255.255.255.248 8
7 to 14 /28 255.255.255.240 16
15 to 30 /27 255.255.255.224 32
31 to 62 /26 255.255.255.192 64
63 to 126 /25 255.255.255.128 128
127 to 254 /24 255.255.255.0 256
255 to 510 /23 255.255.254.0 512
511 to 1,022 /22 255.255.252.0 1,024
1,023 to 2,046 /21 255.255.248.0 2,048
2,047 to 4,094 /20 255.255.240.0 4,096
4,095 to 8,190 /19 255.255.224.0 8,192
8,191 to 16,382 /18 255.255.192.0 16,384
16,383 to 32,766 /17 255.255.128.0 32,768
32,767 to 65,534 /16 255.255.0.0 65,536

A requirement just over a boundary doubles its block: 62 hosts fit a /26, 63 need a /25. Leave room for growth when you size, since renumbering a subnet later is far more work than a bigger block now.

Splitting a network into equal subnets

The equal split mode is fixed length subnet masking: every subnet gets the same prefix. It works by borrowing bits from the host part. Each borrowed bit doubles the number of subnets and halves their size, so borrowing n bits gives 2n subnets. A count that is not a power of two rounds up: 5 subnets need 3 bits, which gives 8.

192.168.10.0/24 into 4: borrow 2 bits, so the prefix becomes /26 and each of the 4 subnets has 64 addresses, 62 of them usable.

Subnet Network First host Last host Broadcast
1 192.168.10.0/26 192.168.10.1 192.168.10.62 192.168.10.63
2 192.168.10.64/26 192.168.10.65 192.168.10.126 192.168.10.127
3 192.168.10.128/26 192.168.10.129 192.168.10.190 192.168.10.191
4 192.168.10.192/26 192.168.10.193 192.168.10.254 192.168.10.255

Splitting a /24

Subnets Bits borrowed New prefix Mask Addresses each Usable each
2 1 /25 255.255.255.128 128 126
4 2 /26 255.255.255.192 64 62
8 3 /27 255.255.255.224 32 30
16 4 /28 255.255.255.240 16 14
32 5 /29 255.255.255.248 8 6
64 6 /30 255.255.255.252 4 2

Common mistakes

  • Forgetting the two reserved addresses. A block of 32 holds 30 hosts, not 32. Count the router's own interface as a host too.
  • Starting a block off its boundary. 192.168.10.16/26 is not a network: a /26 must start at a multiple of 64. The calculator always places blocks on their boundary.
  • Allocating in the order listed. Small blocks first leave gaps the large ones cannot use. Sort largest first.
  • Overlapping subnets. Two subnets that share addresses make routing ambiguous. Plans here are built to tile the base network exactly, with no overlap, and the test suite checks that on thousands of random plans.

Questions

What is VLSM?

Variable length subnet masking: splitting one network into subnets of different sizes, each with its own prefix length, instead of cutting it into equal pieces. A department of 50 hosts gets a block for 50, and a link between two routers gets a block for 2, so far fewer addresses go unused.

Why allocate the largest subnet first?

Every subnet must start at a multiple of its own size. Placing the biggest blocks first means each smaller block starts where the last one ended and is already aligned, so there are no gaps. The example plan on this page needs 120 addresses largest first; listed in reverse, smallest first, the same blocks would span 128.

How big a subnet do 50 hosts need?

A /26: 64 addresses, of which 62 are usable after the network and broadcast address. The rule is the smallest power of two at least two more than the host count. 62 hosts still fit a /26, but 63 need a /25.

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

A /30 has 4 addresses and 2 usable, which works everywhere. A /31 has only 2 addresses, both usable on a router-to-router link under RFC 3021, and halves the space. In the example plan, /31 links would bring the total from 120 to 116 addresses. Use /31 where both ends support it.

What is the difference between VLSM and FLSM?

Fixed length subnet masking (FLSM) gives every subnet the same prefix, so a network is cut into 2, 4, 8 or more equal blocks; the equal split mode does this. VLSM sizes each subnet to its own need. FLSM is simpler to manage, VLSM wastes fewer addresses.

What if my subnets do not fit?

The calculator adds up the block sizes, which is exact for blocks placed largest first, and says how many addresses are missing and the smallest base network that would hold them. Then either use a larger base network, shrink a requirement that sits just over a power of two, or use /31 for router links.