In your AWS VPC, routing tables act as the traffic directors. They decide where network traffic should go — whether it’s to another subnet, another VPC, or the internet. A well-configured routing table ensures smooth communication within your network and to the outside world.
In this article, we’ll take a deep dive into what routing tables are, how they work, and how to set them up effectively.
A routing table is a set of rules that governs how network traffic moves. Every resource in your VPC — like EC2 instances, databases, and load balancers — relies on routing tables to determine:
Think of your VPC as a city, and the routing table as its traffic management system:
To reach the internet:
0.0.0.0/0
(all traffic leaving the VPC).To communicate within the VPC:
10.0.1.0/24
(a subnet’s CIDR block).To connect with another VPC:
192.168.1.0/24
(the CIDR block of the peered VPC).Each routing table consists of one or more routes, and each route contains:
0.0.0.0/0
for the internet).Default Main Routing Table:
When you create a VPC, AWS automatically provides a main routing table. This table is applied to all subnets by default unless you explicitly associate them with a custom routing table.
Custom Routing Tables:
You can create custom routing tables to handle specific traffic flows. For example:
Local routing is AWS’s built-in feature that allows resources within the same VPC to communicate with each other automatically, without requiring user-defined routes.
AWS creates a local route in every routing table for the VPC’s CIDR block.
Destination: 10.0.0.0/16
Target: local
This local route enables intra-VPC communication. For example:
10.0.1.0/24
) can talk to an RDS database in Subnet B (10.0.2.0/24
) automatically, as long as security groups and NACLs permit the traffic.You don’t need to define local routes manually. AWS handles this for you when the VPC is created.
Intra-:
The prefix "intra" means within. It refers to communication, interaction, or activity happening inside the same group, system, or boundary.
Inter-:
The prefix "inter" means between. It refers to communication, interaction, or activity happening between two or more separate groups, systems, or boundaries.
Resources such as EC2 instances in different subnets of the same VPC communicating with each other.
Example:
10.0.1.0/24
) communicating with an RDS database in Subnet B (10.0.2.0/24
).Resources in one VPC communicating with resources in another VPC.
Example:
10.0.0.0/16
) communicating with an S3 bucket or another instance in VPC 2 (192.168.0.0/16
).Communication between resources in different VPCs or services (like Lambda and DynamoDB) that are in the same region.
Example:
10.0.0.0/16
) communicating with DynamoDB in the same region.Communication between resources located in different AWS regions.
Example:
us-east-1
communicating with an application server in eu-west-1
.Think of "intra" and "inter" like neighborhoods and cities:
PublicRoutingTable
).0.0.0.0/0
10.0.0.0/16
).0.0.0.0/0
).Next, we’ll dive into NAT Gateways and Internet Gateways — the bridges that connect your VPC to the outside world while keeping things secure.