What is CIDR?

Classless Inter-Domain Routing – method of allocating IP addresses for networks & sub-networks. It improves the distribution of IP addresses.

In this blog we will explore the IPv4 IP Address, Classes of IPv4, Method for allocation IP addresses using CIDR – Classless Inter-Domain Routing.


  • IPv4 – 4th version of the Internet Protocol.
  • Addresses are 32 bits Integer. Binary at back-end
  • Divided in 4 Octets
  • It has Network Component & Host Component depending upon Subnet Mask. Will see later.

For example 192.168.0.1 – Valid IPv4 Address. Lets see its binary representation. Below table is used to binary conversion.

2726252423222120
1286432168421

192 – Let see which bits are turned on. (128 + 62 = 192)

1286432168421
11000000

168 – (128 + 32 + 8 = 168)

1286432168421
10101000

0: All are turned off

1286432168421
00000000

1:

1286432168421
00000001

192.168.0.1 – Binary Representation:

19816801
110000001010100000000000000001

Classes of IP:

ClassRangeCIDR NotationDefault Subnet
A0.0.0.0 – 127.255.255.255/8255.0.0.0
B128.0.0.0 – 191.255.255.255/16255.255.0.0
C192.0.0.0 – 223.255.255.255/24255.255.255.0
D224.0.0.0 – 239.255.255.255
E 240.0.0.0 – 255.255.255.255
D class reserved for Multicast IPs and E for experimental IP addresses.

CIDR Notation – Subnet masks tells us the Network & Host Details:

  • /8 – First 8 bits reserved for network & rest are for host
  • /16 – First 16 bits reserved for network & rest are forhost
  • /24 – First 24 bits reserved for network & rest are forhost

127.0.0.0 – Reserved for loopback network

Reserved Private IPv4 (Which can be used within the local networks)

  • 10.0.0.0 – 10.255.255.255
  • 172.16.0.0 – 172.31.255.255
  • 192.168.0.0 – 192.168.255.255

Network Part & Host Part:

IPv4 has two main component : Network Part & Host Part. To identify the these parts we need Subnet Mask. Subnet Mask is also 32-bit number where network bits are represent as 1 & host bits as 0.

Example 1: Network 192.0.0.0 IP its default Subnet mask = 255.255.255.0 (CIDR /24)

CIDR Notation (/24) – Means 24 bits reserved for network. Rest of 8 for Host.

255.255.255.0 : Binary Representation

11111111111111111111111100000000
Network BitsNetwork BitsNetwork BitsHost Bits
192 Fixed0 Fixed0 Fixed0 – 255
  • Total no of IP in network = 2No of Host Bits = 28 = 256
  • Total no of usable IP in network = 2No of Host Bits – 2= 256
  • As 2 IP address reserved for Network IP & Broadcast IP
  • First IP – 192.0.0.0 (Network IP)
  • Last IP – 192.0.0.255 (Broadcast IP)
  • First Usable IP – 192.0.0.1
  • Last Usable IP – 192.0.0.254

Example 2: 128.0.0.0 its Subnet mask = 255.255.0.0 (CIDR /16)

11111111111111110000000000000000
Network BitsNetwork BitsHost BitsHost Bits
192 Fixed0 Fixed0 – 2550 – 255
  • Total no of IP in network = 2No of Host Bits = 216 = 65,536
  • Total no of usable IP in network = 2No of Host Bits – 2= 65,534
  • As 2 IP address reserved for Network IP & Broadcast IP
  • First IP – 192.0.0.0 (Network IP)
  • Last IP – 192.0.255.255 (Broadcast IP)
  • First Usable IP – 192.0.0.1
  • Last Usable IP – 192.0.255.254

Subnetting

So if you are using the default subnets – you are getting list of IPs in that network. Suppose you want to manage the network such like within network you want some sub networks, so you have to borrow the bits from host parts i.e. change the CIDR.

Let see some examples in details.

Example 1: IP :10.0.0.0/20

Subnet Mask: 255.255.240.0 ( CIDR Notation /20)

CIDR Notation (/20) – Means 20 bits turned true for network.

11111111111111111111000000000000
Network BitsNetwork BitsNetwork/Host BitsHost Bits

So we have borrowed here 4 bits (red) from the 3 octet & make it CIDR 20 instead of 16 (255.255.0.0) . Red underlined one is magic number 4th one i.e. 16

10.0.0.000001010000000000000000000000000
255.255.240.011111111111111111111000000000000
Logical AND00001010000000000000000000000000
10000

Network Address: 10.0.0.0 , Broadcast Address: 10.0.15.255

  • Total no of subnets = 2No of Subnets Bits = 24 = 16 Sub Networks
  • Total no of IP in each sub network = 2No of Host Bits = 212 = 4,096
  • Total no of usable IP in each sub network = 2No of Host Bits – 2= 4,094
  • First IP address reserved for Network IP & Last for Broadcast IP for each subnet
Network AddressRange
10.0.0.010.0.0.0 – 10.0.15.255
10.0.16.010.0.16.0 – 10.0.31.255
10.0.32.010.0.32.0 – 10.0.47.255
10.0.48.010.0.48.0 – 10.0.62.255
10.0.64.010.0.64.0 – 10.0.79.255
10.0.80.010.0.80.0 – 10.0.95.255
10.0.96.010.0.96.0 – 10.0.111.255
10.0.112.010.0.112.0 – 10.0.127.255
10.0.128.010.0.128.0 – 10.0.143.255
10.0.144.010.0.144.0 – 10.0.159.255
10.0.160.010.0.160.0 – 10.0.175.255
10.0.176.010.0.176.0 – 10.0.191.255
10.0.192.010.0.192.0 – 10.0.207.255
10.0.208.010.0.208.0 – 10.0.15.255
10.0.224.010.0.224.0 – 10.0.223.255
10.0.240.010.0.240.0 – 10.0.239.255

Example 2: IP Address : 192.168.100.154/27

Subnet Mask: 255.255.255.224 ( CIDR Notation /27)

11111111111111111111111111100000
Network BitsNetwork BitsNetworkNw Bits<->Host Bits
192 Fixed168 Fixed100 Fixed

So we have borrowed here 3 bits (red) from the 4th octet host bits& make it CIDR 27 instead of 24 (255.255.255.0) . Red underlined one is magic number 3rd one i.e. 32 from binary table.

192.168.100.154 Binary representation

192.168.100.15411000000101010000110010010011010
255.255.255.22411111111111111111111111111100000
Logical AND11000000101010000110010010000000
192168100128

Network Address: 192.168.100.128, Broadcast Address: 192.168.100.159

  • Total no of subnets = 2No of Subnets Bits = 23 = 8 Sub Networks
  • Total no of IP in each sub network = 2No of Host Bits = 25 = 32
  • Total no of usable IP in each sub network = 2No of Host Bits – 2= 30
  • First IP address reserved for Network IP & Last for Broadcast IP for each subnet
Network AddressRange
192.168.100.0192.168.100.0 – 192.168.100.31
192.168.100.32192.168.100.32 – 192.168.100.63
192.168.100.64192.168.100.64 – 192.168.100.95
192.168.100.96192.168.100.96 – 192.168.100.127
192.168.100.128192.168.100.128 – 192.168.100.159
192.168.100.160192.168.100.160 – 192.168.100.191
192.168.100.192192.168.100.192 – 192.168.100.223
192.168.100.224192.168.100.224 – 192.168.100.255

Thanks!

Happy Learning! Your feedback would be appreciated!

One thought on “What is CIDR?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s