LEARN · Subnetting

USABLE HOSTS

By Richard Lucht · Published

“How many hosts fit in a /27?” is probably the most-asked subnetting question there is, in exams and in change tickets. The answer is one line of arithmetic, but the real-world question is usually the reverse: you have 50 devices, so which prefix do you ask for? This guide covers both, plus the extra addresses that real networks quietly take away.

The formula

A prefix of length p leaves 32 − p host bits. The subnet holds 2(32 − p) addresses. Two of them can’t be assigned to a device: the all-zeros address names the network, and the all-ones address is the broadcast. So:

Usable hosts = 2(32 − p) − 2

That rule holds for every prefix from /1 to /30. The two exceptions are at the very end. A /31 has 2 addresses and both are usable on a point-to-point link (RFC 3021). A /32 is a single address, used for loopbacks and host routes.

The table worth knowing by heart

Most LANs, DMZs and router links use prefixes between /24 and /30. These seven rows answer most questions you’ll be asked, and the last two cover the exceptions.

Prefix Host bits Addresses Usable hosts Typical use
/24 8 256 254 Standard LAN or VLAN
/25 7 128 126 Half a /24: split user VLANs
/26 6 64 62 Small office, printer or voice VLAN
/27 5 32 30 Server or management segment
/28 4 16 14 Small DMZ, ISP public block
/29 3 8 6 Firewall pair, small public block
/30 2 4 2 Point-to-point router link
/31 1 2 2 Point-to-point link (RFC 3021)
/32 0 1 1 Loopback or host route

The pattern is simple: every extra prefix bit halves the subnet. If you remember that a /24 has 256 addresses, you can rebuild the rest of the table in a few seconds.

Sizing a subnet for a number of devices

To choose a prefix, find the smallest subnet whose usable count covers what you need:

  1. Count the devices that need an address, including the gateway.
  2. Add headroom. Subnets are painful to resize later, so plan for growth, often 25 to 50% for user VLANs.
  3. Pick the first prefix in the table whose usable hosts are at least that number.

Some worked answers:

Note that 254 hosts fit exactly in a /24, but “exactly” means no spare addresses at all. In practice you would almost never plan a subnet to be 100% full on day one.

The addresses you don’t get

The formula gives the theoretical number. Real networks take a few more away before your first device gets an address.

Gateways and redundancy. The default gateway uses one address. With a first-hop redundancy protocol such as HSRP or VRRP, a router pair typically uses three: one for each router and one virtual address that hosts point to. A /29 has 6 usable addresses, so after a redundant gateway it has room for only 3 devices.

Cloud providers. AWS and Azure each reserve five addresses in every subnet. In AWS these are the network address, the VPC router (+1), the DNS server (+2), one reserved for future use (+3) and the broadcast address. Azure reserves the same count for similar purposes. So a /28 cloud subnet gives 11 usable addresses rather than 14, and a /24 gives 251 rather than 254. AWS subnets can’t be smaller than a /28. Azure’s smallest is a /29, which leaves only 3 usable addresses.

DHCP scopes and static ranges. A subnet’s usable count isn’t the same as its DHCP pool. If you reserve the first 20 addresses for switches, printers and access points, a /24 offers 234 addresses to clients, not 254.

Common mistakes

Practice

The host-count field in Subnetle is scored separately, and its feedback tells you when you’re within a factor of two. That makes it a quick way to check whether you’ve really got the halving pattern down.

Practice it: Subnetle puts this into a daily game, free in your browser.

FAQ

How many usable hosts are in a /27?

30. A /27 has 5 host bits, so 2 to the power of 5 is 32 addresses, minus the network and broadcast addresses.

What prefix do I need for 50 hosts?

A /26, which has 62 usable addresses. A /27 only has 30. Pick the smallest subnet whose usable count is at least the number of devices, plus room to grow.

Why does my cloud subnet have fewer addresses than the formula says?

AWS and Azure both reserve five addresses in every subnet: the network address, the broadcast address and three more for the virtual router, DNS and future use. A /28 in either cloud gives 11 usable addresses, not 14.

Should I use /30 or /31 for router links?

If both devices support RFC 3021, a /31 uses half the addresses for the same link. A /30 still works everywhere and is the safe default on older equipment.

SOURCES

RELATED GUIDES