An IP subnet calculator for IPv4 and IPv6
This subnet calculator takes an IP address with its mask, written in CIDR notation (/24) or dotted decimal (255.255.255.0), and shows everything you need to set up a router, a server, a firewall rule or a VLAN: network address, broadcast address, first and last usable host, number of hosts, wildcard mask and the binary form. It is handy when you are studying for a networking certification, planning an office network or reading a cloud provider's VPC settings.
Everything is calculated in your browser; no address is sent anywhere.
How to use it
- On the “IPv4” tab, type into “IP address and mask”, for example
10.20.30.40/27or172.16.5.4 255.255.240.0. If you type an address on its own, pick the prefix in the “Mask” list. - Only know how many machines you need to connect? Fill in “Hosts needed” and the tool picks the smallest network that fits.
- The “Subnetting” tab splits a network into “Equal subnets” or “Different sizes (VLSM)” and lists every range in a table.
- The “IP in a network” tab answers “Is this IP in this network?” and aggregates a list of networks into a route summary.
- The “IPv6” tab gives the expanded and compressed forms of a prefix, its first and last address and its size. “Prefixes /8 to /32” is a ready-made CIDR chart.
Worked examples
A small office subnet. For 10.20.30.40/27 the network address is 10.20.30.32 and the broadcast address is 10.20.30.63. Usable hosts run from 10.20.30.33 to 10.20.30.62, which is 30 addresses. The mask is 255.255.255.224 and the wildcard is 0.0.0.31. The type shown is “Private (RFC 1918)”.
A dotted-decimal mask. 172.16.5.4 255.255.240.0 is a /20: network 172.16.0.0, broadcast 172.16.15.255, 4,096 addresses and 4,094 usable hosts.
Equal subnets. Splitting 10.0.0.0/16 into 8 gives eight /19 networks of 8,190 hosts each: 10.0.0.0/19, 10.0.32.0/19, 10.0.64.0/19 and so on up to 10.0.224.0/19. Ask for 6 subnets of 192.168.1.0/24 and you get 8 networks of /27, because subnets always come in powers of 2.
VLSM. For 60, 28, 12 and 2 hosts inside 172.16.0.0/24, the table gives 172.16.0.0/26 (62 hosts), 172.16.0.64/27 (30), 172.16.0.96/28 (14) and 172.16.0.112/30 (2) for the link between two routers. Free space: 172.16.0.116/30, 172.16.0.120/29 and 172.16.0.128/25.
| Prefix | Mask | Usable hosts |
|---|---|---|
| /16 | 255.255.0.0 | 65,534 |
| /24 | 255.255.255.0 | 254 |
| /27 | 255.255.255.224 | 30 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2 (RFC 3021) |
How subnet maths works
The prefix length says how many bits, counted from the left, belong to the network. The network address is the IP ANDed with the mask; the broadcast address sets every host bit to 1. A /n network holds 2^(32 − n) addresses, two of which are reserved, so a /27 has 2^5 − 2 = 30 hosts. There are two exceptions: a /31 is used on point-to-point links and both of its addresses are usable, and a /32 is a single host.
The class (A, B or C) is shown for reference and marked obsolete: since 1993 only the prefix matters. The tool also flags special ranges such as loopback 127.0.0.0/8, link-local 169.254.0.0/16 (a machine that got no DHCP lease) and 100.64.0.0/10, the shared space some broadband providers use for carrier-grade NAT.
In IPv6, 2001:db8:0:0:1:0:0:1/64 is compressed to 2001:db8::1:0:0:1. Its /64 runs from 2001:db8:: to 2001:db8::ffff:ffff:ffff:ffff, which is 2^64 ≈ 1.845 × 10^19 addresses.
Frequently asked questions
What is a wildcard mask?
It is the bitwise inverse of the subnet mask: 255.255.255.224 becomes 0.0.0.31. You will see it in access control lists and OSPF network statements on many routers.
Why does a /24 have 254 hosts, not 256?
The first address identifies the network and the last one is the broadcast address. Neither can be given to a device.
How do I check whether an IP belongs to a subnet?
Open “IP in a network”. 10.1.2.3 is in 10.0.0.0/8, which runs from 10.0.0.0 to 10.255.255.255, so the tool answers “Yes”.
Which IPv6 formats are accepted?
Full addresses, shortened ones with “::”, missing leading zeros and an IPv4 address at the end (::ffff:192.0.2.1). Results follow RFC 5952: lower case, no leading zeros, and “::” on the longest run of zero groups.