DEVOPS TRIBUNE ENGINEERING INTELLIGENCE FOR THE REAL WORLD
NETWORKING • CLOUD VPC • K8S CNI

IPv4 CIDR & Subnet Calculator

Calculate subnet masks, broadcast boundaries, usable host ranges, and AWS VPC 5-IP reserved allocations. Partition VPCs into multi-AZ tiers and verify overlapping IP ranges for peering.

Presets:
Total Addresses
65,536
Standard Usable Hosts
65,534
AWS VPC Usable Hosts
65,531
(Minus 5 AWS Reserved)
Subnet Mask
255.255.0.0
CIDR Notation 10.0.0.0/16
Network Address 10.0.0.0
Broadcast Address 10.0.255.255
Standard Usable IP Range 10.0.0.1 → 10.0.255.254
AWS VPC Usable IP Range 10.0.0.4 → 10.0.255.254
Subnet Mask 255.255.0.0
Wildcard (Inverse) Mask 0.0.255.255
IP Type / Scope Private Network (RFC 1918)
Binary Netmask 11111111.11111111.00000000.00000000

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:

# Calculating Available Host Addresses Formula:
Total IPs = 2^(32 - Prefix)
Standard Usable Hosts = 2^(32 - Prefix) - 2 (Network + Broadcast reserved)
AWS VPC Usable Hosts = 2^(32 - Prefix) - 5 (AWS reserves 5 IPs per subnet)

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:

terraform-vpc-subnets.tf — Dynamic Multi-AZ Subnet Allocation
variable "vpc_cidr" {
  default = "10.100.0.0/16"
}

# 3 public subnets (/20 each, allowing 4,091 usable IPs per AZ)
resource "aws_subnet" "public" {
  count             = 3
  vpc_id            = aws_vpc.main.id
  cidr_block        = cidrsubnet(var.vpc_cidr, 4, count.index)
  availability_zone = data.aws_availability_zones.available.names[count.index]
}

# 3 private subnets starting at offset 4 (/20 each)
resource "aws_subnet" "private" {
  count             = 3
  vpc_id            = aws_vpc.main.id
  cidr_block        = cidrsubnet(var.vpc_cidr, 4, count.index + 4)
  availability_zone = data.aws_availability_zones.available.names[count.index]
}

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.

Companion Technical Guides & Hands-On Tools

Cross-reference this developer utility with production architectural runbooks and interview scenarios.

Networking Triage

Container Networking Troubleshooting

Debug flannel, Calico, AWS-VPC CNI, iptables packet drops, and MTU bugs.

IaC Best Practices

Production Terraform Best Practices

VPC CIDR module patterns, remote state locking, and multi-account transit routing.

Interactive Utility

Config & Manifest Diff Checker

Compare network route tables, security group rules, and CIDR lists side-by-side.

Interview Track

AWS Cloud Architecture Interview Hub

12 scenarios covering Transit Gateway routing, VPC Peering, and PrivateLink.