Saturday, June 01, 2019

How To Tell If Two IP Ranges Are Adjacent

This post is about how to tell if two IP ranges are adjacent. It is part of series of posts on Tips to Quickly Perform Binary and CIDR Operations.

How to tell if two IP ranges are adjacent

You have two CIDR notations representing two IP ranges, and you want to tell if they are adjacent, or not.

Steps to answer:
  • The prefix value must be the same. CIDR notations with different prefix can never be adjacent
  • Used the steps outlined in How to quickly tell the first and last IP in a CIDR range, to figure out the first and last ip numbers in the two ranges
  • Check if adding 1 to the last IP address of one will lead to the starting IP address of the other. If so, then the two ranges are adjacent

Determine if and are adjacent

Previous post: How To Calculate How Many Smaller IP Ranges Can Be Gotten From a Bigger IP Range
Next post: How to quickly calculate exponents of base 2

No comments: