IPv4 Subnet Calculator
Enter an IPv4 address in CIDR notation to calculate the network address, the subnet mask and the number of usable hosts.
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.
- Subnet mask: the first (prefix length) bits are 1 and the rest are 0 (/24 is 255.255.255.0).
- Network address: the address AND the mask (the host part set to 0).
- Broadcast address: the host part set to all 1s.
- Total addresses: 2 to the power of (32 − prefix length).
- Usable hosts: total addresses − 2 (the network address and the broadcast address are excluded).
/31 and /32 are exceptions
- /31: there are only two addresses. Using "total − 2" would give 0 hosts, but on a point-to-point link (such as a connection between two routers) both addresses are used as host addresses. RFC 3021 says that on a point-to-point link with a 31-bit mask, the two addresses must be interpreted as host addresses (RFC 3021, section 2.1). This calculator shows 2 usable hosts for a /31 and does not show a separate network or broadcast address. Outside point-to-point links, this use may not be possible.
- /32: there is only one address, which identifies a single host (for example, a route to exactly one host). There is no separate network or broadcast address, and the usable host count is shown as 1.
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
- Only IPv4 is supported (not IPv6). A number with a leading zero (such as 010) can be read as octal, so it is ambiguous and is rejected (a single 0 is fine).
- If the address you enter is not the network address (for example, 192.168.1.10/24), the host part is set to 0 to find the network address.
- On a real network, fewer hosts may be usable than shown, for example because one address is used for the gateway (router) or some addresses are reserved.
- A /0 covers all IPv4 addresses, and its numbers are theoretical.
- To check an address or a number in binary or hexadecimal, use the Number Base Converter.
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.