How to Calculate IPv4 and IPv6 Subnets: Network, Mask and Host Range
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
- Enter an address with a prefix, like
192.168.1.10/24or2001:db8::/32. - Read the network address, range, counts and the kind of address.
- 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:
- Network: 192.168.1.0
- Broadcast: 192.168.1.255
- Usable hosts: 192.168.1.1 to 192.168.1.254
- 256 addresses, 254 usable hosts
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:
- 192.168.1.0/26
- 192.168.1.64/26
- 192.168.1.128/26
- 192.168.1.192/26
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
- Cloud providers reserve addresses. AWS, for example, reserves five addresses in each subnet, so a /28 has 11 usable addresses there, not 14. Check your provider's docs.
- Leave room to grow. Picking /24 subnets out of a /16 leaves space for 256 of them; tightly packed /28s look efficient until you need more.
- Avoid overlapping with home and office networks. Many routers default to 192.168.0.0/24 or 192.168.1.0/24. Using those in a VPN or VPC causes routing headaches.
- Membership checks in reviews: paste the block and the address and let the tool answer, rather than doing binary in your head.
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