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=232p2H = 2^{32-p} - 2

Enter your known values, leave one input blank, and solves for the missing one. Try different units for next level excitement!

Learning zone

An IPv4 prefix of pp bits leaves 32p32-p bits for hosts, giving 232p2^{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 imes62=2484 \ imes 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 imes14=22416 \ imes 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 imes10191.8 \ imes 10^{19} addresses per LAN, and nobody subtracts two.

Usable Hosts in an IPv4 Subnet
H=232p2H = 2^{32-p} - 2
Where
  • HH= Usable hosts (hosts)
  • pp= Prefix length (bits)