Oui Lookup

OUI and MAC address lookup


CIDR, standing for Classless Inter-Domain Routing, is a network notation used in order to allocate IP addresses and masks over a network.

Contrary to classful IP addressing used in the early days of Internet, CIDR is used to describe an IP with the number of bits assigned to the network portion.

As an example, the IP 194.125.26.24/8 means that eight bits are assigned to the network portion of the IP.

As a consequence, the IP address of the network is 194.0.0.0/8. In this case, we could make a parallel with previous Class A IP addresses.

However, in some cases, you may need to convert the CIDR notation to an IP range.

In this tutorial, you will learn how you can easily achieve that.

Convert CIDR To IP Range

The easiest way to convert a CIDR IP to an IP range is to write down the IP in a binary format, isolate the part for the network and the part for the host.

CIDR To IP Range method

Using those two parts, you will be able to determine the first IP as well as the last IP, resulting in the complete IP range.

In order to illustrate that, let’s have a quick example using the following IP address : 194.156.145.1/12.

Note : we chose /12 as the CIDR as /8, /16 and /24 CIDR give trivial IP ranges.

As we detailed earlier, the first thing to do is to isolate the network portion and convert it to binary.

Isolating network and host portions

If you are not familiar with converting decimal to binary, you can read the following tutorial.

In our case, the network portion is “1100010.1001“.

Filling the rest of the IP with zeros unveils the IP of the network for our range : 194.144.0.0/12.

Now that we have isolated the network portion, we can easily find the first IP and the last IP in range.

As a reminder, in order to find the first IP address in a network range, you have to fill the host portion with zeros except for the last bit which is a one.

Similarly, in order to find the last IP address in a network range, you have to fill the host portion with ones except for the last bit which is a zero.

First “usable” IP in the RangeLast “usable” IP in the Range
192.144.0.1/12192.144.255.254/12

Awesome, you successfully converted a CIDR IP to an IP range!

Convert CIDR To Subnet Mask

In order to convert find the subnet mask given an IP in a CIDR notation, you simply have to remember that the CIDR number gives the number of bits set to one in the subnet mask.

CIDR To subnet mask

Starting from the left, you write down ones until you reach the CIDR number and you set the rest to zeros.

Given the example we used before, let’s try to find the subnet mask given the following IP address : 145.56.123.25/14.

Here, the CIDR number is 14 : it means that the subnet mask is made of 14 ones and it is ending with 18 zeros : 11111111 11111100 00000000 00000000.

Now that you have found the subnet mask in binary format, you simply have to convert it back to decimal in order to find the subnet mask.

The binary number we found would give the following subnet mask : 255.252.0.0.

Congratulations, you just found the subnet mask given an IP address written in the CIDR format.

Needless to say that you can find the CIDR notation given a subnet mask by applying this method in the opposite direction.

Conclusion

In this tutorial, you learnt how you can simply find the IP range for a given CIDR IP address.

You also learnt that you can find the subnet mask by remembering that the CIDR is simply the number of ones in the network portion of the IP.

Scroll to Top