Network Bytes · Episode 23 · CCNA 1.6
Network, broadcast and usable hosts
A /24 has 256 addresses but only 254 usable hosts. The first address names the subnet and the last one reaches everyone, so usable hosts are 2 to the power of the host bits, minus 2.
Host bits set the size
An IPv4 address is 32 bits. The prefix length, such as /24, says how many of those bits are the network part. The rest are host bits.
A /24 leaves 32 − 24 = 8 host bits. Eight bits can make 2⁸ = 256 different values, so the subnet 192.168.1.0/24 holds 256 addresses, from 192.168.1.0 to 192.168.1.255.
The first address: the network address
The first address in the subnet has every host bit set to 0. That's the network address (192.168.1.0 here). Think of it as the street sign: it's the name of the whole subnet, the thing you see in routing tables and in a written subnet like 192.168.1.0/24. No device is given this address.
The last address: the broadcast address
The last address has every host bit set to 1. That's the broadcast address (192.168.1.255 here). A packet sent to it is delivered to every device on the subnet, like shouting through a megaphone on the street. Because it means "everyone", no single device can have it either.
The usable hosts formula
Take away those two and you get the number of addresses you can give to devices:
usable hosts = 2ⁿ − 2, where n is the number of host bits.
| Prefix | Host bits | Addresses | Usable hosts | |---|---|---|---| | /24 | 8 | 256 | 254 | | /25 | 7 | 128 | 126 | | /26 | 6 | 64 | 62 | | /27 | 5 | 32 | 30 |
Example: 192.168.1.64/26 has 6 host bits, so 64 addresses. The network address is 192.168.1.64, the broadcast address is 192.168.1.127, and the usable hosts are 192.168.1.65 to 192.168.1.126: 62 of them.
Try it yourself
Look up your own network on your computer: on Windows run ipconfig, on a Mac run ipconfig getifaddr en0 and ipconfig getoption en0 subnet_mask. A home network with mask 255.255.255.0 is a /24: your router and devices all sit between .1 and .254, never on .0 or .255.
Then work out a /28 on paper: how many host bits, how many addresses, how many usable hosts? (4 host bits, 16 addresses, 14 usable.)
Good to know
- Usable hosts = 2^(host bits) − 2. Example:
192.168.1.64/26has network.64, broadcast.127, usable.65to.126(62 hosts). - Exceptions:
/31point-to-point links use both addresses for the two ends (RFC 3021), and/32is a single host route.
For CCNA learners
This lines up with CCNA 200-301 exam topic 1.6, configure and verify IPv4 addressing and subnetting: for any subnet you should be able to find the network address, the broadcast address, the usable range and the number of usable hosts with 2ⁿ − 2.
Answer to the comment question
A /27 has 30 usable hosts. It has 5 host bits, so 2⁵ = 32 addresses, and two of them are taken: the network address (all host bits 0) and the broadcast address (all host bits 1). 32 − 2 = 30.
Test your knowledge
Quick quiz: Network, broadcast and usable hosts
4 multiple-choice questions. Pick one answer for each, then check how you did.
Sources
- Cisco, "IP Addressing and Subnetting for New Users": the all-zeros host part is the network address, all-ones is the broadcast, and hosts per subnet = 2^n − 2
- IETF, "RFC 950, Internet Standard Subnetting Procedure": all-zeros and all-ones host values are reserved for "this network" and broadcast
- IETF, "RFC 3021, Using 31-Bit Prefixes on IPv4 Point-to-Point Links": the /31 exception
- Cisco, CCNA 200-301 v1.1 exam topics: 1.6 configure and verify IPv4 addressing and subnetting
Video transcript
Why does a /24 give you 254 hosts, not 256?
A /24 leaves 8 bits for hosts. That's 256 addresses, 0 to 255. But two of them are taken.
The first one, with every host bit 0, is the network address. It's the street sign: the name of the whole subnet. No device gets it.
The last one, with every host bit 1, is the broadcast address. Send to it, and every device on the subnet hears you. No single device gets that one either.
So usable hosts are 2 to the power of the host bits, minus 2. A /26 has 6 host bits: 64, minus 2, is 62.
A /27 has 5 host bits. How many usable hosts is that? Comment your answer below!
That's your byte.
More from Network Bytes
- EP18Collisions and why switches killed hubs
- EP19Binary in 60 seconds
- EP20What a subnet mask does
- EP21CIDR notation (/24, /26)