Guide

How many hosts are in an IPv4 subnet?

Calculate total and usable IPv4 addresses from a CIDR prefix, including the correct treatment of /31 and /32.

by Tools in a Tab · Published on · Reviewed on

Short answer

An IPv4 address contains 32 bits. If a prefix reserves p bits for the network, 32 - p bits remain variable and the block contains:

total addresses = 2^(32 - p)

For /27, five bits remain: 2^5 = 32 addresses.

Quick table

Prefix Total Usable in a conventional subnet
/24 256 254
/27 32 30
/28 16 14
/29 8 6
/30 4 2
/31 2 2 on a point-to-point link
/32 1 1 host address or route

A conventional subnet reserves its first address as the network identifier and its last as the directed broadcast, so two are usually subtracted. Do not apply that rule mechanically to /31 and /32.

Special cases

RFC 3021 permits both addresses in a /31 on a point-to-point link: there are only two endpoints, so a separate directed broadcast is unnecessary. A /32 identifies one address and commonly appears as a host route.

The IPv4 calculator reports these cases explicitly rather than returning zero hosts from an out-of-context subtraction.

Capacity is not availability

The mathematical block size does not guarantee every address is assignable in every network. Gateways, provider reservations, infrastructure, and local policy reduce practical capacity. A /0 should not be read as billions of usable hosts on one LAN.

For planning, calculate the block first and then document design reservations. If you need at least 25 conventional hosts, /27 provides 30; /28 only 14.