What is route table in VPC?
In a Virtual Private Cloud (VPC), a Route Table is the "Traffic Controller" or "GPS" of your network.
Every time a packet of data wants to leave a subnet, it checks the Route Table to find out which way to go. Without a route table, your servers would be like cars in a parking lot with no exit signs—they could see each other, but they couldn't get anywhere else.
A route table is essentially a simple spreadsheet. Each row is a Route consisting of two main parts:
Destination: Where do you want the data to go? (Usually expressed as a CIDR block like 0.0.0.0/0 for "the whole internet").
Target: What is the gateway or connection that gets it there? (e.g., an Internet Gateway, NAT Gateway, or Peering Connection).
Every route table has one unremovable rule: the Local Route. This rule matches your VPC’s own IP range (e.g., 10.0.0.0/16) and sets the target to "Local." This is what allows different subnets within the same VPC to talk to each other by default.
The Main Route Table: When you create a VPC, it comes with a "Main" table automatically. Any subnet you create is implicitly attached to this table unless you tell it otherwise.
Custom Route Tables: These are tables you create manually. Professionals usually create separate custom tables for Public and Private subnets to keep traffic strictly separated.
Destination: 0.0.0.0/0 (The Internet)
Target: igw-xxxxxxxx (Internet Gateway)
Result: Any server in this subnet can be reached by (and can reach) the public web.
Destination: 0.0.0.0/0 (The Internet)
Target: nat-xxxxxxxx (NAT Gateway)
Result: Servers can download updates from the internet, but the internet cannot "initiate" a call to them.
Destination: 172.31.0.0/16 (A friend's VPC)
Target: pcx-xxxxxxxx (VPC Peering Connection)
Result: Traffic destined for your partner's network stays on the private cloud backbone rather than going over the public internet.
What happens if a packet matches two different rules?
The computer always picks the most specific route.
If you have a rule for 0.0.0.0/0 (everyone) and a rule for 10.20.0.0/24 (a specific office), and you try to send data to 10.20.0.5, the route table will pick the second rule because it is a "tighter" fit (the longest prefix).
A Route Table doesn't "block" traffic (that's the job of Security Groups and NACLs); it simply directs it.