What is CIDR? A beginner’s guide to CIDR blocks and notation

What id CiDR Header Image

What is CIDR?

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.

History and Motivation for CIDR

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.

What are the different IP address formats?

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.

Classful addresses

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:

Class A 

IP Address: 10.45.72.89 - where 10 is the network portion (1 octet) and 45.72.89 is the host portion (3 octets)

Class B 

IP Address: 172.16.45.178 - where 172.16 is the network portion (2 octets) and 45.178 is the host portion (2 octets)

Class C

IP Address: 192.168.1.100 - where 192.168.1 is the network portion (3 octets) and 100 is the host portion (1 octet)

Class D

IP Address: 224.0.0.1 - Multicast address (no network/host division, used for group communication)

Class E

IP Address: 240.0.0.1 - Reserved for experimental use (no network/host division)

Classless addresses

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.

What are the limitations of classful IPs?

Classful IP addressing had several major problems:

Wasted Addresses

Problem: Organizations often received far more addresses than needed

  • Example: A company needs 1,000 IP addresses
  • Class C is too small (only 254 hosts)
  • Must use Class B (65,534 hosts)
  • Result: 64,534 IP addresses wasted
  • Real-world case: A medium-sized business with 500 employees would waste 65,034 addresses with a Class B allocation

Inflexible Sizing

Problem: No way to get a network size between classes

  • Class C: 254 hosts
  • Class B: 65,534 hosts
  • No options in between
  • Example:
  • Company needs 300 IP addresses
  • Too big for Class C (254)
  • Too small for Class B (65,534)
  • No intermediate option available

Inefficient Routing

Problem: Large routing tables due to inability to group addresses

  • Example: A company with 4 Class C networks:
  • 192.168.1.0
  • 192.168.2.0
  • 192.168.3.0
  • 192.168.4.0
  • Required 4 separate routing table entries
  • Multiply this by thousands of networks = huge routing tables

Limited Growth

Problem: Rigid structure made network expansion difficult

  • Example: Company with Class C (254 hosts)
  • Needs to add 50 more hosts
  • Must upgrade to entire Class B
  • No incremental growth option

How does CIDR differ from classful IP addressing?

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.

What are the benefits of CIDR?

Efficient IP Address Usage

Before CIDR: Must use entire Class B (65,534 addresses) 

With CIDR: Can allocate exact number needed

  • Example: Need 1,000 addresses?
  • Use a /22 CIDR block (1,022 addresses)
  • Only 22 addresses wasted vs 64,534

Flexible Network Sizes

CIDR allows custom subnet sizes

  • /24 = 256 addresses
  • /23 = 512 addresses
  • /22 = 1,024 addresses
  • Example: Company needs 500 addresses
  • Can use /23 CIDR block
  • Perfect fit without waste

Better Route Aggregation

Ability to combine multiple networks into one route

  • Example: Company has these networks:
  • 192.168.0.0/24
  • 192.168.1.0/24
  • 192.168.2.0/24
  • 192.168.3.0/24
  • Can be aggregated into: 192.168.0.0/22
  • One routing table entry instead of four

Reduced Routing Table Sizes

Before CIDR: Each network needed separate entry 

With CIDR: Multiple networks combined

  • Example: ISP with 256 customers
  • Classful: 256 routing entries
  • CIDR: Could be as few as 8 entries

Precise Network Design

Allows exact sizing for different network segments

  • Example Organization:
  • Corporate HQ: /22 (1,000 addresses)
  • Branch office: /24 (250 addresses)
  • Remote office: /26 (60 addresses)
  • Each sized appropriately

Easier Network Management

Simplified administration and growth

  • Growth Example:
  • Start with /24 (256 addresses)
  • Need more? Expand to /23 (512 addresses)
  • No complete redesign needed

How does CIDR work?

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

CIDR notation uses a simple format: IP address/prefix length.

For example: 192.168.1.0/24

  • The number after the slash (24) indicates how many bits are used for the network portion
  • The remaining bits (32 - 24 = 8) are used for host addresses
  • This example allows for 256 addresses (2^8)

CIDR notation Quick Reference Table

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

Calculating Available Addresses

The formula is simple: 2^(32 - prefix_length)

