IPv4 Subnet Calculator

Enter an IPv4 address in CIDR notation to calculate the network address, the subnet mask and the number of usable hosts.

Enter four numbers (0 to 255) separated by dots, then a slash and the prefix length (0 to 32). IPv6 is not supported.
Subnet results
Subnet results
Network address—
Subnet mask—
Subnet mask (binary)—
Broadcast address—
Total addresses—
Usable hosts—
Usable host range—
The value copied is the network address and the prefix length, such as 192.168.1.0/24.

How subnet calculation works

The "/24" in CIDR notation is the prefix length: how many bits at the start of the address belong to the network part. An IPv4 address has 32 bits, so the remaining (32 − prefix length) bits are the host part. CIDR notation is specified in RFC 4632.

/31 and /32 are exceptions

Examples

Input Network Mask Total Usable hosts
192.168.1.10/24 192.168.1.0 255.255.255.0 256 254 (.1 to .254)
10.0.0.0/30 10.0.0.0 255.255.255.252 4 2 (.1 and .2)
10.0.0.0/31 two addresses (.0 and .1) 255.255.255.254 2 2 (point-to-point link)
10.0.0.5/32 10.0.0.5 255.255.255.255 1 1 (a single address)
172.16.0.0/16 172.16.0.0 255.255.0.0 65,536 65,534

Prefix lengths and subnet masks

Prefix length Subnet mask Total addresses
/8 255.0.0.0 16,777,216
/16 255.255.0.0 65,536
/24 255.255.255.0 256
/25 255.255.255.128 128
/26 255.255.255.192 64
/27 255.255.255.224 32
/28 255.255.255.240 16
/29 255.255.255.248 8
/30 255.255.255.252 4

Notes

Frequently asked questions

Why are usable hosts "total − 2"?

The address with the host part all 0 is the network address, which names the network itself. The address with the host part all 1s is the broadcast address, used to send to everyone on the network. Neither is given to a host.

Can I use a /31 on an ordinary network?

On a point-to-point link (a connection between two devices), yes. For a network with three or more devices you need the network and broadcast addresses, so use /30 or a shorter prefix (a larger network).

What if I only know the subnet mask?

Convert it to a prefix length first (255.255.255.0 is /24 and 255.255.255.252 is /30). The table above can help.