An IPv4 prefix of length p leaves 32 − p host bits, giving 2 raised to that power addresses. A /24 therefore holds 256 addresses, of which 254 are usable: the first is the network address and the last is the broadcast address.
Halving the host space each time you add a bit means the usable count drops quickly. A /25 gives 126 hosts, a /26 gives 62 and a /30 gives just 2, which is why /30 became the traditional choice for point-to-point links. RFC 3021 later allowed /31 for that purpose, using both addresses.
Plan for growth before subnetting tightly. Renumbering a live network is far more disruptive than allocating a larger block at the start, and address space inside RFC 1918 private ranges is not scarce.
The formula
prefix- Mask length in bits, 0 to 32
32 − prefix- Number of host bits
− 2- Network address and broadcast address
block size- How far apart consecutive subnets sit
How to use this calculator
- Set the prefix length with the slider.
- Enter how many hosts you actually need.
- The gauge shows the usable host count.
- Compare the recommended prefix in the results.
Worked examples
The familiar /24
A /24 has 8 host bits, so 256 addresses and 254 usable, with a mask of 255.255.255.0. For 200 required hosts it is the smallest prefix that fits — a /25 would only offer 126.
Sizing a link network
Two routers need two addresses. A /30 provides exactly 2 usable from 4 addresses, wasting half the block, while a /31 provides both of its 2 addresses under RFC 3021. Across a hundred links that saves 200 addresses.
How to read your score
Frequently asked questions
Why subtract two addresses?
The all-zeros host address identifies the network and the all-ones address is the broadcast address for it. Neither can be assigned to an interface on a normal Ethernet segment.
When is a /31 or /32 valid?
A /31 is valid on point-to-point links under RFC 3021, where there is no broadcast to worry about. A /32 is a single host route, used for loopbacks and for advertising individual addresses.
How large should one broadcast domain be?
In practice a /24 is a comfortable ceiling and a /23 the point at which broadcast and ARP traffic starts to matter. Very large flat networks fail in ways that are hard to diagnose.
What is the wildcard mask for?
It is the inverse of the subnet mask, used in access control lists and routing policy on several vendors platforms. A /24 mask of 255.255.255.0 has a wildcard of 0.0.0.255.
Does IPv6 work the same way?
The arithmetic does, but the scale removes the pressure. A /64 is the standard segment size and holds 2 to the 64th addresses, so nobody counts hosts. Subnetting decisions there are about hierarchy, not capacity.
Prefix lengths and usable hosts
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /20 | 255.255.240.0 | 4,096 | 4,094 |
| /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 |
| /28 | 255.255.255.240 | 16 | 14 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 |
A /31 uses both addresses under RFC 3021; a /32 is a single host route.