CIDR (Classless Inter-Domain Routing) — Modern IP Addressing and Network Design¶
CIDR (Classless Inter-Domain Routing) is the modern method of allocating IP addresses and defining network boundaries. Unlike the old class-based addressing system (Class A, B, and C), CIDR allows network administrators to create networks of almost any size by specifying the number of network bits using prefix notation (such as /24, /16, or /28). Today, CIDR is used everywhere—from enterprise data centres and cloud platforms to Kubernetes clusters and home networks. Every Linux administrator, DevOps engineer, Cloud Architect, Platform Engineer, Site Reliability Engineer (SRE), and Network Engineer should master CIDR.
Learning Path¶
Course Progress
What You'll Learn¶
After completing this lesson, you'll be able to:
- Understand what CIDR is
- Read CIDR notation
- Understand prefix lengths
- Calculate network and host bits
- Determine the number of hosts in a subnet
- Understand why CIDR replaced classful addressing
- Apply CIDR in cloud and enterprise networking
Prerequisites¶
Complete:
Why Learn CIDR?¶
Suppose your organisation needs:
Using classful addressing:
Class C:
Class B:
Most addresses would be wasted.
CIDR solves this problem by allowing network sizes that closely match actual requirements.
What is CIDR?¶
CIDR (Classless Inter-Domain Routing) is a method of allocating IP addresses without relying on predefined address classes.
Instead of using:
CIDR uses:
This provides flexible network sizing.
CIDR Notation¶
Example:
The number after the slash indicates:
Remaining bits:
CIDR Format¶
Example:
Meaning:
Prefix Length¶
The prefix length tells us how many bits belong to the network.
Example:
Binary:
Equivalent subnet mask:
CIDR and Subnet Mask¶
| CIDR | Subnet Mask |
|---|---|
| /8 | 255.0.0.0 |
| /16 | 255.255.0.0 |
| /24 | 255.255.255.0 |
| /25 | 255.255.255.128 |
| /26 | 255.255.255.192 |
| /27 | 255.255.255.224 |
| /28 | 255.255.255.240 |
| /29 | 255.255.255.248 |
| /30 | 255.255.255.252 |
| /31 | 255.255.255.254 |
| /32 | 255.255.255.255 |
Network Bits vs Host Bits¶
Example:
Binary:
Network:
Host:
Host Calculation¶
Formula:
The subtraction accounts for the network and broadcast addresses.
Example: /24¶
Host bits:
Calculation:
Example: /26¶
Host bits:
Calculation:
Example: /30¶
Host bits:
Calculation:
A /30 network is commonly used for point-to-point links.
Common CIDR Blocks¶
| CIDR | Hosts |
|---|---|
| /30 | 2 |
| /29 | 6 |
| /28 | 14 |
| /27 | 30 |
| /26 | 62 |
| /25 | 126 |
| /24 | 254 |
| /23 | 510 |
| /22 | 1022 |
| /21 | 2046 |
| /20 | 4094 |
| /16 | 65,534 |
CIDR Example¶
Network:
Network Address:
Usable Hosts:
Broadcast:
Another Example¶
CIDR:
Network bits:
Host bits:
Hosts:
Why CIDR Replaced Classful Addressing¶
Classful addressing:
Suppose a company needs:
Class C:
Class B:
CIDR allows:
Much more efficient.
Route Summarisation¶
CIDR also supports Route Summarisation, where multiple networks are represented by a single route.
Example:
Instead of:
Summarise as:
Benefits:
- Smaller routing tables
- Faster routing decisions
- Reduced memory usage
CIDR in Cloud Computing¶
Cloud providers require CIDR blocks when creating virtual networks.
Examples:
AWS VPC:
Azure VNet:
Google Cloud VPC:
Administrators choose the prefix length based on expected network size.
CIDR in Kubernetes¶
Kubernetes uses CIDR extensively.
Examples:
Pod Network:
Service Network:
Each node receives a smaller CIDR block for Pod allocation.
CIDR in Enterprise Networks¶
Enterprise environments use CIDR for:
- Virtual Local Area Networks (VLANs)
- Branch Offices
- Virtual Private Network (VPN) Networks
- Server Networks
- Storage Networks
- Demilitarised Zones (DMZs)
Example:
CIDR Calculation Shortcut¶
| Prefix | Host Bits |
|---|---|
| /24 | 8 |
| /25 | 7 |
| /26 | 6 |
| /27 | 5 |
| /28 | 4 |
| /29 | 3 |
| /30 | 2 |
Remember:
Hands-on Lab¶
Task 1¶
Determine the subnet mask for:
Task 2¶
Calculate the number of usable hosts for:
Task 3¶
Convert the following subnet masks into CIDR notation:
Task 4¶
Determine the network and broadcast addresses for:
Task 5¶
Research the CIDR block used in your cloud lab or home network.
Task 6¶
Create a VPC design for:
- Web Tier
- Application Tier
- Database Tier
Assign appropriate CIDR blocks to each subnet.
Task 7¶
Use the ip addr command and identify the prefix length assigned to your network interface.
Task 8¶
For each of the following CIDR blocks, calculate:
- Subnet mask
- Total addresses
- Usable host addresses
Linux Commands¶
| Command | Purpose |
|---|---|
ip addr | Display IP address and prefix |
ip route | Display routing table |
hostname -I | Display assigned IP addresses |
ping | Test connectivity |
Common Mistakes¶
❌ Confusing CIDR with subnet masks.
✅ Learn both representations and convert between them.
❌ Forgetting the network and broadcast addresses.
✅ Subtract two usable addresses for most IPv4 subnets.
❌ Memorising host counts without understanding the formula.
✅ Practice using 2^(host bits) - 2.
❌ Assuming larger prefixes mean larger networks.
✅ Larger prefix numbers mean smaller networks.
❌ Ignoring future growth.
✅ Allocate CIDR blocks with room for expansion.
Best Practices¶
- Plan address space before deployment.
- Leave room for future growth.
- Use route summarisation where appropriate.
- Document all CIDR allocations.
- Avoid overlapping CIDR blocks.
- Choose subnet sizes based on actual requirements.
Interview Questions¶
Beginner¶
- What is CIDR?
- What does
/24mean? - What is the subnet mask for
/26? - Why was CIDR introduced?
Intermediate¶
- Calculate the number of hosts in a
/27network. - Explain the relationship between prefix length and subnet mask.
- Why does CIDR improve address utilisation?
- What is route summarisation?
Architect Level¶
- Design a CIDR plan for a multi-tier cloud application.
- Explain how CIDR reduces routing table size.
- How would you allocate CIDR blocks for a Kubernetes cluster and a cloud VPC?
Summary¶
In this lesson, you learned:
- What CIDR is
- CIDR notation
- Prefix lengths
- Network and host bits
- Host calculations
- CIDR-to-subnet mask conversion
- Route summarisation
- Cloud and Kubernetes networking with CIDR
CIDR is the foundation of modern IP networking. It provides flexible address allocation, minimises address wastage, enables efficient routing, and supports scalable enterprise and cloud network designs. Mastering CIDR is essential before learning subnetting and advanced IPv4 planning.
Key Takeaways¶
- CIDR replaces the old classful addressing system.
- The prefix length defines the network portion of an IP address.
- Host bits are calculated as 32 − Prefix Length.
- Usable hosts are calculated using 2^(Host Bits) − 2 (for traditional IPv4 subnets).
- CIDR enables efficient address allocation and route summarisation.