Subnet Calculator: CIDR, Netmask and Usable Hosts
Type an address with a prefix length (192.168.1.0/24) or a netmask (255.255.255.0) and get the network address, broadcast address, usable host range, wildcard mask and host count in one go. Split a network into smaller subnets, or switch tabs to turn a start and end address into the fewest CIDR blocks. IPv6 prefixes work too.
How CIDR notation works
CIDR (Classless Inter-Domain Routing) writes a network as an address, a slash and a number. The number is the prefix length: how many of the address's 32 bits identify the network. The rest identify hosts inside it.
A /24 fixes the first 24 bits and leaves 8 for hosts, which is 2^8 = 256 addresses, and its netmask is 255.255.255.0. A /16 leaves 16 bits for hosts: 65,536 addresses. Every bit you add to the prefix halves the block.
For ordinary IPv4 subnets, usable hosts = 2^(32 − prefix) − 2. Two addresses are lost: the first is the network address and the last is the broadcast address.
Subnetting in your head: the block-size trick
You don't need binary for most everyday subnets. Take the netmask octet that isn't 255 or 0 and subtract it from 256. The result is the block size, and networks start at multiples of it.
Take 192.168.1.130/26. The mask is 255.255.255.192, so the block size is 256 − 192 = 64. Networks start at .0, .64, .128 and .192, which puts .130 in the .128 network. Its broadcast address is the next network minus one, .191, and its usable hosts run from .129 to .190: 62 of them.
Common IPv4 subnet sizes
| Prefix | Netmask | Total addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 512 | 510 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point link) |
| /32 | 255.255.255.255 | 1 | 1 (a single host) |
Private and special IPv4 ranges
| Range | Purpose |
|---|---|
| 10.0.0.0/8 | Private network (RFC 1918) |
| 172.16.0.0/12 | Private network (RFC 1918) |
| 192.168.0.0/16 | Private network (RFC 1918) |
| 100.64.0.0/10 | Shared address space for carrier-grade NAT |
| 127.0.0.0/8 | Loopback: this computer |
| 169.254.0.0/16 | Link-local: self-assigned when DHCP fails |
| 224.0.0.0/4 | Multicast |
Addresses in the private ranges aren't routed across the public internet, which is why millions of homes and offices can reuse the same ones.
Edge cases worth knowing
- /31: RFC 3021 lets both addresses of a /31 be used on a point-to-point link, so there's no network or broadcast address and two usable hosts.
- /32: a single address, used for host routes and firewall rules.
- /0: the whole address space, written 0.0.0.0/0 and used as the default route.
- Wildcard mask: the netmask with every bit flipped (0.0.0.255 for a /24). Routing protocols and access lists often use it instead of a netmask.
IPv6 prefixes
IPv6 addresses are 128 bits, and the prefix-length idea is the same. A /64 is the standard size for one network segment, because address autoconfiguration expects 64 bits for the interface identifier. Providers commonly hand a site a /48 or a /56, which holds 65,536 or 256 /64 networks. IPv6 has no broadcast address, so every address in a prefix is usable.
A /64 holds 2^64 addresses, roughly 18 quintillion, so IPv6 subnetting is about organising networks, not saving addresses.
Planning a subnet
- Count the devices you need today and add room for growth. Renumbering later is painful.
- Use different prefix lengths for different needs (variable-length subnet masking) instead of a /24 for everything.
- Keep subnets that talk to each other aligned so routes can be summarised.
- Write down each allocation. An address plan on paper prevents overlapping ranges.