tech

CIDR

CIDR stands for Classless InterDomain Routing. But to explain what it is, we require some more context.

IP Addresses demystified

An IP address e.g. 52.212.73.201 consist of a network part and a host part. The network part is the same for the whole network. The IP address you see here is actually a decimal representation of four 8-bit numbers 255.255.255.255 represents the binary address 11111111.11111111.11111111.11111111 .

The  IP address above might be a part of the network with ip range: 52.212.73.0 -> 52.212.73.255. This would make  52.212.73 the network part and 201 the host part. In such a range 52.212.73.0 represents the network address and 52.212.255.255 is the broadcast address, broadcasting events to all hosts in the network.

We could also say that for the network above the Network Mask is 255.255.255.0 which means that the first 24 bits are fixed for this network. Which is true because those bits are represented by the network part 52.212.73. So 8 bits are variable (host part) in this network

You might already feel that there is always a fixed part which is the same for all hosts in the network, followed by a variable part of bits. For the example 52.212.73.201 we could say that 52.212.73 is the fixed network part and 201 is the host part. As we have seen if the range is 52.212.73.0 -> 52.212.73.255. the last bit can very from 0 to 255. That is from 0000 0000 to 1111 1111. Which means 8 bits are  flexible, so 24 bits are fixed.

CIDR

That is why we can also write the range 52.212.73.0 -> 52.212.73.255. as  the CIDR block 52.212.73.0/24 meaning that  24 bits are fixed for the network part and 8 bits are variable for the host part. And that is what the CIDR block means.

Examples

Question 1

CIDR 152.2.136.0/26 refers to which IP range and which Network Mask?

 

There are 26 fixed bits in this network address and 6 variable bits (32 – 6)

The CIDR above refers to a range 152.2.136.0 -> 152.2.126.63 ( which are 64 address, 64 being 2)

In binary that is 10011000.00000010.10001000.00000000 -> 10011000.00000010.10001000.00111111

To find the network mask mark that the 10011000.00000010.10001000.00 part is fixed.

That are 26 fixed bits. Which means that we represent the network mask by 26 bits set to 1 -> Network Mask: 11111111.11111111.11111111.11

 

Question 2

What is the Network Mask and CIDR representation of the network range: 52.212.72.0 -> 52.212.79.255?

 

This range in binary is 00110100.11010100.01001000.00000000 -> 00110100.11010100.01001111.11111111

From this we see that the constant part (network part) of these IPs is 00110100.11010100.01001, which is 21 bits long.

-> The network mask is 11111111.11111111.11111

-> CIDR representation 52.212.72.0/21

 

Refs

CIDR to IPv4 Conversion : https://www.ipaddressguide.com/cidr

IP range to CIDR: https://www.ipconvertertools.com/iprange2cidr

IP to binary: https://www.browserling.com/tools/ip-to-bin

Leave a Reply

Your email address will not be published.