Computer Networks Essentials / Network Layer

CIDR (Classless Inter-Domain Routing)

πŸ€” What is CIDR? (Basic Idea)

Earlier, IP addressing used fixed classes:

  • Class A

  • Class B

  • Class C

This caused:

  • ❌ Huge IP wastage

  • ❌ Poor flexibility

  • ❌ Large routing tables

πŸ‘‰ CIDR was introduced to solve these problems.

πŸ“Œ In simple words:

CIDR allows IP addresses to be allocated without fixed classes.


🧠 Simple Definition

πŸ“Œ CIDR (Classless Inter-Domain Routing) is an IP addressing method that allows flexible allocation of IP addresses using variable-length subnet masks.


🧠 Why β€œClassless”?

Because:

  • CIDR removes Class A, B, C boundaries

  • Any number of network bits can be used

  • Addressing becomes flexible and efficient

πŸ“Œ This is why CIDR is called classless addressing.


πŸ•°οΈ Why CIDR Was Introduced?

CIDR was introduced to:

  • πŸ“‰ Reduce IP address wastage

  • πŸ“¦ Support subnetting & supernetting

  • πŸš€ Reduce routing table size

  • 🌍 Support Internet growth

πŸ‘‰ CIDR is mandatory for modern Internet routing.


🧠 Key Concept of CIDR

πŸ”‘ Prefix Length Notation

CIDR uses slash ( / ) notation.

πŸ“Œ Format:

IP_Address / Prefix_Length

πŸ‘‰ Example:

192.168.1.0 /24

πŸ”’ What Does /24 Mean?

  • /24 β†’ 24 network bits

  • Remaining bits β†’ host bits

πŸ“Œ IPv4 total bits = 32

Networkbits=24
Hostbits=32 βˆ’24 =8

🧠 CIDR vs Subnet Mask

CIDR:

/24

Subnet Mask:

255.255.255.0

πŸ“Œ Both mean the same thing.


🧩 CIDR and Subnet Mask Mapping

CIDR

Subnet Mask

/8

255.0.0.0

/16

255.255.0.0

/24

255.255.255.0

/26

255.255.255.192

/30

255.255.255.252


🧠 How CIDR Solves IP Wastage

❌ Without CIDR (Classful)

Need 1000 hosts:

  • Class C β†’ only 254 ❌

  • Class B β†’ 65,534 ❌ (huge waste)


βœ… With CIDR

Choose exactly what you need:

/22β†’1022hosts

βœ”οΈ No wastage

βœ”οΈ Perfect fit


πŸͺœ CIDR Address Calculation (Step-by-Step)

πŸ”Ή Example 1: /26

IP: 192.168.1.0/26
  • Network bits = 26

  • Host bits = 6

Hosts:

2⁢ βˆ’ 2 = 62

Subnet Mask:

255.255.255.192

πŸ”Ή Example 2: /30

IP: 10.0.0.0/30
  • Host bits = 2

Hosts:

2Β² βˆ’ 2 = 2

πŸ“Œ Used for point-to-point links.


🧠 CIDR Block Size (Quick Method)

Block size formula:

256 βˆ’ subnetmask value

Example:

/26 β†’255.255.255.192
Block size =256 βˆ’192 =64

πŸ“¦ CIDR Address Range Example

For:

192.168.1.0/26

Item

Address

Network

192.168.1.0

First Host

192.168.1.1

Last Host

192.168.1.62

Broadcast

192.168.1.63


🌐 CIDR & Route Aggregation

CIDR allows supernetting (route aggregation).

Example:

192.168.0.0/24
192.168.1.0/24

πŸ‘‰ Advertised as:

192.168.0.0/23

βœ”οΈ Smaller routing table

βœ”οΈ Faster routing


βš–οΈ Classful vs CIDR Addressing

Feature

Classful

CIDR

Address Classes

Fixed (A, B, C)

No classes

Flexibility

Low

High

IP Wastage

High

Very Low

Routing Table

Large

Small

Internet Use

❌ No

βœ… Yes


🧠 CIDR + Subnetting + Supernetting Relationship

  • Subnetting β†’ Divide network

  • Supernetting β†’ Combine networks

  • CIDR β†’ Enables both

πŸ“Œ CIDR is the umbrella concept.


🧠 Very Important CIDR Memory Table

Prefix

Hosts

/24

254

/25

126

/26

62

/27

30

/28

14

/29

6

/30

2


⭐ Advantages of CIDR

  • Efficient IP utilization

  • Flexible addressing

  • Smaller routing tables

  • Supports Internet scalability


❌ Limitations of CIDR

  • Requires good planning

  • Complex for beginners

  • Misconfiguration can cause routing issues


🧠 Memory Trick

  • CIDR β†’ Classless

  • Slash ( / ) β†’ Network bits

  • Bigger / number β†’ Fewer hosts


⭐ One-Line Summary

πŸ”Ή CIDR is a flexible, classless IP addressing method that efficiently allocates IP addresses and supports modern Internet routing.