opyebCidrPlan

Designing AWS VPC subnets around five reserved IPs

Cloud · 7 min read

In one line: VPC CIDR is /16 to /28, five addresses are reserved in every subnet, and a /28 leaves only 11. Sizing rules, an availability-zone layout and Terraform.

When you create an AWS VPC the IPv4 CIDR must be between /16 (65,536 addresses) and /28 (16). Subnets follow the same limits, must sit inside the VPC range and cannot overlap. The console error "IPv4 block sizes must be between a /16 netmask and /28 netmask" is this rule being enforced.

Five addresses disappear per subnet

AWS adds three reservations to the textbook two (network and broadcast).

AddressReserved for
10.0.0.0Network address
10.0.0.1VPC router
10.0.0.2AWS DNS (VPC base plus two)
10.0.0.3Future use
10.0.0.255Broadcast — VPCs do not broadcast, but the address is held

So a /28 leaves 11 of 16 addresses for instances, a /27 leaves 27, a /26 leaves 59 and a /24 leaves 251. The smaller the subnet, the larger the share that disappears: 31% of a /28.

The real consumption is higher

Counting servers is not enough. Each instance can hold several elastic network interfaces and secondary IPs, and NAT gateways, Application Load Balancers, VPC endpoints, Lambda functions and EKS pods all take addresses. Size a subnet by every network interface it could ever host, not by today's server count.

A three-zone layout

A common split of 10.0.0.0/16 into public and private subnets across three availability zones.

SubnetCIDRUsablePurpose
public-a10.0.0.0/204,091ALB, bastion
public-b10.0.16.0/204,091ALB
public-c10.0.32.0/204,091ALB
private-a10.0.48.0/204,091apps and databases
private-b10.0.64.0/204,091apps and databases
private-c10.0.80.0/204,091apps and databases

Six /20 blocks end at 10.0.80.0/20, leaving everything from 10.0.96.0/20 onward free. Leaving a large contiguous remainder matters for later VPN attachments and VPC peering.

Carrying it into Terraform

locals {
  vpc_cidr = "10.0.0.0/16"
  azs      = ["ap-northeast-2a", "ap-northeast-2b", "ap-northeast-2c"]
  private  = { for i, az in local.azs :
               az => cidrsubnet(local.vpc_cidr, 4, i + 3) }
}

resource "aws_subnet" "private" {
  for_each          = local.private
  vpc_id            = aws_vpc.main.id
  cidr_block        = each.value
  availability_zone = each.key
}

cidrsubnet("10.0.0.0/16", 4, 3) adds four bits to make a /20 and selects block number three, which is 10.0.48.0/20. CidrPlan shows this calculation for every subnet in a split and generates the same code.

Everything is calculated in your browser. The ranges you type are not stored on a server.

Back to the CIDR calculator

Frequently asked questions

Can an AWS VPC be smaller than a /28?

No. Both VPCs and subnets need at least a /28. Five of its 16 addresses are reserved, leaving 11.

Do the five reservations apply to every subnet?

Yes: the first four and the last address of each subnet. A BYOIP range is the exception — there the first and last addresses can be used.

Can a subnet be resized later?

A VPC CIDR can only be added to, not shrunk, and a subnet CIDR cannot be changed after creation. Size generously at the start.

Sources

Read next