Study FAQ
How do I calculate an IPv4 subnet mask, broadcast address and usable host range?
Also asked as 2
- How can I derive the network and usable addresses from an IPv4 CIDR prefix?
- How do I find the IPv4 subnet boundaries from a host address and prefix length?
Answer
Write the prefix length as that many leading binary ones in a 32-bit mask. A bitwise AND between the address and mask gives the network address. Set all host bits to one to get the broadcast address for an ordinary IPv4 subnet. Usable host values fall between those two boundaries.
For 192.0.2.77/26, the 26 network bits leave six host bits. The mask is 255.255.255.192, with 11000000 in the last octet. The block size in the last octet is 256 − 192 = 64, so the blocks begin at .0, .64, .128 and .192. Address .77 lies in the block beginning at .64.
| Value | Result |
|---|---|
| Network | 192.0.2.64/26 |
| Broadcast | 192.0.2.127 |
| Usable host addresses | 192.0.2.65 through 192.0.2.126 |
| Usable host count | 2^6 − 2 = 62 |
Keep the ordinary host count rule scoped to conventional subnets such as this one. A /31 point-to-point prefix and a /32 host route have different purposes. Address eligibility also leaves assignment and uniqueness to check in the actual network.
References
Full explanation
HPE6-A86: IPv4 Subnetting, ARP and the Next-Hop Decision
Study guide · HPE6-A86
Read the full explanation