👈

🌐 CIDR Notation – Complete Explanation


1️⃣ What is CIDR?

CIDR stands for:

Classless Inter-Domain Routing

CIDR is a method used to:

  • Represent IP address ranges
  • Perform subnetting
  • Control network size
  • Optimize IP usage

2️⃣ Why CIDR Was Introduced (The Real Problem)

Before CIDR, networking used classful addressing.

🔴 Classful IP Problems

ClassNetwork Size
Class AVery large
Class BMedium
Class CVery small

Problems: ❌ Wasted IP addresses ❌ Inflexible network sizes ❌ Poor internet scalability


✅ CIDR Solved This

CIDR:

  • Removed fixed classes
  • Allowed custom network sizes
  • Improved IP utilization
  • Enabled modern subnetting

3️⃣ Basic CIDR Format

CIDR notation looks like:

IP_address/prefix_length

Example:

192.168.1.0/24

4️⃣ What Does /24 Mean?

The /24 is called the prefix length.

It means:

The first 24 bits are network bits

Since IPv4 has 32 bits total:

Network bits = 24
Host bits = 32 - 24 = 8

5️⃣ Understanding IP Addresses in Binary (Very Important)

IPv4 address:

192.168.1.0

In binary:

11000000.10101000.00000001.00000000

Each octet = 8 bits


6️⃣ Network Bits vs Host Bits

CIDR divides IP into:

  • Network part → identifies network
  • Host part → identifies devices

Example /24:

Network: 192.168.1
Host:    last octet

7️⃣ How Many IPs Does a CIDR Block Have?

Formula:

Total IPs = 2^(host bits)

Usable IPs:

2^(host bits) - 2

(One for network address, one for broadcast)


8️⃣ CIDR Examples (VERY IMPORTANT)


🔹 Example 1: /24

192.168.1.0/24
  • Host bits = 8
  • Total IPs = 256
  • Usable IPs = 254

Range:

192.168.1.0  → Network
192.168.1.1  → First host
192.168.1.254 → Last host
192.168.1.255 → Broadcast

🔹 Example 2: /16

10.0.0.0/16
  • Host bits = 16
  • Total IPs = 65,536
  • Usable IPs = 65,534

🔹 Example 3: /28

192.168.1.0/28
  • Host bits = 4
  • Total IPs = 16
  • Usable IPs = 14

9️⃣ Common CIDR Blocks You Must Remember

CIDRTotal IPsUsable
/1665,53665,534
/24256254
/25128126
/266462
/273230
/281614

🔟 CIDR and Subnetting (Connection)

Subnetting is:

Splitting a CIDR block into smaller CIDR blocks

Example:

10.0.0.0/24

Split into two subnets:

10.0.0.0/25
10.0.0.128/25

1️⃣1️⃣ CIDR in AWS (VERY IMPORTANT)

VPC CIDR

When creating a VPC:

10.0.0.0/16

This defines:

  • Size of your VPC
  • How many subnets you can create

Subnet CIDR

Subnets use smaller CIDR blocks inside VPC CIDR.

Example:

VPC:     10.0.0.0/16
Subnet1: 10.0.1.0/24
Subnet2: 10.0.2.0/24

1️⃣2️⃣ AWS Reserved IPs (IMPORTANT EXAM POINT)

In AWS:

  • 5 IPs are reserved per subnet

For /24:

Total IPs = 256
Usable = 251

Reserved:

  • Network address
  • Router
  • DNS
  • Future use
  • Broadcast

1️⃣3️⃣ CIDR and Route Tables

Route tables use CIDR blocks to:

  • Match destination IPs
  • Decide where traffic goes

Example:

0.0.0.0/0 → IGW
10.0.0.0/16 → local

1️⃣4️⃣ CIDR and Security (SG / NACL)

CIDR is used to define:

  • Allowed IP ranges
  • Blocked IP ranges

Example:

Allow SSH from 203.0.113.0/24

1️⃣5️⃣ 0.0.0.0/0 (VERY IMPORTANT)

This means:

All IPv4 addresses

Used as:

  • Default route
  • Open access

1️⃣6️⃣ Private IP CIDR Ranges (MUST MEMORIZE)

RangePurpose
10.0.0.0/8Private
172.16.0.0/12Private
192.168.0.0/16Private

1️⃣7️⃣ Longest Prefix Match (Exam Concept)

If multiple routes match:

  • Route with largest prefix length wins

Example:

10.0.1.0/24 → local
10.0.0.0/16 → IGW

Traffic to 10.0.1.5:

  • Uses /24 route

1️⃣8️⃣ Real-World Analogy

CIDR is like:

  • Apartment building size
  • /16 → big building
  • /24 → floor
  • /28 → few flats

1️⃣9️⃣ One-Line Exam Definition

CIDR notation defines an IP address range using a prefix length that determines the network and host portions.


2️⃣0️⃣ Final Summary (Must Remember)

  • CIDR replaced classful addressing
  • /number = network bits
  • Remaining bits = hosts
  • Used everywhere in AWS
  • Essential for subnetting, routing, and security