How CIDR Notation Works (Classless Inter-Domain Routing)
Before CIDR was introduced in 1993 (RFC 1519), the Internet allocated IPv4 space using rigid classful boundaries: Class A (/8), Class B (/16), and Class C (/24). This caused catastrophic IP address wastage, as an organization needing 500 addresses had to receive a Class B allocation of 65,536 addresses.
CIDR allows variable-length subnet masking (VLSM). The prefix length (the number following the slash, e.g., /20) designates how many bits from the 32-bit IPv4 address belong to the network prefix. The remaining 32 - prefix bits represent available host addresses:
The AWS 5-IP Reservation Rule in VPC Subnets
A frequent pitfall for DevOps engineers migrating to Amazon Web Services is assuming that a /28 subnet yields 14 usable addresses. In an AWS VPC, Amazon reserves 5 IP addresses in every subnet:
| Offset | Example (10.0.1.0/24) | Dedicated Purpose & Behavior |
|---|---|---|
| .0 | 10.0.1.0 | Network Address: Reserved by Internet Protocol standards. |
| .1 | 10.0.1.1 | VPC Default Router: Gateway route target for traffic leaving the subnet. |
| .2 | 10.0.1.2 | Amazon-Provided DNS: Route 53 Resolver (VPC base IP + 2). |
| .3 | 10.0.1.3 | AWS Future Use: Reserved by AWS for infrastructure expansion. |
| .255 | 10.0.1.255 | Network Broadcast Address: AWS VPC does not support broadcast, but reserves this IP. |
Consequently, the smallest subnet AWS allows is /28 (16 total IPs minus 5 = 11 usable EC2/ENI hosts). The largest allowed VPC CIDR is /16 (65,536 IPs).
Designing a Scalable Multi-AZ VPC Architecture
When provisioning an enterprise VPC across 3 Availability Zones (AZ-a, AZ-b, AZ-c), adopt a modular /16 partition scheme:
- Public Ingress Subnets (
/22, 1,024 IPs): Hosting Internet-facing Application Load Balancers (ALB) and NAT Gateways across 3 AZs (e.g.,10.0.0.0/22,10.0.4.0/22,10.0.8.0/22). - Private Application Workloads (
/20, 4,096 IPs): Hosting Kubernetes EKS Pods, ECS Fargate tasks, and EC2 auto-scaling instances. Container network interfaces (AWS VPC CNI) consume 1 IP per pod, demanding large subnets. - Isolated Data Subnets (
/24, 256 IPs): Zero internet access. Dedicated to Amazon Aurora, RDS multi-AZ databases, and ElastiCache clusters. - Spare Capacity (
/18): Preserved for future hybrid cloud expansion, local zones, or direct connect peering without CIDR exhaustion.
IPv4 Subnet & CIDR Cheatsheet Table
| Prefix | Subnet Mask | Total IPs | Usable Hosts | AWS VPC Usable | Typical Deployment Use Case |
|---|---|---|---|---|---|
| /16 | 255.255.0.0 | 65,536 | 65,534 | 65,531 | Standard AWS / GCP VPC Root Network |
| /18 | 255.255.192.0 | 16,384 | 16,382 | 16,379 | Large Kubernetes Pod Network Block |
| /20 | 255.255.240.0 | 4,096 | 4,094 | 4,091 | High-density Microservice Private Subnet |
| /22 | 255.255.252.0 | 1,024 | 1,022 | 1,019 | Multi-AZ Public Load Balancer Subnet |
| /24 | 255.255.255.0 | 256 | 254 | 251 | Class C / Standard Database Subnet |
| /26 | 255.255.255.192 | 64 | 62 | 59 | VPN Gateway & Bastion Host Subnet |
| /28 | 255.255.255.240 | 16 | 14 | 11 | Minimum Allowed AWS VPC Subnet Size |
| /30 | 255.255.255.252 | 4 | 2 | 0 (N/A) | Point-to-Point Router Interconnects |
| /32 | 255.255.255.255 | 1 | 1 | 1 | Single Host Route / Security Group Ingress |
AWS VPC & Cloud Provider Reserved IP Rules
In traditional networking, two IP addresses are reserved in any subnet (network & broadcast). However, in Amazon Web Services (AWS VPC), five IP addresses are strictly reserved in every subnet (tested in AWS Platform Interviews):
10.0.1.0— Network address (cannot be assigned to instances).10.0.1.1— VPC router / default gateway.10.0.1.2— Amazon-provided DNS (Route 53 Resolver).10.0.1.3— Reserved by AWS for future use.10.0.1.255— Network broadcast address.
Automating Subnet Partitioning with Terraform cidrsubnet()
Instead of hardcoding brittle IP blocks (see IaC Best Practices and Terraform Best Practices), use cidrsubnet() to divide a /16 supernet across Availability Zones:
Troubleshoot packet drops and CNI route tables with our Container Networking Troubleshooting Guide, validate configurations with the YAML Validator, and explore cloud transit routing in our AWS Interview Hub.