Connect via MCP →

Enter Calculation

Formula

Advertisement

Results

Usable Hosts per Subnet
254
for /24
Total addresses 256
Host bits 8
Prefix /24

What is the Subnet CIDR Calculator?

This calculator works out how many IP addresses fit inside an IPv4 subnet defined by a CIDR prefix (the number after the slash, like /24). It returns the total number of addresses, the number of host bits, and the number of usable host addresses you can actually assign to devices. It applies to standard IPv4 networking and is universal — no country or vendor specific rules.

How to use it

Enter the CIDR prefix length between 0 and 32. The prefix tells you how many leading bits are fixed for the network; the remaining bits are available for hosts. A smaller prefix (e.g. /16) means a larger network with more hosts, while a larger prefix (e.g. /30) means a tiny subnet.

The formula explained

An IPv4 address has 32 bits. The host portion is \(32 - \text{prefix}\) bits, so the total number of addresses is \(2^{(32 - \text{prefix})}\). In a normal subnet two addresses are reserved: the network address (all host bits 0) and the broadcast address (all host bits 1). Therefore usable hosts:

$$\text{Usable Hosts} = 2^{\left(32 - \text{Prefix }(/n)\right)} - 2$$

Note that /31 (point-to-point links, RFC 3021) and /32 (single host) are special cases where the standard \(-2\) does not apply.

Diagram of a 32-bit IPv4 address split into network bits and host bits by a CIDR prefix line
A CIDR prefix divides the 32 bits into network bits and host bits.

Worked example

For a /24 network: host bits = \(32 - 24 = 8\), total = \(2^8 = 256\) addresses. Subtract the network and broadcast addresses:

$$256 - 2 = 254 \text{ usable hosts}$$

— the classic size of a home or small-office LAN.

Bar chart comparing total addresses minus two reserved addresses to show usable hosts
Two addresses (network and broadcast) are subtracted to get usable hosts.

FAQ

Why subtract 2? The first address identifies the network and the last is the broadcast address, so neither can be assigned to a host.

What does /30 give? Total = \(4\), usable = \(2\) — perfect for a link between two routers.

Is this for IPv6? No. IPv6 uses a 128-bit address space and different host-counting conventions; this tool is IPv4 only.

Last updated: