The number of usable IP addresses in a block is 2 raised to the number of host bits, minus two for the network and broadcast addresses. For example, a /24 IPv4 subnet has 8 host bits, so 2^8 = 256 total addresses, and 256 − 2 = 254 usable host addresses.

Counting IP addresses by subnet size

IPv4 addresses are 32 bits long, split into a network portion and a host portion by the prefix length. The host portion is what you count. Every subnet of size /n has 32 − n host bits, giving 2^(32−n) total addresses.

A /30 has 2 host bits: 4 total addresses, 2 usable. A /29 has 3 host bits: 8 total, 6 usable. A /28 has 4 host bits: 16 total, 14 usable. A /27 has 5 host bits: 32 total, 30 usable. A /26 has 6 host bits: 64 total, 62 usable. A /25 has 7 host bits: 128 total, 126 usable. A /24 has 8 host bits: 256 total, 254 usable.

Larger blocks follow the same doubling. A /23 has 9 host bits: 512 total, 510 usable. A /22 has 10 host bits: 1,024 total, 1,022 usable. A /21 has 11 host bits: 2,048 total, 2,046 usable. A /20 has 12 host bits: 4,096 total, 4,094 usable. A /16 has 16 host bits: 65,536 total, 65,534 usable. A /8 has 24 host bits: 16,777,216 total, 16,777,214 usable.

Reference table for common IPv4 prefixes

| Prefix | Host bits | Total addresses | Usable hosts | |--------|-----------|-----------------|--------------| | /30 | 2 | 4 | 2 | | /29 | 3 | 8 | 6 | | /28 | 4 | 16 | 14 | | /27 | 5 | 32 | 30 | | /26 | 6 | 64 | 62 | | /25 | 7 | 128 | 126 | | /24 | 8 | 256 | 254 | | /23 | 9 | 512 | 510 | | /22 | 10 | 1,024 | 1,022 | | /21 | 11 | 2,048 | 2,046 | | /20 | 12 | 4,096 | 4,094 | | /16 | 16 | 65,536 | 65,534 | | /8 | 24 | 16,777,216 | 16,777,214 |

Each step up in prefix length halves the block; each step down doubles it. If you know one row, you can derive the neighbors by doubling or halving and adjusting the minus-two.

Why two addresses are subtracted

In every IPv4 subnet, the lowest address is reserved as the network address and the highest is reserved as the broadcast address. Neither can be assigned to a host interface. That is why a /24 yields 254 usable addresses rather than 256.

This rule applies to standard subnets. A /31 point-to-point link is a special case: it has 2 total addresses and both are usable under common point-to-point conventions, so the usual minus-two does not apply. A /32 has a single address and is used for a single host route, not a subnet with hosts.

If you are sizing a subnet for devices, start from usable hosts, not total addresses. A room needing 40 devices fits in a /26 (62 usable) but not a /27 (30 usable).

Adjusting the count for unusual cases

Several factors change the practical number of addresses you can actually use.

Reserved addresses inside a subnet

Some networks reserve the first few usable addresses for the gateway or for infrastructure. That does not change the mathematical count, but it changes how many remain for endpoints. If your gateway takes one usable address, a /24 leaves 253 for other devices.

Overlapping and private ranges

Private IPv4 ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) are not extra addresses on top of the public pool; they are carved out of the same 32-bit space. Using them does not increase the total, but it does let you reuse address space internally.

IPv6 changes the scale entirely

An IPv6 address is 128 bits. A typical /64 subnet has 64 host bits, which is 2^64 total addresses — about 18.4 quintillion. That is far more than any LAN needs, which is why IPv6 subnets are usually /64 and the minus-two rule is not applied in the same way.

For IPv6, count host bits as 128 minus the prefix length. A /64 has 64 host bits; a /56 has 72; a /48 has 80. The usable-host convention differs by design, so treat the raw 2^host-bits figure as the address count.

Mistakes in measuring IP address counts

