The premiere source of truth powering network automation. Open and extensible, trusted by thousands.

NetBox is now available as a managed cloud solution! Stop worrying about your tooling and get back to building networks.

/30 addressing shortcut

By stretch | Thursday, June 12, 2008 at 12:13 a.m. UTC

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.)

Posted in Tips and Tricks

Comments


Dinger
June 15, 2008 at 12:57 a.m. UTC

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


mayjune
August 16, 2010 at 4:23 p.m. UTC

"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.....


stretch
August 17, 2010 at 3:04 p.m. UTC

@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.


mattheuw1
April 29, 2011 at 5:19 p.m. UTC

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?


anon
July 1, 2011 at 10:11 a.m. UTC

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.

Comments have closed for this article due to its age.