Change a subnet route table
This section explains how to work with route tables. Note that this section is a grouping of procedures all related to making changes in subnet route table.
Contents
Determine the route table for a subnet
You can determine which route table a subnet is associated with by looking at the subnet details in the Amazon VPC console.
To determine the route table for a subnet
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Subnets.
-
Select the subnet.
-
Choose the Route table tab to view information about the route table and its routes. To determine whether the association is to the main route table, and if that association is explicit, see Determine which subnets and or gateways are explicitly associated.
Determine which subnets and or gateways are explicitly associated
You can determine how many and which subnets or gateways are explicitly associated with a route table.
The main route table can have explicit and implicit subnet associations. Custom route tables have only explicit associations.
Subnets that aren't explicitly associated with any route table have an implicit association with the main route table. You can explicitly associate a subnet with the main route table. For an example of why you might do that, see Replace the main route table.
To determine which subnets are explicitly associated using the console
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Route tables.
Check the Explicit subnet association column to determine the explicitly associated subnets and the Main column to determine whether this is the main route table.
-
Select the route table and choose the Subnet associations tab.
-
The subnets under Explicit subnet associations are explicitly associated with the route table. The subnets under Subnets without explicit associations belong to the same VPC as the route table, but are not associated with any route table, so they are implicitly associated with the main route table for the VPC.
To determine which gateways are explicitly associated using the console
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Route tables.
-
Select the route table and choose the Edge associations tab.
To describe one or more route tables and view its associations using the command line
-
describe-route-tables (Amazon CLI)
-
Get-EC2RouteTable (Amazon Tools for Windows PowerShell)
Create a custom route table
You can create a custom route table for your VPC using the Amazon VPC console.
Note
There is a quota on the number of route tables that you can create per VPC. There is also a quota on the number of routes that you can add per route table. For more information, see Amazon VPC quotas.
To create a custom route table using the console
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Route tables.
-
Choose Create route table.
-
(Optional) For Name, enter a name for your route table.
-
For VPC, choose your VPC.
-
(Optional) To add a tag, choose Add new tag and enter the tag key and tag value.
-
Choose Create route table.
To create a custom route table using the command line
-
create-route-table (Amazon CLI)
-
New-EC2RouteTable (Amazon Tools for Windows PowerShell)
Add and remove routes from a route table
You can add, delete, and modify routes in your route tables. You can only modify routes that you've added.
For more information about working with static routes for a Site-to-Site VPN connection, see Editing Static Routes for a Site-to-Site VPN Connection in the Amazon Site-to-Site VPN User Guide.
Note
There is a quota on the number of route tables that you can create per VPC. There is also a quota on the number of routes that you can add per route table. For more information, see Amazon VPC quotas.
To update the routes for a route table using the console
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Route tables, and select the route table.
-
Choose Actions, Edit routes.
-
To add a route, choose Add route. For Destination enter the destination CIDR block, a single IP address, or the ID of a prefix list.
-
To modify a route, for Destination, replace the destination CIDR block or single IP address. For Target, choose a target.
-
To delete a route, choose Remove.
-
Choose Save changes.
To update the routes for a route table using the command line
-
create-route (Amazon CLI)
-
replace-route (Amazon CLI)
-
delete-route (Amazon CLI)
-
New-EC2Route (Amazon Tools for Windows PowerShell)
-
Set-EC2Route (Amazon Tools for Windows PowerShell)
-
Remove-EC2Route (Amazon Tools for Windows PowerShell)
Note
If you add a route using a command line tool or the API, the destination CIDR
block is automatically modified to its canonical form. For example, if you
specify 100.68.0.18/18
for the CIDR block, we create a route with a
destination CIDR block of 100.68.0.0/18
.
Enable or disable route propagation
Route propagation allows a virtual private gateway to automatically propagate routes to your route tables. This means that you don't need to manually add or remove VPN routes.
To complete this process, you must have a virtual private gateway.
For more information, see Site-to-Site VPN routing options in the Site-to-Site VPN User Guide.
To enable route propagation using the console
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. In the navigation pane, choose Route tables, and then select the route table.
-
Choose Actions, Edit route propagation.
Select the Enable check box next to the virtual private gateway, and then choose Save.
To enable route propagation using the command line
-
enable-vgw-route-propagation (Amazon CLI)
-
Enable-EC2VgwRoutePropagation (Amazon Tools for Windows PowerShell)
To disable route propagation using the console
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. In the navigation pane, choose Route tables, and then select the route table.
Choose Actions, Edit route propagation.
-
Clear the Enable check box next to the virtual private gateway, and then choose Save.
To disable route propagation using the command line
-
disable-vgw-route-propagation (Amazon CLI)
-
Disable-EC2VgwRoutePropagation (Amazon Tools for Windows PowerShell)
Change the route table for a subnet
You can change the route table association for a subnet.
When you change the route table, your existing connections in the subnet are dropped unless the new route table contains a route for the same traffic to the same target.
To change a subnet route table association using the console
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Subnets, and then select the subnet.
-
From the Route table tab, choose Edit route table association.
-
For Route table ID, select the new route table.
-
Choose Save.
To change the route table associated with a subnet using the command line
-
replace-route-table-association (Amazon CLI)
-
Set-EC2RouteTableAssociation (Amazon Tools for Windows PowerShell)
Associate or disassociate a subnet with a route table
To apply route table routes to a particular subnet, you must associate the route table with the subnet. A route table can be associated with multiple subnets. However, a subnet can only be associated with one route table at a time. Any subnet not explicitly associated with a table is implicitly associated with the main route table by default.
You can disassociate a subnet from a route table. Until you associate the subnet with another route table, it's implicitly associated with the main route table.
To associate or disassociate a route table with a subnet using the console
-
Open the Amazon VPC console at https://console.amazonaws.cn/vpc/
. -
In the navigation pane, choose Route tables, and then select the route table.
-
On the Subnet associations tab, choose Edit subnet associations.
-
Select or deselect the check box for the subnet to associate with the route table.
-
Choose Save associations.
To associate a subnet with a route table using the command line
-
associate-route-table (Amazon CLI)
-
Register-EC2RouteTable (Amazon Tools for Windows PowerShell)
To disassociate a subnet from a route table using the command line
-
disassociate-route-table (Amazon CLI)
-
Unregister-EC2RouteTable (Amazon Tools for Windows PowerShell)