Skip to content
Calculator Collection

IP Subnet Calculator

Compute the number of usable hosts in an IPv4 subnet from its CIDR prefix length. A /24 gives 254 usable hosts, a /30 gives 2, and so on.

Last updated: September 2026

Compare 3 scenarios
Fill in the required fields to see your result.

Compare with similar

About this calculator

An IPv4 address is 32 bits. A CIDR prefix like /24 means the first 24 bits identify the network and the last 32 − 24 = 8 bits identify the host inside that network. The total addresses in the block are 2^(32 − prefix); two of those are reserved — the network address (all-zero host bits) and the broadcast address (all-one host bits) — so the usable count is 2^(32 − prefix) − 2.

This subtraction of 2 is the convention for classical IPv4 subnets and is what most exam questions and network-planning tools expect. Point-to-point links use /31 specifically to avoid the −2 penalty (RFC 3021 blesses that), and a /32 addresses exactly one interface, so both cases are edge conditions where the −2 formula is either bent or ignored.

Common sizes: /24 = 254 hosts (a classic 'Class C' equivalent), /23 = 510, /22 = 1022, /30 = 2 (four addresses, two usable, typical for a router-to-router link), /29 = 6 (small server VLAN).

How to use

Example — plan a /24 subnet. Enter 24. Result = 2^(32 − 24) − 2 = 2^8 − 2 = 256 − 2 = 254 usable hosts. That is your addressable device count on that VLAN. Reserve one for the gateway, one for DHCP relay if used, and the rest are free for endpoints. Example — small point-to-point link. Enter 30. Result = 2^2 − 2 = 2 usable hosts. That is enough for the two router interfaces on either end of a WAN link, which is exactly what /30 is used for in ISP designs. If you want to skip the −2 waste, RFC 3021 says a /31 works for the same job.

Frequently asked questions

Why subtract 2?

In a classical IPv4 subnet, the first address (all-zero host bits) is the network identifier and the last address (all-one host bits) is the directed broadcast address. Both are reserved and cannot be assigned to a host, so the usable count is (2^host_bits) − 2. Exceptions: /31 on point-to-point links (RFC 3021 allows using both addresses), and /32 (a host route, one address total).

How is IPv6 different?

IPv6 uses 128-bit addresses. A /64 — the standard subnet size — has 2^64 addresses. There is no network/broadcast reservation in the same way; instead, specific low-numbered addresses (::1, subnet-router anycast) are reserved by convention. For IPv6 planning, count the number of subnets (2^(64 − prefix)) rather than hosts per subnet.

What does 'subnet mask' mean in decimal form?

The CIDR prefix and the decimal subnet mask carry the same information. /24 = 255.255.255.0, /23 = 255.255.254.0, /25 = 255.255.255.128, /30 = 255.255.255.252. To convert: write out the prefix bits as 1s (left-justified) and the rest as 0s, then read the binary as four bytes. /26 has 26 ones = 11111111.11111111.11111111.11000000 = 255.255.255.192.

What's the largest realistic subnet?

In practice, subnets larger than /22 (~1000 hosts) cause performance problems: ARP traffic, broadcast domain size, and STP re-convergence all scale with host count. Most enterprise networks cap end-user VLANs at /23 or /24 and use L3 routing between them rather than one giant subnet.

Related calculators

Sources & references