Subnet Calculator

Enter an IPv4 or IPv6 address with a CIDR prefix and get the network address, broadcast, usable host range, and more, instantly.

Files never leave your device
Network address
192.168.1.0
Broadcast address
192.168.1.255
First usable host
192.168.1.1
Last usable host
192.168.1.254
Usable hosts
254
Total addresses
256
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
Prefix length
/24
Scope
Private
Class
Class C

What a mask actually does

A subnet mask marks which bits of an address are the network's and which are the host's: AND the address with the mask and what's left is the network address, with every host bit zeroed. Feed in 192.168.1.0/24 and the mask is 255.255.255.0 — the top 24 bits are network, the bottom 8 are host — giving network 192.168.1.0, broadcast 192.168.1.255, and a usable host range of 192.168.1.1 through 192.168.1.254: 254 addresses, since the network and broadcast addresses themselves aren't hosts.

Splitting one block into smaller ones

CIDR notation just means the prefix length can be anything, not only the classful defaults, so the same /24 can be cut into four equal /26s. Take 192.168.1.100/26: the mask is 255.255.255.192, and that address falls in the block running from 192.168.1.64 to 192.168.1.127 — network 192.168.1.64, broadcast 192.168.1.127, 62 usable hosts. Three more /26s from the same /24 sit alongside it, each with its own 62 hosts, carved out of address space that used to come in one size only.

Two prefixes where the usual formula breaks

Usable hosts is normally 2^(32 − prefix) − 2 — total addresses minus one for the network and one for the broadcast. That formula gives a nonsense answer at the two longest prefixes, which is exactly why they're handled as special cases. A /31 has no broadcast at all: RFC 3021 lets both of its two addresses serve as hosts on a point-to-point link, so usable hosts is 2, not 0. A /32 is a single address serving as a route to one specific host — the address is the host — so usable hosts is 1, not the formula's -1.

Tip: Seeing a /31 on a link between two routers isn't a misconfiguration — it's the RFC 3021 case, deliberately sized to waste neither address on a network/broadcast pair that a two-host link has no use for.

From fixed classes to a chosen prefix

Before CIDR, an address's class was read off its first octet and fixed how large its network was: 1–127 was Class A with an implied /8 (16,777,214 hosts), 128–191 was Class B with an implied /16 (65,534 hosts), and 192–223 was Class C with an implied /24 (254 hosts) — 192.168.1.1 falls in that last range. CIDR (RFC 1519) broke the link between an address's leading bits and its network size, letting a 192.168.x.x address run at /26 or /28 just as easily as the classful /24 it used to be stuck with — the four-way split above only exists because CIDR made the prefix a free choice instead of a fixed one.

ClassFirst octetClassful prefixHosts
A1–127/816,777,214
B128–191/1665,534
C192–223/24254
D224–239— (multicast)n/a
E240–255— (reserved)n/a

IPv6: no broadcast, and far more room than it looks

An IPv6 address compresses for reading rather than for storage: 2001:0db8:0000:0000:0000:ff00:0042:8329 writes as 2001:db8::ff00:42:8329 once every group's leading zeros are dropped and the single longest run of all-zero groups collapses to :: — never a run of just one zero group, and never more than one :: in the same address. There's no broadcast address to compute either; the calculator reports a last address instead, the top of the range. And the range itself dwarfs IPv4: a /64, the size routinely handed to a single LAN, holds 2^64 addresses — 18,446,744,073,709,551,616 of them — more than every IPv4 address that has ever existed, inside one home network.

Tip: A /32 in IPv6 is nothing like a /32 in IPv4 — it's a typical allocation handed to an entire ISP, not a single host route. IPv4 and IPv6 prefixes of the same number describe very different amounts of address space; don't carry IPv4 intuition about a prefix's size across to IPv6.

Frequently asked questions

What does a subnet mask actually do?
It marks which bits of an address belong to the network and which belong to the host: AND the address with the mask and what's left is the network address, with every host bit zeroed out. Feed in `192.168.1.0/24` and the mask is `255.255.255.0` — the top 24 bits are network, the bottom 8 are host — giving network `192.168.1.0`, broadcast `192.168.1.255`, and a usable host range of `192.168.1.1` through `192.168.1.254`: 254 addresses, since the network and broadcast addresses themselves aren't hosts.
Why do usable-host counts stop following `2^n − 2` at /31 and /32?
Because that formula assumes a network address and a broadcast address both exist and both need subtracting, and at the two longest prefixes neither assumption holds. A `/31` has no broadcast at all — RFC 3021 lets both of its two addresses serve as hosts on a point-to-point link, so usable hosts is 2, not the formula's 0. A `/32` is a single address acting as a route to one specific host — the address *is* the host — so usable hosts is 1, not the formula's -1.
How did CIDR replace the old address classes?
Before CIDR, an address's class was read straight off its first octet and fixed how large its network had to be: 1–127 was Class A with an implied /8, 128–191 was Class B with an implied /16, and 192–223 was Class C with an implied /24. CIDR (RFC 1519) broke that link, letting the prefix length be chosen independently of the address's leading bits — the same `192.168.x.x` range that used to be stuck at /24 can now be split into four /26s, eight /27s, or left as one /24, depending on what the network actually needs.
What changes when I switch this tool from IPv4 to IPv6?
The math changes shape as much as the addresses do. IPv6 has no broadcast address, so there's a last address in the range instead of a broadcast; every count is a `bigint` rather than a plain number, because a `/64` alone already holds more addresses than a JavaScript number can represent exactly; and there's no concept of a legacy class, since IPv6 was designed with CIDR-style prefixes from the start.
Why does `2001:0db8:0000:0000:0000:ff00:0042:8329` compress down to `2001:db8::ff00:42:8329`?
Two separate rules, applied together. Each group drops its own leading zeros first — `0db8` becomes `db8`, `0042` becomes `42` — and then the single longest run of consecutive all-zero groups collapses to `::`. Here that run is the three zero groups in positions three through five; a run of just one zero group is never collapsed, since `::` has to save more than it costs to write.
What's the difference between the subnet mask and the wildcard mask?
They're bitwise complements of the same 32 bits. The mask marks network bits with 1s and host bits with 0s — `255.255.255.192` for a /26. The wildcard mask flips that: host bits become 1s and network bits become 0s — `0.0.0.63` for the same /26. Masks appear on interfaces and routes; wildcard masks show up in access-control-list rules, where a 1 bit means 'ignore this bit' rather than 'match it'.
Can I type a dotted mask like `255.255.255.0` instead of a prefix length?
Yes — `192.168.1.10/255.255.255.0` and `192.168.1.10/24` parse to the same result. Type whichever one you have in front of you; the tool reads a dotted mask back to its prefix length automatically, as long as its one-bits form a contiguous run from the top, the only shape a real subnet mask can take.