How to Calculate IPv4 and IPv6 Subnets: Network, Mask and Host Range

By Alok Singh · Published

Setting up a home lab, writing a cloud VPC plan, or answering "is 10.0.5.200 inside 10.0.4.0/23?" in a code review: subnet maths comes up just often enough to be annoying and rarely enough that nobody remembers it. Subnet calculator takes an address and prefix and gives you the network, range, counts, address type, membership checks and splits.

Steps

  1. Enter an address with a prefix, like 192.168.1.10/24 or 2001:db8::/32.
  2. Read the network address, range, counts and the kind of address.
  3. Add a second address to see whether it's inside the block, or split the block into smaller prefixes.

IPv4 essentials, with an example

Take 192.168.1.10/24:

You can write the prefix as /24 or as a dotted mask like 255.255.255.0. A valid mask is a run of 1-bits followed by 0-bits, so 255.255.0.255 is rejected.

Two special cases worth knowing: a /32 is a single address (common in firewall rules and routes), and a /31 has two addresses that are both usable on a point-to-point link, so no network or broadcast address is wasted.

Address types

The tool names what kind of address you typed: private (10/8, 172.16/12, 192.168/16), loopback, link-local, shared (the 100.64/10 range used by carrier-grade NAT), multicast or public. Handy when someone asks why their "public" IP starts with 100.

IPv6

IPv6 has no broadcast, and the host count is just the address count. The range runs from the network address to the last address in the block. 2001:db8:1::/64 is a documentation prefix with 2^64 addresses, which is why IPv6 people never argue about how many hosts fit in a subnet.

Splitting a block

Pick a longer prefix and the tool lists the resulting blocks. A /24 split into /26s gives four blocks of 64 addresses:

That's the bread and butter of VPC design: one /16 for the VPC, then /24s or /20s per subnet and availability zone.

Practical tips

Privacy

The page states everything runs locally and addresses you type stay in the tab. There are Google ads on the page, as on the rest of the site.

FAQ

What's in 192.168.1.10/24? Network .0, broadcast .255, hosts .1 to .254: 256 addresses, 254 hosts.

Why does a /31 have two usable hosts? It's meant for point-to-point links, where no broadcast is needed.

How does IPv6 count hosts? Hosts equal addresses; there's no broadcast.

Can I split a block? Yes, choose a longer prefix to list the sub-blocks.

Next time subnet maths comes up, open Subnet calculator.

— Alok Kumar Singh


← All guides