How many usable hosts are in a /26 subnet, and what is the general formula?
A /26 leaves 6 host bits, so 2^6 = 64 addresses, of which 62 are usable because the first is the network address and the last is the broadcast address. The formula is 2^(32 - prefix) minus 2.
Explain it simply
An IPv4 address has 32 bits. The prefix says how many bits name the neighbourhood (network). The remaining bits number the houses (hosts). More host bits means bigger neighbourhoods.
Example
usable hosts = 2^(32 - prefix) - 2
/24 8 host bits 256 addresses 254 usable
/26 6 host bits 64 addresses 62 usable
/27 5 host bits 32 addresses 30 usable
/28 4 host bits 16 addresses 14 usable
/29 3 host bits 8 addresses 6 usable
/30 2 host bits 4 addresses 2 usableWorked: 192.168.10.0/26 has addresses .0 to .63. The network address is 192.168.10.0, the broadcast is 192.168.10.63, and usable hosts run from .1 to .62. That is 62 hosts.
A /30 with only 2 usable addresses is the classic size for a point-to-point link between two routers. Note that /31 (RFC 3021) is allowed on point-to-point links with no network or broadcast address, and /32 is a single host.
What to say in the interview
"Host bits are 32 minus the prefix, addresses are 2 to the power of that, and I subtract 2 for network and broadcast. For /26 that is 64 minus 2, so 62 usable hosts."
Common mistakes
- Forgetting to subtract the network and broadcast addresses.