SkillSprout
Chapter 4 · Lesson 3
Intermediate
7 min read

Route Tables

Overview

A route table is a set of rules, called routes, that tells the VPC router where to send network traffic leaving a subnet or gateway. Each route has a destination (a CIDR range) and a target (such as an Internet Gateway, NAT Gateway, peering connection, Transit Gateway or virtual private gateway).

Every subnet must be associated with exactly one route table. If you do not associate one explicitly, the subnet uses the VPC's main route table. Every route table automatically contains a local route for the VPC CIDR, which lets all resources in the VPC talk to each other and cannot be deleted.

Route tables are how you create public, private and isolated subnets, how you send traffic to on-premises networks, and how you steer traffic through inspection appliances. Understanding which route wins when several match is a classic exam topic.

Key Concepts

  • Every VPC has a main route table; new subnets use it unless you explicitly associate another table.
  • The local route (VPC CIDR -> local) is always present and cannot be removed or overridden by a less specific route.
  • Longest prefix match wins: the most specific route (highest prefix number) is chosen regardless of order.
  • A subnet has one route table, but one route table can serve many subnets.
  • Route propagation lets a virtual private gateway (VPN/Direct Connect) or Transit Gateway attachment automatically add routes.
  • A route whose target was deleted becomes a blackhole and silently drops traffic.
  • Gateway route tables (edge associations) attach to an IGW or VGW to inspect/redirect inbound traffic, e.g. to a firewall appliance.
  • On a tie, static routes beat propagated routes; among propagated routes, Direct Connect > static VPN > BGP VPN.
  • Routing is not transitive through peering connections or gateway endpoints.

Detailed Notes

Anatomy of a route table

DestinationTargetMeaning
10.0.0.0/16localIntra-VPC traffic (implicit, always first)
0.0.0.0/0igw-0a1b2cDefault route to the internet (public subnet)
0.0.0.0/0nat-0d4e5fDefault route via NAT (private subnet)
172.16.0.0/16pcx-0987Traffic to a peered VPC
192.168.0.0/16vgw-0123Traffic to on-premises over VPN/DX
pl-63a5400avpce-0abcPrefix list route to S3 gateway endpoint
::/0eigw-0abcIPv6 outbound-only via egress-only IGW

Main vs. custom route tables

  • The main route table is the default for any subnet without an explicit association. Best practice is to leave the main table private (local route only) so a newly created subnet is never accidentally public.
  • Custom route tables are created for specific subnets, for example public-rt with an IGW route.
  • You can change which table is main, but you cannot delete the main table.

Route selection: longest prefix match

When multiple routes match a destination, AWS chooses the most specific route.

text
Packet to 10.0.5.20
  10.0.0.0/16 -> local         (matches, /16)
  0.0.0.0/0   -> nat-xyz       (matches, /0)
Winner: local  (/16 is more specific than /0)

Packet to 172.16.5.9
  172.16.0.0/16 -> pcx-1       (/16)
  172.16.5.0/24 -> tgw-9       (/24)
Winner: tgw-9  (/24 is longer)

If prefixes are equal, priority is: local route, then static routes, then propagated routes (Direct Connect BGP, then static VPN, then BGP VPN).

Route propagation

Enable route propagation on a route table and AWS automatically installs routes learned from a virtual private gateway (BGP-advertised on-premises prefixes) or, via Transit Gateway route tables, from attachments. This removes manual maintenance and the risk of stale entries. A route table supports up to 50 non-propagated routes by default (adjustable to 1,000) and 100 propagated routes; if on-premises advertises more than 100 prefixes, summarise them.

Gateway route tables (edge associations)

A route table can be associated with an Internet Gateway or virtual private gateway instead of a subnet. This lets you redirect traffic entering the VPC to a middlebox ENI (for example an inspection firewall or Gateway Load Balancer endpoint) before it reaches the workload — "ingress routing".

Common patterns

Public subnet

bash
aws ec2 create-route --route-table-id rtb-public --destination-cidr-block 0.0.0.0/0 --gateway-id igw-0a1b2c
aws ec2 associate-route-table --route-table-id rtb-public --subnet-id subnet-pub-a

Private subnet with egress, one table per AZ

bash
aws ec2 create-route --route-table-id rtb-private-a --destination-cidr-block 0.0.0.0/0 --nat-gateway-id nat-az-a

Isolated subnet

