What is CIDR Notation?
CIDR (Classless Inter-Domain Routing) notation is a compact way to represent an IP address and its associated network mask. It consists of an IP address followed by a slash and a prefix length number, like 192.168.1.0/24.
The prefix length (the number after the slash) indicates how many bits of the IP address represent the network portion. The remaining bits are used to identify individual hosts within that network.
Understanding IP Address Structure
An IPv4 address is 32 bits, written as four octets (groups of 8 bits) in decimal notation:
192.168.1.100
= 11000000.10101000.00000001.01100100
←─── 32 bits total ───────────────→How the Prefix Length Works
In 192.168.1.0/24, the /24 means the first 24 bits are the network address and the remaining 8 bits identify hosts:
192.168.1.0/24
11000000.10101000.00000001 | 00000000
←────── Network (24 bits) ──────────→ ←── Host (8 bits) ──→Key Subnet Calculations
From a CIDR block, you can calculate several important values:
| Value | Formula | Example (/24) |
|---|---|---|
| Total addresses | 2^(32 - prefix) | 2^8 = 256 |
| Usable hosts | Total - 2 | 256 - 2 = 254 |
| Network address | First IP in range | 192.168.1.0 |
| Broadcast address | Last IP in range | 192.168.1.255 |
| First usable host | Network + 1 | 192.168.1.1 |
| Last usable host | Broadcast - 1 | 192.168.1.254 |
Common CIDR Blocks Reference
| CIDR | Subnet Mask | Total Hosts | Usable Hosts | Common Use |
|---|---|---|---|---|
| /32 | 255.255.255.255 | 1 | 0 | Single host route |
| /30 | 255.255.255.252 | 4 | 2 | Point-to-point links |
| /29 | 255.255.255.248 | 8 | 6 | Small segments |
| /28 | 255.255.255.240 | 16 | 14 | Small office |
| /27 | 255.255.255.224 | 32 | 30 | Small department |
| /26 | 255.255.255.192 | 64 | 62 | Medium subnet |
| /25 | 255.255.255.128 | 128 | 126 | Large subnet |
| /24 | 255.255.255.0 | 256 | 254 | Standard LAN |
| /23 | 255.255.254.0 | 512 | 510 | Large LAN |
| /22 | 255.255.252.0 | 1,024 | 1,022 | Campus network |
| /16 | 255.255.0.0 | 65,536 | 65,534 | Large organization |
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | ISP allocation |
Private IP Address Ranges
RFC 1918 defines three ranges of private IP addresses for use within organizations:
| Range | CIDR | Addresses |
|---|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | 16,777,216 |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | 1,048,576 |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | 65,536 |
Subnetting Example
Suppose you have the network 10.0.0.0/8 and need to divide it into smaller subnets for different departments:
Department A (500 hosts needed) → 10.1.0.0/23 (510 usable)
Department B (200 hosts needed) → 10.2.0.0/24 (254 usable)
Department C (50 hosts needed) → 10.3.0.0/26 (62 usable)
Point-to-point link → 10.4.0.0/30 (2 usable)✓ Tip: To find the right prefix length for a required number of hosts, use the formula: prefix = 32 - ceil(log2(hosts + 2)). For 100 hosts: 32 - ceil(log2(102)) = 32 - 7 = /25 (126 usable hosts).
CIDR in Cloud Environments
CIDR notation is fundamental in cloud networking. When you create a VPC (Virtual Private Cloud) in AWS, Azure, or GCP, you assign a CIDR block that defines the IP address space for the entire virtual network. Subnets within the VPC are smaller CIDR blocks carved from the VPC range.
VPC: 10.0.0.0/16 (65,534 addresses)
Public Subnet: 10.0.1.0/24 (254 addresses)
Private Subnet: 10.0.2.0/24 (254 addresses)
Database Subnet: 10.0.3.0/24 (254 addresses)