VPC, Subnets, and Route Tables

Topics Covered

VPC Fundamentals

What a VPC is

CIDR blocks and address planning

Reserved addresses

Availability zones and subnets

Public and private subnets

IPv6

A Virtual Private Cloud is a logically isolated network inside an AWS region, where a team decides the IP address ranges, carves them into subnets, controls routing, and attaches gateways to the internet and to other networks. Almost every compute resource on AWS, from EC2 instances to Lambda functions that need private access, RDS databases and load balancers, lives in a VPC. The network design is usually set once and lived with for years, because changing address ranges or subnet layouts under running workloads is disruptive. Getting the fundamentals right at the start saves painful migrations later.

What a VPC is

A VPC spans every Availability Zone in its region and is isolated from all other VPCs by default: no traffic flows in or out until a team adds a gateway, a peering connection, a transit gateway attachment or an endpoint. Inside the VPC, AWS provides the routing between subnets, DNS resolution, and the DHCP options that hand out addresses. There are no routers or switches to manage, and the VPC itself costs nothing; charges come from what runs in it and from gateways, endpoints and data transfer. Each account receives a default VPC in each region for convenience, but production workloads normally live in VPCs designed for them.

A VPC is also a security boundary in the sense that matters for audits. Traffic between two VPCs never flows unless someone builds a path, and those paths, gateways, peerings, attachments and endpoints, are visible in configuration. Reviewing what can reach a VPC therefore means reviewing a short list of attachments rather than tracing cables. That property is why many organisations give each application or environment its own VPC, sometimes in its own account, and connect them deliberately rather than putting everything in one large shared network.

CIDR blocks and address planning

A VPC has one or more IPv4 address ranges written in CIDR notation, such as 10.20.0.0/16, which covers 65,536 addresses. The allowed size ranges from a /16 down to a /28 of sixteen addresses, and secondary ranges can be added later, up to a limit per VPC. Ranges should come from the private address space defined in RFC 1918, 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16, and must not overlap with any network the VPC will ever connect to: other VPCs, on premises data centres, partner networks or VPN clients. Overlapping ranges cannot be routed between, and fixing an overlap after the fact usually means rebuilding one of the networks.

The most common planning mistake is choosing 10.0.0.0/16 for every VPC because it is the console default. That works until two of those VPCs need to talk, or a merger brings in a data centre using the same range. A simple plan allocates a distinct block per region, per environment and per account from a central register, such as 10.0.0.0/12 for production in one region, divided into /16 or smaller VPCs. Writing the plan down before the second VPC is created is far cheaper than renumbering later.

One central plan gave every VPC its own range. Two teams that had both picked 10.0.0.0/16 could never have been connected without renumbering.

A useful sanity check for any plan is to ask how many VPCs the organisation could plausibly run in five years and in how many regions, then confirm the plan leaves room for all of them with ranges to spare. A /16 per VPC sounds generous, but the 10.0.0.0/8 space holds only 256 of them, and an organisation with hundreds of accounts can exhaust it. Smaller VPCs, such as /20 for most workloads and /16 only for container heavy platforms, stretch the space much further. The register should record the owner, purpose and environment of every allocation, so that a range can be reclaimed confidently when its VPC is deleted.

Reserved addresses

AWS reserves five addresses in every subnet: the network address, the first three addresses after it for the VPC router, DNS and future use, and the last address. A /24 subnet therefore offers 251 usable addresses, and a /28 only eleven. Small subnets lose a large share to reservations, which matters when sizing subnets for services that consume many addresses. Each Lambda function in a VPC, each EKS pod with the default VPC CNI, each load balancer node and each interface endpoint uses addresses, and these add up faster than teams expect.

Reserved addresses are only part of the overhead. AWS services that place network interfaces in a subnet, such as load balancers, NAT gateways, interface endpoints, RDS instances and EFS mount targets, each take addresses that a team did not launch directly. A load balancer can add interfaces as it scales, and an interface endpoint takes one address per subnet it serves. Counting these hidden consumers when sizing subnets avoids the confusing case where a subnet that looks half empty in the instance list has, in fact, almost no free addresses left.

Availability zones and subnets

A subnet is a range of addresses within the VPC that lives in exactly one Availability Zone. Resources launched into a subnet are physically in that zone, so building for availability means creating matching subnets in at least two zones, usually three, and spreading each tier across them. A typical layout has one public subnet and one or more private subnets per zone, such as a private application tier and a private data tier, each with the same size in every zone so capacity is symmetric when one zone fails.

Zone names such as us-east-1a map to different physical zones in different accounts, so teams coordinating across accounts should use zone IDs such as use1-az1, which are consistent. This matters when two accounts want their resources in the same physical zone to avoid cross zone data transfer charges, or when a service is only available in certain zones. Checking zone IDs before choosing which zones to use avoids subtle surprises with capacity and pricing.

Subnet size should follow from what the tier runs, not from habit. A data tier holding a handful of database instances and their replicas needs few addresses, while an application tier running containers or VPC attached Lambda functions may need thousands. Teams also leave unallocated space in each VPC for tiers they have not thought of yet, such as a subnet for interface endpoints, a subnet for a firewall, or a subnet for a new service. Because subnets cannot be resized, a VPC whose range is fully carved into subnets on day one has no room to adapt, and the only option later is a secondary CIDR, which adds routing and planning complexity.

Public and private subnets

AWS has no setting that makes a subnet public. A subnet is called public when its route table sends internet bound traffic to an internet gateway, and private when it does not. Instances in a public subnet still need a public IPv4 address or an Elastic IP to be reachable from the internet, and security groups still decide what traffic is allowed. Load balancers facing the internet and NAT gateways live in public subnets. Application servers, databases and most other resources belong in private subnets, reaching the internet, if they need it, through NAT.

Many teams also separate tiers into different subnets for reasons beyond routing. Distinct subnets let network ACLs draw coarse boundaries, let flow logs and reachability checks speak in terms of tiers, and let IP utilisation alarms target the tier that is actually growing. They also make it obvious, from a resource's address alone, which tier it belongs to, which speeds up incident investigation. A common layout per zone is one small public subnet, one large private application subnet and one medium private data subnet, repeated identically across three zones, with spare ranges left for later.

IPv6

VPCs can also have IPv6 ranges, either Amazon provided /56 blocks or ranges a team brings, with each subnet receiving a /64. IPv6 addresses are globally unique, so there is no NAT; instead, an egress only internet gateway lets private resources make outbound IPv6 connections while blocking inbound ones. Dual stack subnets carry both families, and IPv6 only subnets avoid IPv4 exhaustion entirely for workloads whose dependencies support it. Because AWS charges for public IPv4 addresses, IPv6 is increasingly attractive for internet facing workloads.

Plan addresses before the second VPC

Allocate non overlapping ranges per region, environment and account from one register, size subnets for the addresses each tier will really consume, spread every tier across at least two zones, and remember that public means a route to an internet gateway, nothing more.