Definition
With h host bits, a subnet contains 2^h addresses. Under traditional rules, two are reserved: all-zero host bits for the Network ID and all-one host bits for broadcast.
Example
For 130.192.1.4/30, h = 2:
.4: network (00host bits).5: first host (01).6: second host (10).7: broadcast (11)
Thus four total addresses leave two usable hosts.
/31 and /32
| Prefix | Total addresses | Interpretation |
|---|---|---|
| /30 | 4 | Two ordinary usable hosts |
| /31 | 2 | No ordinary hosts under traditional reservations; two endpoints on an RFC 3021 point-to-point link |
| /32 | 1 | One exact address, commonly a host route |
A /31 leaves just one host bit. Traditionally its two values are consumed by network and broadcast. The broadcast cannot substitute for an individual device address.
For a point-to-point link, RFC 3021 instead treats both values as endpoint addresses. This qualifies the slide’s page 9 statement that 254 is invalid in the fourth mask byte.
Important rules
- Use
2^h - 2for ordinary subnets with network/broadcast reservations. - Do not apply that formula blindly to /31 and /32.
254is a valid mask octet. It is also used in255.255.254.0(/23).
Common mistakes
Thinking one remaining bit is always useless, or thinking a /32 provides a shared subnet containing a host and gateway.
Related concepts
- IPv4 Interfaces and Special Addresses
- CIDR Prefixes and Netmasks
- IPv4 Network IDs and Subnet Boundaries
Source
Lecture 01 - IPv4 Addressing and Routing, PDF pages 9-10. /31 clarification follows RFC 3021; worked host assignments are added study explanation.