Establish the Route Table Entries
For each public subnet that uses the internet gateway, you must update the subnet route table entry to include a route to the IGW.
Each route rule specifies a destination CIDR block and the target (the next hop) for any traffic that matches that CIDR. Before you can create a rule, you must create a target for the rule, in this case, an IGW.
This example adds the existing IGW target to the route rules of the default route table for the VCN. You can also create a new route table for reaching the IGW specifically, but that's not shown in this example. The route rule uses CIDR block 0.0.0.0/0 so that all traffic not covered by other rules in the route table go to the IGW target specified in the new rule.
-
In the Compute Cloud@Customer Console navigation menu, select Networking, then select Virtual Cloud Networks.
- If needed, change the compartment to find the resource you want.
-
Select the name of the VCN for which you want to create a route table. The VCN details page is displayed.
-
Under Resources, select Route Tables.
- Go to the details page of the Default Route Table and select Add Route Rule.
-
Select +New Rule, and enter the following information for this example:
-
Target Type: Select
Internet Gateway
from the list. -
CIDR Block: Enter 0.0.0.0/0 as the destination CIDR block for the traffic.
-
Target: The target is the IGW. Select the arrow and select the target IGW. You might need to change the compartment just above the arrow.
-
Description: An optional description of the rule, such as "New rule for IGW."
-
-
Select Create Route Table Rule.
The details page of the edited default route table is displayed. Because the subnet was set up to use the default route table, the resources in the subnet can now use the internet gateway.
-
Use the oci network route-table update command and required parameters to update the route rules.
Note
The
routeRules
object you provide replaces the entire existing set of rules.oci network route-table update --rt-id <route-table_OCID> [OPTIONS]
For a complete list of CLI commands, flags, and options, see the Command Line Reference.
Procedure
-
Gather the information you need to run the command:
-
The OCID of the compartment where you want to create this route table (
oci iam compartment list
) -
The OCID of the VCN for this route table (
oci network vcn list --compartment-id compartment_OCID
)
-
-
Construct an argument for the
--route-rules
option.Route rules are specified in JSON format. To see how to format a rule, use the following command:
oci network route-table update --generate-param-json-input route-rules > route_rule_format.json
Example (put the following content into the
IGW_route_rule.json
file):[ { "cidr-block": "0.0.0.0/0", "description": null, "destination": null, "destination-type": "CIDR_BLOCK", "network-entity-id": "ocid1.internetgateway.unique_ID" } ]
-
Run the route table update command.
Syntax:
oci network route-table update --compartment-id compartment_OCID \ --vcn-id vcn_OCID --route-rules file:///home/flast/IGW_route_rule.json
-
Use the UpdateRouteTable operation to update the specified route table’s display name or route rules. Avoid entering confidential information.
For information about using the API and signing requests, see REST APIs and Security Credentials. For information about SDKs, see Software Development Kits and Command Line Interface.