Slash 31

When configuring point-to-point LAN or WAN links, it’s common to use “/30” subnet masks (255.255.255.252) to conserve address space. As you may be aware, the general rule is that you can’t two of the addresses on a subnet, because the “subnet” and “directed broadcast” addresses (all zeros and all ones in the host portion, respectively) are reserved. For example, if using network 192.168.1.0 with a “/30” mask (six subnet bits and two host bits), there are sixty-four available subnets (and you can use all the subnets). The subnets increment by four in the fourth octet, and they are:

  • 192.168.1.0/30 (legal addresses 192.168.1.1 and 192.168.1.2)
  • 192.168.1.4/30 (legal addresses 192.168.1.5 and 192.168.1.6)
  • 192.168.1.8/30 (legal addresses 192.168.1.9 and 192.168.1.10)
  • (Fifty-eight more subnets that increment by four go here)
  • 192.168.1.244/30 (legal addresses 192.168.1.245 and 192.168.1.246)
  • 192.168.1.248/30 (legal addresses 192.168.1.249 and 192.168.1.250)
  • 192.168.1.252/30 (legal addresses 192.168.1.253 and 192.168.1.254)

Looking at the 192.168.1.4/30 subnet, only two addresses are usable, 192.168.1.5 and 192.168.1.6, with 192.168.1.4 (subnet) and 192.168.1.7 (broadcast) reserved. Since each subnet consumes four addresses from the space, but only two of the four are usable, half of the available address space is wasted.

Contrast this with what would happen if we use a “/31” mask (255.255.255.254) on this Class “C” network (seven subnet bits, and one host bit). The subnets are:

  • 192.168.1.0/31
  • 192.168.1.2/31
  • 192.168.1.4/31
  • (122 more subnets that increment by two go here)
  • 192.168.1.250/31
  • 192.168.1.252/31
  • 192.168.1.254/31

But wait … isn’t there a rule that says that you have to subtract two addresses from each subnet, and isn’t two minus two zero? Put another way, since there’s only one host bit, and it has to be either a zero or a one, and since you can’t have all zeros or all ones in the host portion, you can’t use either address, right? However you look at it, wouldn’t it mean that when using a “/31” mask (one host bit), no hosts at all would be permitted?

No, because in this special case the requirements to reserve the “subnet” and “directed broadcast” addresses are overridden, and we have:

  • 192.168.1.0/31 (legal addresses 192.168.1.0 and 192.168.1.1)
  • 192.168.1.2/31 (legal addresses 192.168.1.2 and 192.168.1.3)
  • 192.168.1.4/31 (legal addresses 192.168.1.4 and 192.168.1.5)
  • (122 more subnets that increment by two go here)
  • 192.168.1.250/31 (legal addresses 192.168.1.250 and 192.168.1.251)
  • 192.168.1.252/31 (legal addresses 192.168.1.252 and 192.168.1.253)
  • 192.168.1.254/31 (legal addresses 192.168.1.254 and 192.168.1.255)

Thus, we have 128 subnets that support two hosts apiece, and we’ve wasted zero addresses. It’s perfectly legal, and is supported by Cisco IOS. In case you think I’m making this up, you might consult RFC 3021, “Using 31-Bit Prefixes on IPv4 Point-to-Point Links” (December 2000) for details!

Author: Al Friebe

In this article

Join the Conversation

3 comments

  1. Andy Reply

    Are the /30s at the end all typos? Shouldn’t they be /31s? Odd since this is what the article is about.

  2. Al Friebe Reply

    Yeah, you’re right! Sorry!

  3. Alex Reply

    Nice article! And thanks for the RFC reference.