CIDR (Classless Inter-Domain Routing) is a method of allocating IP addresses and routing Internet protocol packets.
Think of it as a more efficient way to organize and distribute IP addresses on the internet, similar to how a postal system organizes addresses for mail delivery.
Instead of using fixed classes like the old system, CIDR allows network administrators to divide IP address space into pieces of any size, much like being able to divide a pizza into exactly the number of slices you need.
In the early 1990s, the Internet was growing rapidly, and the original system of IP address allocation (called classful networking) was becoming problematic. It was like having only small, medium, and large T-shirts available when people needed many different sizes.
CIDR was introduced in 1993 to solve this problem by allowing more flexible network sizes. This change helped prevent the Internet from running out of IP addresses too quickly and made routing more efficient.
The classful addressing system, used before CIDR, divided the IPv4 address space into five distinct classes (A through E). Each class was defined by the first few bits of the address, making it easy to determine the class by looking at the first octet.
The original IP addressing system divided addresses into five classes (A, B, C, D, and E). Each class had fixed boundaries, like having boxes that only come in certain sizes.
Here's a simple one-line example for each class showing how the network and host portions are divided:
IP Address: 10.45.72.89 - where 10 is the network portion (1 octet) and 45.72.89 is the host portion (3 octets)
IP Address: 172.16.45.178 - where 172.16 is the network portion (2 octets) and 45.178 is the host portion (2 octets)
IP Address: 192.168.1.100 - where 192.168.1 is the network portion (3 octets) and 100 is the host portion (1 octet)
IP Address: 224.0.0.1 - Multicast address (no network/host division, used for group communication)
IP Address: 240.0.0.1 - Reserved for experimental use (no network/host division)
Classless addressing (CIDR) removes these fixed boundaries. It's like having a custom box maker that can create exactly the size you need. For example, instead of being limited to 256 addresses (Class C), you could have 512 or 1024 addresses, depending on your needs.
Classful IP addressing had several major problems:
Problem: Organizations often received far more addresses than needed
Problem: No way to get a network size between classes
Problem: Large routing tables due to inability to group addresses
Problem: Rigid structure made network expansion difficult
CIDR removes the concept of fixed classes entirely.
Instead of being restricted to predefined sizes, CIDR allows networks to be divided into any size using a simple notation called the prefix length. It's like being able to cut a piece of fabric to exactly the size you need instead of only having pre-cut pieces.
Before CIDR: Must use entire Class B (65,534 addresses)
With CIDR: Can allocate exact number needed
CIDR allows custom subnet sizes
Ability to combine multiple networks into one route
Before CIDR: Each network needed separate entry
With CIDR: Multiple networks combined
Allows exact sizing for different network segments
Simplified administration and growth
CIDR (Classless Inter-Domain Routing) works by using a flexible prefix length notation that allows network administrators to divide IP address space into variable-sized pieces, unlike the fixed classes of the old system.
It uses a format of IP address/prefix length (e.g., 192.168.1.0/24), where the prefix length indicates how many bits are used for the network portion of the address. For example, in a /24 network, the first 24 bits identify the network, leaving 8 bits (32-24=8) for host addresses, which allows for 256 (2^8) possible addresses.
CIDR notation uses a simple format: IP address/prefix length.
For example: 192.168.1.0/24
CIDR Notation | Host Bits | Available Addresses | Subnet Mask | Common Use Case |
---|---|---|---|---|
/32 | 0 | 1 | 255.255.255.255 | Single host |
/31 | 1 | 2 | 255.255.255.254 | Point-to-point links |
/30 | 2 | 4 | 255.255.255.252 | Small WAN links |
/29 | 3 | 8 | 255.255.255.248 | Tiny subnet |
/28 | 4 | 16 | 255.255.255.240 | Small office |
/27 | 5 | 32 | 255.255.255.224 | Small department |
/26 | 6 | 64 | 255.255.255.192 | Medium department |
/25 | 7 | 128 | 255.255.255.128 | Large department |
/24 | 8 | 256 | 255.255.255.0 | Standard network |
/23 | 9 | 512 | 255.255.254.0 | Large network |
/22 | 10 | 1024 | 255.255.252.0 | Very large network |
/16 | 16 | 65536 | 255.255.0.0 | Enterprise network |
The formula is simple: 2^(32 - prefix_length)
Examples:
Address: 192.168.1.0/24
Address: 192.168.0.0/23
Address: 192.168.1.0/25
Let's break down 192.168.1.0/24:
Route aggregation is a key feature of CIDR that dramatically improves routing efficiency. Imagine the internet as a massive postal system where routers are like sorting centers, and each network is a destination.
Scenario: An ISP with multiple consecutive networks
Old Method (Classful Routing):
Same Scenario:
Benefits:
Common CIDR block sizes:
Each reduction in the prefix number doubles the available addresses.
IPv6 uses the same CIDR concept but with 128-bit addresses instead of 32-bit:
Several tools help work with CIDR:
CIDR is used everywhere in modern networking:
For example, when you set up a Virtual Private Cloud (VPC) in AWS or Azure, you're asked to specify a CIDR range for your network. This allows you to plan your network size according to your needs, whether it's a small development environment or a large production network.