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 (00 host bits)
  • .5: first host (01)
  • .6: second host (10)
  • .7: broadcast (11)

Thus four total addresses leave two usable hosts.

/31 and /32

PrefixTotal addressesInterpretation
/304Two ordinary usable hosts
/312No ordinary hosts under traditional reservations; two endpoints on an RFC 3021 point-to-point link
/321One 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 - 2 for ordinary subnets with network/broadcast reservations.
  • Do not apply that formula blindly to /31 and /32.
  • 254 is a valid mask octet. It is also used in 255.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.

Source

Lecture 01 - IPv4 Addressing and Routing, PDF pages 9-10. /31 clarification follows RFC 3021; worked host assignments are added study explanation.