CIDR notation like 10.0.0.0/24 is a compact way to describe a block of IP addresses, but turning it into network, broadcast and usable-host counts trips people up. This guide breaks down the math.
What CIDR notation means
The /N suffix is the number of leading bits that identify the network. The remaining bits identify hosts within it. A /24 has 24 network bits and 8 host bits, giving 2^8 = 256 total addresses.
Network, broadcast and usable hosts
The first address in the block (all host bits zero) is the network address and identifies the subnet. The last address (all host bits one) is the broadcast address. Everything in between is usable by hosts, so a /24 yields 254 usable addresses, not 256.
Counting hosts from the prefix
For a /N with 32 - N host bits, the total address count is 2^(32 - N), and the usable count is that minus 2 for the network and broadcast addresses. A /27 therefore has 2^5 = 32 addresses and 30 usable hosts.
Special cases: /31 and /32
A /32 describes a single host with no network or broadcast address. A /31 (RFC 3021) is a special case for point-to-point links where both addresses in the two-address block are usable as hosts.