How to use
- Enter an IP address, such as 192.168.1.10. You can type the prefix too, like 10.0.0.5/8.
- Enter the prefix length (like 24) or the subnet mask (like 255.255.255.0).
- Read the network, broadcast, first and last usable host, host count, mask and wildcard. Open Show the binary to see the working.
IPv6 works the same way: enter an address such as 2001:db8::1 with a prefix like 64. Everything runs in your browser.
How subnetting works
An IPv4 address is 32 bits. The prefix (/n) says how many of the first bits name the network; the rest number the hosts (RFC 4632).
- Mask: n ones followed by zeros. /20 is 255.255.240.0.
- Network address: the IP AND the mask (host bits set to 0).
- Broadcast address: the network with every host bit set to 1.
- Usable hosts: 2^(32 − n) − 2, because the network and broadcast addresses can’t be given to hosts.
Two exceptions: a /31 point-to-point link uses both of its addresses (RFC 3021), and a /32 is a single address.
Example
172.16.5.4/20 in binary, with a bar after the first 20 bits:
Address 10101100.00010000.0000 | 0101.00000100
Mask 11111111.11111111.1111 | 0000.00000000
Network 10101100.00010000.0000 | 0000.00000000
So the network is 172.16.0.0/20, the broadcast is 172.16.15.255, and the 4,094 usable hosts run from 172.16.0.1 to 172.16.15.254.
Common prefixes
| Prefix | Subnet mask | Addresses | Usable hosts |
|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 |
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /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 |
| /32 | 255.255.255.255 | 1 | 1 |
Wildcard masks, private ranges and IPv6
- Wildcard mask: the subnet mask with every bit flipped (0.0.15.255 for /20), as used in Cisco access lists.
- Private ranges (RFC 1918): 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. 100.64.0.0/10 is shared carrier-grade NAT space (RFC 6598).
- IPv6 addresses are 128 bits. A /64, the usual subnet size, holds 18,446,744,073,709,551,616 addresses. Results use the short form from RFC 5952, such as 2001:db8::1.
Want to see an address as one binary or hex number? Convert each part with the number base converter.