What It Is
The Usable IP Address Count Calculator tells you how many host addresses you can actually assign within an IPv4 subnet of a given prefix length (CIDR notation, such as /24 or /16). This is essential when planning subnets, sizing DHCP scopes, or estimating capacity for a network segment.
How to Use It
Enter the subnet prefix length — the number after the slash in CIDR notation (0 to 32). Press calculate and the tool returns the total addresses in the block, the number of host bits, and the count of usable addresses after reserving the network and broadcast addresses.
The Formula Explained
An IPv4 address has 32 bits. The prefix length p fixes the network portion, leaving 32 − p host bits. The total number of addresses is therefore \(2^{32 - p}\). In a standard subnet the first address is reserved as the network identifier and the last as the broadcast address, so the usable count is:
$$\text{usable} = 2^{\,32 - p} - 2$$
Note: a /31 point-to-point link (RFC 3021) and a /32 host route are special cases where the classic subtraction does not apply.
Worked Example
For a /24 subnet: host bits = 32 − 24 = 8, total = \(2^8 = 256\), and usable = 256 − 2 = 254 addresses. A /16 yields:
$$2^{16} - 2 = 65{,}534$$
usable hosts.
Usable Hosts by Prefix Length (/0 to /32)
For an IPv4 subnet with prefix length \(p\), there are \(32-p\) host bits. The classic formula is \(\text{usable} = 2^{32-p} - 2\), where the two subtracted addresses are the network address and the broadcast address. Two prefixes are special cases: /31 and /32 (see the notes below the table).
| Prefix | Subnet mask | Host bits | Total addresses (2^(32-p)) | Usable hosts |
|---|---|---|---|---|
| /0 | 0.0.0.0 | 32 | 4,294,967,296 | 4,294,967,294 |
| /1 | 128.0.0.0 | 31 | 2,147,483,648 | 2,147,483,646 |
| /2 | 192.0.0.0 | 30 | 1,073,741,824 | 1,073,741,822 |
| /3 | 224.0.0.0 | 29 | 536,870,912 | 536,870,910 |
| /4 | 240.0.0.0 | 28 | 268,435,456 | 268,435,454 |
| /5 | 248.0.0.0 | 27 | 134,217,728 | 134,217,726 |
| /6 | 252.0.0.0 | 26 | 67,108,864 | 67,108,862 |
| /7 | 254.0.0.0 | 25 | 33,554,432 | 33,554,430 |
| /8 | 255.0.0.0 | 24 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 23 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 22 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 21 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 20 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 19 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 18 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 17 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 16 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 15 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 14 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 13 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 12 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 11 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 10 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 9 | 512 | 510 |
| /24 | 255.255.255.0 | 8 | 256 | 254 |
| /25 | 255.255.255.128 | 7 | 128 | 126 |
| /26 | 255.255.255.192 | 6 | 64 | 62 |
| /27 | 255.255.255.224 | 5 | 32 | 30 |
| /28 | 255.255.255.240 | 4 | 16 | 14 |
| /29 | 255.255.255.248 | 3 | 8 | 6 |
| /30 | 255.255.255.252 | 2 | 4 | 2 |
| /31 | 255.255.255.254 | 1 | 2 | 2 (RFC 3021; classic formula gives 0) |
| /32 | 255.255.255.255 | 0 | 1 | 1 (single host route; classic formula gives -1) |
Special cases:
- /0 covers the entire IPv4 space; the classic formula gives 4,294,967,294.
- /30 has 4 addresses and 2 usable hosts, a traditional choice for point-to-point links.
- /31 has 2 addresses. Under RFC 3021 both are usable on point-to-point links, so the usable count is 2 instead of the 0 the classic formula gives.
- /32 is a single address, used as a host route or loopback. The classic formula would give -1, but the practical count is 1.
Choosing a Prefix: Common Scenarios
Pick the longest prefix (smallest subnet) whose usable count is at least the number of hosts you need, and leave room for growth and for gateway or infrastructure addresses. Spare capacity below is usable hosts minus required hosts.
| Scenario | Hosts required | Smallest prefix that fits | Usable hosts | Spare capacity |
|---|---|---|---|---|
| Point-to-point link (classic) | 2 | /30 | 2 | 0 |
| Point-to-point link (RFC 3021) | 2 | /31 | 2 | 0 |
| Small office | ~50 | /26 | 62 | 12 |
| VLAN | ~200 | /24 | 254 | 54 |
| Larger segment | ~500 | /23 | 510 | 10 |
| Large campus | ~4,000 | /20 | 4,094 | 94 |
Example: for 50 hosts, a /27 gives \(2^{5}-2 = 30\), which is too few. A /26 gives \(2^{6}-2 = 62\), which fits. Each step one bit shorter doubles the address count, so spare capacity can grow quickly. Plan for growth, but avoid oversizing subnets.
Key Terms
- CIDR (Classless Inter-Domain Routing)
- An addressing method that describes a network as an address plus a prefix length (for example 192.168.1.0/24) instead of fixed classes A, B and C.
- Prefix length
- The number of leading bits, from 0 to 32 in IPv4, that identify the network. The remaining bits identify hosts.
- Subnet mask
- A 32-bit value written in dotted decimal, with ones for the network bits and zeros for the host bits. A /24 is 255.255.255.0.
- Network address
- The first address in a subnet, with all host bits set to 0. It identifies the subnet and is not assigned to a host in the classic model.
- Broadcast address
- The last address in a subnet, with all host bits set to 1. It reaches all hosts on the subnet and is not assigned to a single host in the classic model.
- Host bits
- The bits left over after the prefix, equal to \(32 - p\). They determine the subnet size: \(2^{32-p}\) total addresses.
- Usable host
- An address that can be assigned to an interface. In the classic model this is the total minus the network and broadcast addresses: \(2^{32-p} - 2\).
- Point-to-point link (RFC 3021)
- A link between exactly two devices. RFC 3021 allows a /31 on such links, so both addresses are usable and no network or broadcast address is reserved.
- Host route
- A /32 route that matches exactly one IPv4 address, commonly used for loopback interfaces and for routing to a single device.
FAQ
Why subtract 2? One address identifies the network itself and one is the broadcast address; neither can be assigned to a host.
What about /31 subnets? RFC 3021 allows /31 to use both addresses for point-to-point links, giving 2 usable addresses.
Does this work for IPv6? No — this tool is for IPv4. IPv6 uses 128-bit addresses and different host-reservation conventions.