Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Usable Hosts per Subnet
254
for a /24 subnet
Prefix length /24
Host bits 8
Total addresses (2^host bits) 256
Usable hosts (− network & broadcast) 254

What is the Hosts per Subnet Calculator?

This tool tells you how many usable host IP addresses fit inside an IPv4 subnet based on its CIDR prefix length (the /n after an address, such as 192.168.1.0/24). The prefix length is the number of bits used for the network portion; the remaining bits address individual hosts.

How to use it

Enter the prefix length between 0 and 32 and read off the usable host count. The result also shows the host bits and the total address count so you can see exactly how the number is derived.

The formula explained

An IPv4 address has 32 bits. With a prefix of p, the host portion is \(32 - p\) bits, which yields \(2^{(32 - p)}\) total addresses. Two of those are reserved: the network address (all host bits 0) and the broadcast address (all host bits 1). So the usable host count is $$\text{Usable Hosts} = 2^{\left(32 - p\right)} - 2$$

Advertisement
32-bit IPv4 address split into network bits and host bits by a CIDR prefix line
The prefix splits the 32-bit address into network bits and host bits, and host bits determine the host count.

Worked example

For a /24 subnet: host bits = \(32 - 24 = 8\), total addresses = \(2^8 = 256\), usable hosts = \(256 - 2 = \mathbf{254}\). A /30 (common for point-to-point links) gives $$2^2 - 2 = \mathbf{2}$$ usable hosts.

Bar of host addresses with first and last addresses crossed out as unusable
Two addresses are reserved: the network address and the broadcast address, hence the minus 2.

FAQ

Why subtract 2? The first address identifies the network itself and the last is the broadcast address, so neither can be assigned to a device in standard IPv4 networking.

What about /31 and /32? A /31 yields 0 usable hosts by the classic formula, though RFC 3021 allows both addresses on point-to-point links. A /32 represents a single host route. This calculator floors usable hosts at 0.

Does this apply to IPv6? No — this formula is for IPv4, which uses 32-bit addresses. IPv6 uses 128-bit addresses and does not reserve network/broadcast addresses the same way.

Last updated: