Usable Hosts in an IPv4 Subnet

Also known as subnet size · hosts per subnet · CIDR host count · usable addresses · slash 24 hosts · subnet mask hosts

H=232−p−2H = 2^{32-p} - 2

Units aren’t used in this calculation — every value is a plain number.

Worked example: a /24 → 254 usable hosts — press Try an example to run it live, then adjust anything.

Enter your known values, leave one input blank, and solves for the missing one. Tap a variable’s symbol to see what it means, with a typical value.

Learning zone

Usable Hosts in an IPv4 Subnet explained

pH

An IPv4 prefix of pp bits leaves 32−p32-p bits for hosts, giving 232−p2^{32-p} addresses, of which two are unusable: the all-zeros address names the network itself and the all-ones address is the broadcast. So a /24 has 254 usable hosts, a /26 has 62, and a /30 has 2, which is why point-to-point links were traditionally /30 and wasted half their space.

The minus two is where the money goes when you subnet. Split a /24 into four /26s and you get 4×62=2484 \times 62 = 248 usable addresses instead of 254, because each subnet now pays its own network-and-broadcast tax. Split it into sixteen /28s and you are down to 16×14=22416 \times 14 = 224. Every additional boundary costs you two addresses, which is invisible on a whiteboard and painfully visible when a /24 will not fit the VLAN plan.

Two exceptions are worth knowing before you trust the formula blindly. RFC 3021 permits a /31 on point-to-point links by dropping the reservation entirely, so a /31 has two usable addresses rather than none, and most modern router platforms support it. A /32 is a single host route, used for loopbacks and for advertising a service address. And the whole thing is an IPv4 story: IPv6 subnets are /64 by convention, which is 1.8×10191.8 \times 10^{19} addresses per LAN, and nobody subtracts two.

Usable Hosts in an IPv4 Subnet formula

H=232−p−2H = 2^{32-p} - 2
Where
  • HH= Usable hosts (hosts)
  • pp= Prefix length (bits)

Missing one of these? Work it out first, then come back