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.
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.
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.