The most common error is forgetting the minus-two and reporting total addresses as usable hosts. A /24 has 256 addresses but only 254 usable, and planning for 256 devices on a /24 will fail.

A second error is confusing bits with bytes. The prefix length counts bits, not octets. A /24 is 24 bits of network, not 24 addresses.

A third error is assuming every address in a block is assignable. Network and broadcast addresses are reserved, and some environments reserve additional addresses for gateways or management.

A fourth error is applying IPv4 arithmetic to IPv6. The 32-bit total (about 4.3 billion) does not describe IPv6, whose 128-bit space is vastly larger.

To check your result, subtract the prefix length from 32 for IPv4, raise 2 to that power, then subtract 2 for usable hosts. For a /26: 32 − 26 = 6; 2^6 = 64; 64 − 2 = 62. That matches the table.

What changes the available address count most

The prefix length is the single biggest lever. Moving one bit changes the count by a factor of two. Going from /24 to /23 doubles the block from 256 to 512 total addresses; going from /24 to /25 halves it to 128.

The address family is the next biggest factor. IPv4's 32 bits cap the entire space at about 4.3 billion addresses; IPv6's 128 bits make any single /64 subnet larger than the whole IPv4 space.

Reserved addresses matter at the margins. The minus-two rule removes two addresses per subnet, which is significant on small subnets (/30 loses half its addresses) and negligible on large ones (/16 loses two out of 65,536).

IP address counts for mixed subnet plans

When you plan several subnets, add the usable counts. Two /24s give 508 usable hosts; four /26s give 248; one /23 plus one /24 gives 510 + 254 = 764.

If you need 500 hosts, a /23 (510 usable) fits, while two /24s (508 usable) also fit but use more subnets. If you need 1,000 hosts, a /22 (1,022 usable) fits; a /21 (2,046 usable) leaves room to grow.

For a home network, a single /24 is usually enough; for a small office, a /24 or /23 covers typical device counts. For a data center, /24s and /23s are common building blocks, and larger allocations use /20 or shorter prefixes.

Always leave headroom. A subnet sized exactly to current devices has no room for growth, and adding devices later means renumbering or adding a subnet.

Checking an IP address count by hand

Write the prefix length. Subtract it from 32. Raise 2 to that result. That is total addresses. Subtract 2 for usable hosts, unless the prefix is /31 or /32.

For a /28: 32 − 28 = 4; 2^4 = 16; 16 − 2 = 14 usable. For a /22: 32 − 22 = 10; 2^10 = 1,024; 1,024 − 2 = 1,022 usable.

For IPv6, subtract the prefix from 128 instead of 32. A /64: 128 − 64 = 64; 2^64 is about 18.4 quintillion addresses.

If your count disagrees with a subnet calculator, check whether the calculator is reporting total or usable addresses, and whether it treats /31 specially.

IPv4 versus IPv6 address counts in practice

IPv4's total space is 2^32, about 4.29 billion addresses. After subtracting reserved and special-use ranges, the assignable public pool is smaller, and private ranges are reused inside networks.

IPv6's total space is 2^128, about 340 undecillion addresses. A single /64 subnet contains 2^64 addresses, roughly 18.4 quintillion, which is more than the entire IPv4 space by a wide margin.

That scale is why IPv6 planning focuses on prefix lengths and subnet counts rather than counting individual hosts. For most LANs, a /64 is standard and the host count is effectively unlimited for practical purposes.

Subnet sizing for devices and growth

Match the subnet to the device count with room to spare. Ten devices fit in a /28 (14 usable); 50 devices fit in a /26 (62 usable); 200 devices fit in a /24 (254 usable).

Add headroom of roughly 20 to 30 percent. A site with 40 devices is better served by a /26 (62 usable) than a /27 (30 usable), because the /27 is already too small.

Remember that each subnet consumes a network and broadcast address, so many small subnets waste more addresses proportionally than a few large ones. Balance subnet count against wasted addresses.

For point-to-point links, a /31 or /30 is typical; for loopbacks, a /32 is typical. These special cases do not follow the standard usable-host count.