Designing VPC Address Space, Subnets and Route Tables
This lesson explains how VPC address space, subnets and routing fit together, since every architecture question involving servers or databases involves a VPC.
Learning outcomes
After completing this lesson, you will be able to:
- Explain how to plan VPC address space for growth and connectivity.
- Explain how subnets are placed across Availability Zones and tiers.
- Explain how route tables make a subnet public or private.
Address space
A VPC's address space must be planned carefully, because it limits how far the network can grow and determines whether it can connect to other networks. A VPC is Regional, with a primary IPv4 CIDR block between /16 and /28 in size, optional secondary CIDR blocks and optional IPv6.
VPCs should use private ranges, from RFC 1918, that do not overlap with on-premises networks or with other VPCs they may ever connect to, because overlapping ranges cannot be routed between; Amazon VPC IP Address Manager (IPAM) plans addresses across accounts to prevent overlaps. Room for growth matters too: a /16 VPC divided into /20 or /24 subnets for each tier in each Availability Zone is a common layout. Amazon EKS pods and ECS tasks in awsvpc mode each use one IP address, so container subnets need to be larger. A VPC that runs out of addresses can be extended with a secondary CIDR block and new subnets.
Sizing subnets
Subnets
A subnet is a range of addresses within a VPC, and it lives in exactly one Availability Zone, so a design that must survive the loss of a zone needs subnets in at least two. AWS reserves five addresses in every subnet: the network address, the VPC router, the DNS server, one for future use and the broadcast address. A /24 subnet therefore has 251 usable addresses, not 256, which matters when sizing small subnets.
Subnets are usually organised in tiers by how much exposure their resources need. The web tier is public and holds only what must be reachable from the internet, such as load balancers and NAT gateways. The application tier is private and holds instances or containers, which receive traffic only from the load balancer. The data tier is private with no route to the internet at all and holds databases, reachable only from the application tier. The following table summarises the tiers.
| Tier | Subnet | Contains |
|---|---|---|
| Web | Public | Load balancers, NAT gateways |
| Application | Private | Instances or containers |
| Data | Private, no internet route | Databases |
Repeat each tier in two or three AZs.
The following diagram shows the three tiers repeated in two Availability Zones.

Which tier?
Route tables
Every subnet is associated with a route table, which decides where traffic leaving the subnet goes. Whether a subnet is public or private is decided entirely by its default route, 0.0.0.0/0. In a public subnet, the default route points to an internet gateway, so resources with public IP addresses can reach, and be reached from, the internet. In a private subnet, the default route points to a NAT gateway, which allows outbound connections only, or there is no default route, so the subnet has no internet access at all. The following table summarises the rule.
| Subnet type | 0.0.0.0/0 route |
|---|---|
| Public | Internet gateway |
| Private | NAT gateway, or none |
The following list describes further characteristics of route tables.
- Every table has a
localroute for the VPC CIDR. - Routes can also target peering, transit gateways, virtual private gateways, gateway endpoints and appliances; the most specific route wins.
- Public-subnet instances need a public IPv4 or Elastic IP to be reachable; every public IPv4 address is charged.
The following diagram shows the route tables for the three kinds of subnet.

Planning a VPC for growth
A company is building its first production VPC. It expects to add hundreds of instances and containers, and to connect to on premises (10.0.0.0/16) later.
| Decision | Choice | Reason |
|---|---|---|
| VPC CIDR | 10.20.0.0/16 | Does not overlap with on premises; 65,536 addresses |
| Availability Zones | Three | High availability |
| Public subnets | Three /24s (one per AZ) | Load balancers and NAT gateways only |
| Private application subnets | Three /20s | Room for many instances and container tasks |
| Private database subnets | Three /24s | Databases isolated from the application tier |
AWS reserves five addresses in every subnet, and containers using awsvpc networking consume one IP each, which is why application subnets are sized generously. Choosing a CIDR that overlaps the on-premises network would make the later VPN or Direct Connect connection impossible to route.
What makes a subnet public?
Show answer
Its route table has a route to an internet gateway. Instances in it also need public IP addresses to be reached from the internet.
Exam Tips
Remember for the exam
- Five addresses are reserved in every subnet, so a /28 gives 11 usable addresses.
- A subnet is public only if its route table points to an internet gateway.
- Subnets belong to one Availability Zone, so spread each tier across at least two zones for high availability.
- Plan non-overlapping CIDRs before connecting VPCs or on-premises networks.
- When a VPC runs out of IP addresses, add a secondary CIDR and new subnets.
- Databases belong in private subnets with no route to the internet.