How it works
An IPv4 address is a 32-bit number, written as four 8-bit octets. The prefix says how many leading bits identify the network. The network address has all host bits set to 0 and the broadcast address has them all set to 1; the addresses in between are usable hosts. So a /24 has 28 = 256 addresses and 254 usable hosts.
In general a /n block has 232−n addresses. The subnet mask is the same prefix written as an address: n one-bits followed by zeros. To find the network, a router ANDs the address with the mask.
Worked example
Take 203.0.113.77/27. A /27 mask is 27 ones, so the last octet of the mask is 11100000 = 224, giving 255.255.255.224. Only the last octet changes:
Address 77 01001101 Mask 224 11100000 AND --------- Network 64 01000000 -> 203.0.113.64 Broadcast 95 01011111 -> 203.0.113.95 (host bits all 1)
The calculator shows network 203.0.113.64/27, usable hosts 203.0.113.65 to 203.0.113.94 (30 hosts out of 32 addresses), wildcard mask 0.0.0.31, and the address type Documentation (TEST-NET-3), because 203.0.113.0/24 is reserved for examples like this one.
CIDR prefix cheat sheet
| Prefix | Subnet mask | Addresses | Usable hosts |
|---|---|---|---|
| /32 | 255.255.255.255 | 1 | 1 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point links) |
| /30 | 255.255.255.252 | 4 | 2 |
| /29 | 255.255.255.248 | 8 | 6 |
| /28 | 255.255.255.240 | 16 | 14 |
| /27 | 255.255.255.224 | 32 | 30 |
| /26 | 255.255.255.192 | 64 | 62 |
| /25 | 255.255.255.128 | 128 | 126 |
| /24 | 255.255.255.0 | 256 | 254 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
/31 and /32
A /32 is a single address, used for host routes, loopback interfaces and firewall rules that match one IP. A /31 has two addresses and, under RFC 3021, both are usable on point-to-point links, because a link between two routers needs no network or broadcast address. The calculator follows this, so both show no broadcast address and count every address as usable.
Subnetting a network
Splitting a block means borrowing host bits for the network. Each extra prefix bit doubles the number of subnets and halves their size. Choosing /26 in Split into for 192.168.1.0/24 gives four subnets of 62 hosts each:
| Subnet | First host | Last host | Broadcast |
|---|---|---|---|
| 192.168.1.0/26 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 |
| 192.168.1.64/26 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 |
| 192.168.1.128/26 | 192.168.1.129 | 192.168.1.190 | 192.168.1.191 |
| 192.168.1.192/26 | 192.168.1.193 | 192.168.1.254 | 192.168.1.255 |
To size a subnet, add two to the hosts you need (for network and broadcast) and round up to a power of two. Fifty hosts need 64 addresses, which is a /26. Very large splits list the first 1,024 subnets.
Private address ranges
10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are reserved for private networks (RFC 1918) and are not routed on the internet. The calculator also flags loopback, link-local, carrier-grade NAT and documentation ranges.
Note that 172.16.0.0/12 runs from 172.16.0.0 to 172.31.255.255, so 172.32.0.1 is a public address. The carrier-grade NAT range, 100.64.0.0/10 (RFC 6598), is shared ISP space and should not be used inside your own network either.
Cloud networks
AWS, Azure and Google Cloud reserve some addresses in every subnet (AWS and Azure reserve 5), so usable hosts in a cloud VPC subnet are a few fewer than shown here.
Common mistakes
- Typing a host address as the network.
192.168.1.10/24is a host in192.168.1.0/24. Many firewalls and cloud consoles reject a CIDR block whose host bits are not zero, so use the Network (CIDR) value. - Overlapping ranges. Two VPCs or sites using the same private block cannot be peered or joined by VPN without NAT. Plan ranges before you need to connect them.
- Non-contiguous masks. A mask such as
255.0.255.0is invalid; the one-bits must all come first. The calculator rejects it, and also rejects octets with leading zeros like192.168.01.1, which some systems read as octal.