Tools Guides
developer Free No signup

IP Subnet Calculator

Divide an IPv4 network into equal subnets or use VLSM to allocate subnets by host requirement.

Loading tool…

About this tool

Enter any IPv4 CIDR network (e.g. 192.168.0.0/16) and specify either the number of subnets you need or the required hosts per subnet; the calculator determines the optimal prefix length and lists every resulting subnet with its network address, broadcast address, usable host range, and subnet mask. The VLSM (Variable Length Subnet Masking) mode lets you name multiple sub-networks and specify each one's host requirement — subnets are then allocated from largest to smallest for maximum efficiency. An ASCII-art tree diagram visualises how the address space is carved up.

How to use

  1. 1 Enter the base network in CIDR notation (e.g. 10.0.0.0/8) in the Network field.
  2. 2 Choose 'Equal Subnets' mode and enter either the number of subnets or hosts per subnet — the other value is calculated automatically.
  3. 3 Or switch to 'VLSM' mode, add each subnet by name and required host count, then click 'Calculate'.
  4. 4 Review the subnet table and ASCII tree diagram; copy any value by clicking on it.

What this calculator does that a plain subnet lookup does not

A basic subnet tool tells you the mask, broadcast, and host range for a single network. This calculator goes a step further: it carves one base block into many subnets. You give it a starting network in CIDR form — say 192.168.0.0/16 — and it splits that space for you in one of two ways. In Equal Subnets mode every piece is the same size; in VLSM mode each piece is sized independently to fit the hosts it actually needs. Both modes produce a full table (network, first and last host, broadcast, mask, usable count) plus an ASCII allocation tree you can paste into documentation.

Equal subnets: splitting by count or by host requirement

In equal mode you choose one of two questions. "Divide into N subnets" borrows enough bits from the host portion to create at least N blocks: the tool computes bits = ceil(log2(N)) and adds them to the prefix. Asking for 4 subnets borrows 2 bits, so a /16 becomes four /18 networks. Alternatively, "Hosts per subnet" finds the smallest block whose usable count meets your figure, then reports how many such blocks fit in the base. Because subnet sizes are always powers of two, asking for 4 subnets and asking for 5 both borrow the same bits when 5 rounds up past a power-of-two boundary — the tool always rounds up so every request is satisfied.

A worked VLSM example

VLSM (Variable Length Subnet Masking) is where this tool earns its keep. Suppose you have 192.168.0.0/24 and three departments needing 50, 25, and 10 hosts. A naïve equal split into four /26 blocks (62 hosts each) wastes huge ranges on the small departments. The VLSM allocator instead sorts your requirements largest-first and packs them tightly:

DepartmentHosts neededAllocated blockUsable
LAN A50192.168.0.0/2662
LAN B25192.168.0.64/2730
LAN C10192.168.0.96/2814

Sorting largest-first is what keeps the blocks aligned: each subnet starts on a boundary that is a multiple of its own size, which is a hard rule of CIDR. The tool advances a cursor after every allocation and rounds it up to the next valid boundary, so you can never accidentally create overlapping or misaligned ranges. After placing all three, the space from 192.168.0.112 onward stays free for future growth — something the equal split would have squandered.

How the bit math works under the hood

Every address is treated as a single 32-bit integer. The mask for a /26 is 0xFFFFFFC0 (26 leading ones); ANDing an address with it yields the network, and the host count is 2^(32 − prefix) minus the two reserved addresses (network and broadcast). The allocator's "smallest block that fits" search starts at /30 and widens the prefix until the usable count clears your requirement, which is exactly how a network engineer sizes a subnet by hand — just instant and error-free.

Use cases

  • Office network design. Allocate right-sized subnets per floor, department, or VLAN without wasting a public or RFC 1918 block.
  • Studying for CCNA. VLSM problems are an exam staple; checking your hand-worked answer against the allocation table builds speed and confidence.
  • Cloud and lab planning. Carve a VPC CIDR into subnets for app, database, and management tiers before you provision anything.
  • Documentation. Copy the ASCII tree straight into a runbook or wiki so the next engineer sees the whole hierarchy at a glance.

Tips and common mistakes

  • Plan for the +2 overhead per subnet. Requesting "exactly 30 hosts" lands you in a /27 (30 usable) with zero spare. If the department might grow, ask for a few more.
  • Order does not matter in VLSM input — the tool sorts for you. You can list departments in any order; it always allocates largest-first to preserve alignment.
  • Watch for "Network space exhausted." If your requirements add up to more than the base block holds, the tool flags the subnet that no longer fits rather than silently overlapping.
  • The base can be any address in the block. Entering 192.168.0.37/24 is fine; the tool ANDs it down to the true 192.168.0.0 network first.
  • Equal mode rounds up. Asking for 3 subnets gives you 4 (two borrowed bits), because subnet counts are powers of two — the extra block is yours to keep in reserve.

Privacy

All of this is integer bit-math performed in your browser. The networks you enter are never transmitted or logged, and the calculator keeps working with no internet connection once the page has loaded.

Frequently Asked Questions

{# Alpine.js — self-hosted. (The previous jsdelivr CDN tag had a stale SRI integrity hash, so the browser refused to run it and window.Alpine was never defined — silently breaking every FAQ accordion and Alpine tool.) #}