/30 addressing shortcut

Point-to-point IPv4 links are typically addressed with a 30-bit mask (255.255.255.252). This only provides 50% addressing efficiency (only two of the four addresses per subnet are usable), but many organizations consider this sufficient. Consequently, an engineer often needs to find the address of the interface at the other end of a /30 link to a neighboring router. You could do the binary in your head to deduce whether the local interface has the lower or higher IP, but an easier way is to remember this rule of thumb: the lower address will always be odd, and the higher will always be even.

Consider a point-to-point link between routers A and B. You know the interface of router A is assigned 192.168.0.90/30. Router B's address is obviously one IP higher or lower -- but which is it? Since the local address is even, we know know we have the higher IP, and the other end of the link must be 192.168.0.89. Indeed, working out the binary will confirm that these are the two correct addresses for the 192.168.0.88/30 subnet.

This same trick also works in reverse for /31 subnets, which are becoming more common as some legacy IP rules have been deprecated. For /31 subnets, the lower IP is always even, and the higher is always odd. For example, we know 192.168.0.176/31 is the lower IP in the pair, facing 192.168.0.177. (Note that these shortcuts only work on properly addressed networks.)

About the Author

Jeremy Stretch is a freelance networking engineer, instructor, and the maintainer of PacketLife.net. He currently lives in Fairfax, Virginia, on the edge of the Washington, DC metro area. Although primarily an R&S guy, he likes to get into everything, and runs a free network training lab out of his basement for fun. You can contact him by email or follow him on Twitter.

Comments

When can you use /30s vs /31s? Obviously they have to be point-to-point (not Ethernet) but what about the IOS limitations?

"Since the local address is even, we know know we have the higher IP, and the other end of the link must be 192.168.0.89. "

What do you mean local address is even? How do i know its even? I didn't get it.....

@mayjune: The last octet is an even number, so we know that in a /30, for example, the only other valid host address in the subnet is one less than ours.

The only time I've ever used a /31 is for summarizing 2 ips in a firewall rule. Where/how else could you use a /31?

Hello,
it is easier doing a few maths.

In a /30 network, the network address will always be divisible by 4: 88/4 = 22.
Broadcast address +1 will always be also divisible by 4: (91+1)/4 = 23.

If they are not divisible by four you are between the two nearest numbers divisible by four:

88/4 = 22 < 90/4 = 22.5 < (91+1)/4 = 23

This rule also applies for all subnets, a subnet address is always divisible by the number of ips it contains and the broadcast address+1 too. For example:

192.168.0.48/28
Net address - 48/16 = 3
Broadcast address - (63+1)/16 = 4

Regards.

Leave a Comment


Register to comment as a member. You'll look cooler.

Optional; will not be displayed publicly or given out.

No commercial links. Only personal (e.g. blog, Twitter, or LinkedIn) and/or on-topic links, please.
What protocol is used to resolve domain names to IP addresses?