Skip to content

CIDR (Classless Inter-Domain Routing)

CIDR replaced the old classful addressing system to use IP addresses more efficiently.

Why CIDR?

  • Old classful system (Class A, B, C) was wasteful. Need 300 hosts? You get Class B = 65,534 hosts.
  • CIDR allows variable length subnet masks — allocate exactly what you need.
  • Also helps with route aggregation (reduces routing table size).

CIDR Notation

Written as IP address / prefix length. Example: 192.168.1.0/24

192.168.1.0/24
   /24 → first 24 bits are the network part
   Remaining 8 bits are the host part

Subnet Mask Reference Table

CIDRSubnet MaskNetwork BitsHost BitsHosts Available
/8255.0.0.082416,777,214
/16255.255.0.0161665,534
/24255.255.255.0248254
/25255.255.255.128257126
/26255.255.255.19226662
/27255.255.255.22427530
/28255.255.255.24028414
/30255.255.255.2523022
/32255.255.255.2553201 (host route)

Formula: Hosts Available = 2ⁿ - 2 (subtract 2 for network address + broadcast address)

How Subnetting Works

Take 192.168.1.0/24:

Network address  → 192.168.1.0   (first address, not assignable)
Broadcast address→ 192.168.1.255 (last address, not assignable)
Usable hosts      → 192.168.1.1 to 192.168.1.254 = 254 hosts

Splitting a Network — Example

Split 192.168.1.0/24 into 2 subnets → use /25

Subnet 1: 192.168.1.0/25
  → Hosts:     192.168.1.1 – 192.168.1.126 (126 hosts)
  → Broadcast: 192.168.1.127

Subnet 2: 192.168.1.128/25
  → Hosts:     192.168.1.129 – 192.168.1.254 (126 hosts)
  → Broadcast: 192.168.1.255

Route Aggregation (Supernetting)

192.168.0.0/24
192.168.1.0/24
192.168.2.0/24
192.168.3.0/24

→ All summarized as 192.168.0.0/22

This reduces routing table entries — routers work faster.

Quick Trick — Host Bits to Hosts

Host bits12345678
Hosts026143062126254

Formula: 2ⁿ - 2, where n = host bits

CIDR vs Classful

ClassfulCIDR
Subnet maskFixed per classVariable (any prefix)
FlexibilityLowHigh
IP wastageHighLow
Route aggregationNoYes