Linking a Route Table with a Subnet

You can link a route table to one or more of the Subnets of the Net for which it is created. The routes contained in the route table are automatically applied to virtual machines (VMs) placed in the Subnet to route network traffic.

Linking a Route Table to a Subnet Using Cockpit v2

You can also do this action in the Nets dashboard, by clicking the ID of a Net, selecting a Subnet, and clicking IconLink Link Route Table in the displayed action menu.

  1. Click inside the Route Tables dashboard to make checkboxes appear.

  2. Check the box of the route table you want to link to a Subnet.

  3. Click IconLink Link to Subnet.
    The LINK ROUTE TABLE TO SUBNET dialog box appears.

  4. From the list, select the Subnet you want to link to the route table.

  5. Click Link to Subnet.
    The route table is linked to the Subnet.

Linking a Route Table to a Subnet Using OSC CLI

The LinkRouteTable command associates a Subnet with a route table.
The Subnet and the route table must be in the same Net. The traffic is routed according to the route table defined within this Net. You can associate a route table with several Subnets.

Request sample
$ osc-cli api LinkRouteTable --profile "default" \
    --RouteTableId "rtb-12345678" \
    --SubnetId "subnet-12345678"

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • RouteTableId: The ID of the route table.

  • SubnetId: The ID of the Subnet.

The LinkRouteTable command returns the following elements:

  • LinkRouteTableId: The ID of the association between the route table and the Subnet.

  • ResponseContext: Information about the context of the response.

Result sample
{
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  },
  "LinkRouteTableId": "rtbassoc-12345678"
}

Associating a Route Table with a Subnet Using AWS CLI

To associate a route table with a subnet, use the associate-route-table command following this syntax:

Request sample
$ aws ec2 associate-route-table \
    --profile YOUR_PROFILE \
    --subnet-id subnet-87654321 \
    --route-table-id rtb-1234abcd \
    --endpoint https://fcu.eu-west-2.outscale.com

This command contains the following attributes that you need to specify:

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • subnet-id: The ID of the subnet.

  • route-table-id: The ID of the route table.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The associate-route-table command returns the following element:

  • AssociationId: The ID of the association between the subnet and the route table.

Result sample
{
    "AssociationId": "rtbassoc-781d0d1a"
}

The route table is associated with the specified subnet.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.