Introduction
CIDR stands for Classless Inter-Domain Routing. It is a method replaced the older system of class-based IP address allocation and introduced more scalable approach to IP networking. This method used to allocate IP address and manage routing in a more efficient and flexible way.
In this article, we will cover everything that a beginner needs to know like why it was introduced?, how to read CIDR notation?, how it is used in real-world?, and more.
1. Introduction to IP Addressing
Before diving into CIDR it is important to understand the basics of IP addresses.
An IP (Internet Protocol) address is nothing but a numerical label assigned to each device which is connected in a computer network that uses the Internet Protocol for communication. There are two types:
- IPv4:- Uses 32-bit addressing and creating around 4.3 billion unique addresses (eg:-192.168.1.1).
- IPv6:- Uses 128-bit addressing and creating almost infinite number of unique addresses (eg:-2001:0db8:85a3:0000:0000:8a2e:0370:7334).
Traditionally, IPv4 addresses were divided into five classes (A, B, C, D, E) and each with the predefined number of hosts. This method was inefficient and let to waste of IP addresses.
2. IP Address Classes
An IPv4 address is a 32-bit number and written in dotted decimal notation (eg:- 192.168.1.1).
These 32 bits are grouped into four octets (8 bits). An IP address belongs to any one of five classes – A, B, C, D, E depending on the value of first few bits. Let’s have a look at class in depth.
Class A:
- First Octet Range: 1.0.0.0 to 126.255.255.255
- Default Subnet Mask: 255.0.0.0
- Network Bits: 8
- Host Bits: 24
- Number of Networks: 128 (only 1-126 usable)
- Number of Hosts per Network: Over 16 million
Purpose:
Class A was considered for very large organisations which needs a huge number of host addresses.
Class B:
- First Octet Range: 128.0.0.0 to 191.255.255.255
- Default Subnet Mask: 255.255.0.0
- Network Bits: 16
- Host Bits: 16
- Number of Networks: 16384
- Number of Hosts per Network: 65534
Purpose:
This class was considered for medium-sized organisations like universities.
Class C:
- First Octet Range: 192.0.0.0 to 223.255.255.255
- Default Subnet Mask: 255.255.255.0
- Network Bits: 24
- Host Bits: 8
- Number of Networks: 2097152
- Number of Hosts per Network: 254
Purpose:
Used by small organisations or offices which requires less than 254 devices per network.
Class D (Multicast):
- First Octet Range: 224.0.0.0 to 239.255.255.255
- Default Subnet Mask: Not Applicable
Purpose:
This class is reserved for multicasting not for individual hosts. It is used in applications where one data packet is delivered to multiple destinations simultaneously.
Class E (Experimental)
- First Octet Range: 240.0.0.0 to 255.255.255.255
- Default Subnet Mask: Not Applicable
Purpose:
It is experimental, reserved for future or research purposes. Should not be used in normal networks.
Class Table
Class |
First Octet Range |
Subnet Mask |
Hosts Per Network |
Purpose |
A |
1-126 |
255.0.0.0 |
1,67,77,214 |
Large Networks |
B |
128-191 |
255.255.0.0 |
65,534 |
Medium Networks |
C |
192-223 |
255.255.255.0 |
254 |
Small Networks |
D |
224-239 |
N/A |
Multicast |
Multicasting |
E |
240-255 |
N/A |
Reserved |
Experimental |
Why CIDR was Introduced?
The classful system was inefficient due to its IP address waste. For example a small organisation may receive a class B block (65,536) when it only needed in hundreds.
CIDR resolved this issue by eliminating rigid class boundaries and flexibly allowing to assign IP.
What is CIDR?
CIDR provides IP address allocation based on variable-length subnet masking (VLSM) allowing network administrators to control over how many IPs are allocated to each subnet.
CIDR uses the format:
[IP Address]/[Prefix Length]
Example: 192.168.1.0/24
- 192.168.1.0 ---------> Network Address
- First 24 bits ---------> Network Part
- Remaining 8 bits ---> Host Address
CIDR Notation and Subnet Masks
The prefix length “/n” shows how many bits are reserved for the network portion.
CIDR Table
CIDR |
Subnet Mask |
Number of Hosts |
/8 |
255.0.0.0. |
16777214 |
/16 |
255.255.0.0 |
65534 |
/24 |
255.255.255.0 |
254 |
/30 |
255.255.255.252. |
2 |
/32 |
255.255.255.255 |
1 (Single host) |
CIDR in Routing
CIDR builds route aggregation which reduces the size of routing tables.
Example:
Let’s consider a router has to manage the below networks:
- 192.168.0.0/24
- 192.168.1.0/24
- 192.168.2.0/24
- 192.168.3.0/24
Instead of maintaining 4 entries CIDR combines them to 192.168.0.0/22. This can covers from 192.168.0.0 to 192.168.3.255. This process is called Supernetting.
Subnetting with CIDR
Subnetting breaks down a larger network into smaller ones.
Example:
Suppose you are given 192.168.1.0/24 and require 4 subnets. Each subnet must have 64 IPs so 6 bits for hosts (2^6=64). Then new subnet mask: /26 (32-6 = 26).
Subnets:
- 192.168.1.0/26 (0–63)
- 192.168.1.64/26 (64–127)
- 192.168.1.128/26 (128–191)
- 192.168.1.192/26 (192–255)
Advantages of CIDR
- Efficient IP address allocation
- Flexible Network Sizes
- Route aggregation reduces router load
- Supports subnetting and supernetting
- More scalable than class-based addressing