Amazon VPC Route tables
Amazon defines A route table containing a set of rules, called routes, that are used to determine where network traffic from your subnet or gateway is directed.
When a network packet arrives at a Router, it determines the destination IP address of a received packet and makes the routing decisions to send a packet to its destination.
The following diagram shows the main route table associated with private subnet and A custom route table is explicitly associated with the public subnet. The custom route table informs the internet gateway to direct internet (0.0.0.0/0) traffic to the public subnet.
Main Route Table
When you create a VPC, automatically a default route table is associated with your VPC, known as the Main Route Table. It controls the routing for all subnets that are not explicitly associated with any other route table.
Custom Route Table
You can create a custom route table for your VPC and you can add, remove, and modify the routes. One way to protect your VPC is to leave the main route table without any modification and then explicitly associate the subnet with a custom route table as per your requirement. Custom route table helps to control how each subnet routes traffic.
Important points about Route Tables
- Each subnet must be associated with a route table which controls the routing for the subnet .
- A subnet can only be associated with one route table at a time, While you multiple subnets can be associated with the same route table.
- You cannot set a gateway route table as the main route table.
- Main route table contains only a local route (i.e. communication within the VPC).
- You cannot delete the main route table.
- You can replace the main route table with a custom route table.
- By default main route table route contains only a local route and you can add, remove, and modify the routes .
- By default Custom route table is empty and you can add, remove, and modify the routes .
- Routes to IPv4 and IPv6 addresses or CIDR blocks are independent of each other.
- For more information: Route Table User Guide