IP Subnet Calculator
Enter an IPv4 address with a CIDR prefix or dotted mask to get the network address, broadcast address, usable host range, host count, wildcard mask, and class. A separate IPv6 section expands or compresses any address and shows its prefix range.
IPv4
IPv6
How subnetting works
An IPv4 address is 32 bits, split into a network portion and a host portion by a mask. Every host on the same subnet shares the network portion; the host portion identifies the individual device. CIDR notation (like /24) states how many leading bits are the network portion — the same information a dotted mask like 255.255.255.0 encodes. IPv6 drops broadcast addresses and classes entirely and uses prefix length the same way CIDR does for IPv4, just across 128 bits instead of 32.
How it’s calculated
Network address = IP AND mask. Broadcast address = network OR (NOT mask). Usable hosts = 2(32−prefix) − 2 (subtracting the network and broadcast addresses), except /31 and /32 which are special-cased per RFC 3021. Wildcard mask = NOT mask (mask bits inverted). Class is derived from the first octet (A: 1–126, B: 128–191, C: 192–223, D: 224–239 multicast, E: 240–255 reserved). Private ranges follow RFC 1918 (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) plus loopback (127.0.0.0/8) and link-local (169.254.0.0/16). IPv6 expansion pads each of the 8 groups to 4 hex digits and replaces the longest run of zero groups with “::” for the compressed form.
This tool models addressing math only — it doesn’t reach your network or verify a subnet is actually routed or configured that way.
Worked example
192.168.1.10/24: network mask 255.255.255.0 puts the network address at 192.168.1.0 and broadcast at 192.168.1.255, giving a usable range of 192.168.1.1 – 192.168.1.254 (254 hosts), wildcard mask 0.0.0.255, Class C, and it’s a private address (RFC 1918). For IPv6, 2001:db8::1/64 expands to 2001:0db8:0000:0000:0000:0000:0000:0001 with the /64 network spanning 2001:db8:: through 2001:db8::ffff:ffff:ffff:ffff.
IPv4 mask reference, /0 through /32
Every prefix length maps to a fixed mask and host count. The table below lists the pattern used across the whole range: /8 through /15 fall in the historical Class A block, /16 through /23 in Class B, and /24 through /30 in Class C, with /31 and /32 reserved for point-to-point links and single-host routes. Full mask-and-host tables run long, so here are the ranges seen most often: /8 = 255.0.0.0 (16,777,214 hosts, Class A), /16 = 255.255.0.0 (65,534 hosts, Class B), /24 = 255.255.255.0 (254 hosts, Class C), /27 = 255.255.255.224 (30 hosts), /29 = 255.255.255.248 (6 hosts), /30 = 255.255.255.252 (2 hosts, common for router links), /31 = 255.255.255.254 (0 by the standard formula, but 2 usable under RFC 3021), and /32 = 255.255.255.255 (a single host route). Enter any prefix from 0 to 32 above to see its exact mask, wildcard, and host count.
Common mistakes
- Assigning the network or broadcast address to a device — both are reserved and unusable as host addresses.
- Confusing a private IP (10.x, 172.16–31.x, 192.168.x) with a public, internet-routable one; private addresses only work behind NAT.
- Expecting IPv6 to have a broadcast address — it uses multicast and anycast instead, and prefix length alone doesn’t reserve two addresses the way IPv4 masks do.
- Forgetting that /31 and /32 don’t follow the normal “usable = total − 2” rule.
Where it is used
- Planning subnets for offices, VLANs, or cloud VPCs before provisioning.
- Troubleshooting whether two devices are on the same subnet.
- Firewall and ACL rule-writing, where wildcard masks are used directly (e.g., Cisco access lists).
- Verifying whether an address is public-facing or behind NAT.
Frequently asked questions
What's the difference between network address and broadcast address?
The network address is the first address in a subnet (all host bits zero) and identifies the subnet itself — it’s never assigned to a device. The broadcast address is the last address (all host bits one) and reaches every host on that subnet at once. Usable addresses are everything between the two.
How do I convert a subnet mask to a CIDR prefix?
Count the number of leading 1 bits in the mask. 255.255.255.0 in binary is 11111111.11111111.11111111.00000000 — 24 leading ones — so it’s /24. This calculator accepts either a CIDR number or a dotted mask and converts automatically.
What are IP classes A, B, and C?
Classes are a pre-CIDR (1980s) scheme based on the first octet: Class A is 1–126 (huge networks, default /8), Class B is 128–191 (default /16), and Class C is 192–223 (default /24). Modern networks use CIDR instead, but the class label is still useful shorthand and this calculator reports it.
Why do /31 and /32 show zero usable hosts?
The usable-host formula subtracts 2 for the network and broadcast address, which needs at least 2 host bits. A /31 (2 addresses) and /32 (1 address) don’t have room for both — RFC 3021 allows /31 as a special point-to-point link using both addresses as hosts, and /32 is used to identify a single address, such as a loopback or router interface.
How is this different for IPv6?
IPv6 has no broadcast address or address classes — it uses prefix length (like /64) purely to mark the network portion, with the remaining bits for host or subnet addressing. Because IPv6 addresses are 128 bits, they’re normally shortened with “::” to skip runs of zero groups; the calculator shows both the compressed and fully expanded forms.