Examples:

  1. /24 network: 2^(32-24) = 2^8 = 256 addresses
  2. /23 network: 2^(32-23) = 2^9 = 512 addresses
  3. /22 network: 2^(32-22) = 2^10 = 1,024 addresses

Common CIDR Examples

/24 Network (Similar to Class C)

Address: 192.168.1.0/24

  • Prefix length: 24 bits for network
  • Host bits: 8 (32 - 24 = 8)
  • Available addresses: 2^8 = 256
  • There are 256 available addresses because in the last octet we can use from 192.168.1.0 to 192.168.1.255
  • Subnet mask: 255.255.255.0
  • Range: 192.168.1.0 to 192.168.1.255

/23 Network (Double size of /24)

Address: 192.168.0.0/23

  • Prefix length: 23 bits for network
  • Host bits: 9 (32 - 23 = 9)
  • Available addresses: 2^9 = 512. 
  • There are 512 available addresses because in the last two octets we can use from 192.168.0.0 to 192.168.0.255 and 192.168.1.0 to 192.168.1.255
  • Subnet mask: 255.255.254.0
  • Range: 192.168.0.0 to 192.168.1.255

/25 Network (Half of /24)

Address: 192.168.1.0/25

  • Prefix length: 25 bits for network
  • Host bits: 7 (32 - 25 = 7)
  • Available addresses: 2^7 = 128
  • There are 128 available addresses because in the last octet we can use from 192.168.1.0 to 192.168.0.127
  • Subnet mask: 255.255.255.128
  • Range: 192.168.1.0 to 192.168.1.127

Binary Representation

Let's break down 192.168.1.0/24:

  • IP: 192.168.1.0 
  • Binary: 11000000.10101000.00000001.00000000 
  • Prefix (/24): 
  • First 24 bits are network portion (11000000.10101000.00000001)
  • Last 8 bits are host portion (00000000)

CIDR in Routing

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.

Before CIDR: Inefficient Routing

Scenario: An ISP with multiple consecutive networks

  • 192.168.1.0/24
  • 192.168.2.0/24
  • 192.168.3.0/24
  • 192.168.4.0/24

Old Method (Classful Routing):

  • Each network requires a separate routing entry
  • 4 different routes in routing tables
  • More memory and processing power needed
  • Slower routing decisions

With CIDR: Intelligent Route Aggregation

Same Scenario:

  • Networks: 
  • 192.168.1.0/24
  • 192.168.2.0/24
  • 192.168.3.0/24
  • 192.168.4.0/24
  • Can be aggregated to: 192.168.0.0/22

Benefits:

  • Single routing table entry
  • Reduced routing table size
  • Faster routing decisions
  • Less memory consumption
  • Decreased network overhead

CIDR blocks

IPv4 CIDR blocks

Common CIDR block sizes:

  • /24 = 256 addresses
  • /23 = 512 addresses
  • /22 = 1024 addresses
  • /16 = 65,536 addresses

Each reduction in the prefix number doubles the available addresses.

IPv4 Characteristics
  • 32-bit address space
  • Total addresses: 2^32 (approximately 4.3 billion)
  • Subnet masks range from /0 to /32
  • Most subnets are /24 to /16 for typical networks

IPv6 CIDR blocks

IPv6 uses the same CIDR concept but with 128-bit addresses instead of 32-bit:

  • Common prefix lengths are /48, /56, and /64
  • Much larger address space allows for more flexible allocation
  • Typically, /64 is used for single networks
  • 128-bit address space
  • Total addresses: 2^128 (approximately 340 undecillion)
  • Subnet masks range from /0 to /128

Tools to Work with CIDR

Several tools help work with CIDR:

  1. Router Network’s CIDR calculator
  2. IP calculators
  3. Online CIDR calculators
  4. Network planning tools
  5. Subnet calculators These tools help calculate address ranges, subnet masks, and valid host addresses.

Real-World Applications of CIDR

CIDR is used everywhere in modern networking:

  1. Cloud Computing: Cloud providers use CIDR to allocate customer networks
  2. Enterprise Networks: Companies use CIDR to organize their internal networks
  3. Internet Service Providers: ISPs use CIDR to allocate customer IP ranges
  4. Data Centers: CIDR helps organize server networks efficiently
  5. Home Networks: Even your home router uses CIDR principles for local 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.