Appearance
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 partSubnet Mask Reference Table
| CIDR | Subnet Mask | Network Bits | Host Bits | Hosts Available |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 8 | 24 | 16,777,214 |
| /16 | 255.255.0.0 | 16 | 16 | 65,534 |
| /24 | 255.255.255.0 | 24 | 8 | 254 |
| /25 | 255.255.255.128 | 25 | 7 | 126 |
| /26 | 255.255.255.192 | 26 | 6 | 62 |
| /27 | 255.255.255.224 | 27 | 5 | 30 |
| /28 | 255.255.255.240 | 28 | 4 | 14 |
| /30 | 255.255.255.252 | 30 | 2 | 2 |
| /32 | 255.255.255.255 | 32 | 0 | 1 (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 hostsSplitting 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.255Route 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 bits | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
|---|---|---|---|---|---|---|---|---|
| Hosts | 0 | 2 | 6 | 14 | 30 | 62 | 126 | 254 |
Formula: 2ⁿ - 2, where n = host bits
CIDR vs Classful
| Classful | CIDR | |
|---|---|---|
| Subnet mask | Fixed per class | Variable (any prefix) |
| Flexibility | Low | High |
| IP wastage | High | Low |
| Route aggregation | No | Yes |