Only the local route — no IGW or NAT. Add a gateway endpoint prefix-list route if it needs S3 or DynamoDB.

Limits and behaviours to remember

ItemDefault limit
Route tables per VPC200
Non-propagated routes per table50 (up to 1,000)
Propagated routes per table100
Route table associations per route table50
  • You cannot delete or replace the local route; you can only add more specific routes inside the VPC CIDR that point to a network interface or GWLB endpoint for inspection designs.
  • Peering and endpoints are not transitive — a route to a peered VPC does not give access to that VPC's internet gateway or VPN.
  • Deleting a NAT Gateway or peering connection leaves a blackhole route; remove or replace it.

Troubleshooting

Use Reachability Analyzer to see exactly which route table entry is missing, and VPC Flow Logs to confirm packets reach the ENI. Check both directions: return traffic needs a route back to the source CIDR as well.

Real World Example

Scenario — a retailer inspects all inbound traffic with a third-party firewall.

A retail platform must pass every internet request through a next-generation firewall before it hits the web tier. They deploy Gateway Load Balancer endpoints in dedicated "inspection" subnets in each AZ.

The team creates an edge-associated (gateway) route table on the Internet Gateway. Its routes say: for each public subnet CIDR, the target is the GWLB endpoint in the same AZ. The public subnet's own route table sends 0.0.0.0/0 to the same endpoint for outbound traffic, so replies are inspected symmetrically.

On-premises ranges arrive through a virtual private gateway with route propagation enabled, so when the data-centre team advertises a new /24 over BGP, the route appears automatically. Because the on-premises 10.50.0.0/16 and a peered analytics VPC's 10.50.7.0/24 overlap in the table, longest prefix match routes only the /24 to the peering connection, and everything else in 10.50.0.0/16 to the VPN. The setup keeps routing predictable and audit-friendly.

Architecture Diagram

Route tables steering public, private and hybrid traffic
Architecture
AWS Cloud
VPC 10.0.0.0/16
Public subnet
Public RT0.0.0.0/0 -> IGW
NAT Gateway
Private subnet
Private RT0.0.0.0/0 -> NAT
App servers
Isolated subnet
Isolated RTlocal only
Database
Internet Gateway
Virtual Private Gatewaypropagated routes
Peering connection172.16.0.0/16
Internet
On-premises192.168.0.0/16

Each subnet uses the route table that defines where its 0.0.0.0/0 and on-premises traffic goes.

  1. 1Traffic leaving a subnet is evaluated against that subnet's route table; the most specific matching route wins.
  2. 2Public RT: VPC CIDR stays local, 0.0.0.0/0 goes to the Internet Gateway.
  3. 3Private RT: 0.0.0.0/0 goes to the NAT Gateway in a public subnet, which then uses the IGW.
  4. 4Isolated RT has only the local route; on-premises prefixes (192.168.0.0/16) appear through VGW propagation where needed.

Best Practices

  • ✓Keep the main route table private (local route only) and use explicit custom tables for public subnets.
  • ✓Use one private route table per AZ when each AZ has its own NAT Gateway so traffic stays zonal.
  • ✓Enable route propagation for VPN/Direct Connect instead of maintaining on-premises prefixes by hand.
  • ✓Summarise routes on-premises to stay under the 100 propagated-route limit.
  • ✓Use prefix lists for repeated CIDR groups and for AWS-managed service ranges instead of many individual routes.
  • ✓Clean up blackhole routes after deleting NAT Gateways, peering connections or attachments.
  • ✓Use gateway route tables for centralised ingress inspection with Gateway Load Balancer.
  • ✓Manage routes as code and review changes; a wrong default route can take down an entire environment.

Common Interview Questions

Exam Tips

SAA-C03 focus

  • Longest prefix match decides between overlapping routes — the most specific wins.
  • The local route is mandatory and cannot be deleted.
  • A subnet is public only when its route table has 0.0.0.0/0 -> IGW.
  • New subnets use the main route table by default — a classic "why is my new subnet public/private?" trap.
  • Static routes beat propagated routes on equal prefixes; for propagated, Direct Connect is preferred over VPN.
  • Peering is non-transitive: adding a route is not enough to reach a third network through a peer.
  • A VPN/Direct Connect VGW supports up to 100 propagated routes (summarise on-premises prefixes).
  • For inbound traffic inspection before the workload, think gateway route table + Gateway Load Balancer.

Finished this lesson?

0 of 64 lessons done · 0% of the course