addRoute

Prev Next

Available in VPC

Add a route to a route table.

Syntax

The addRoute syntax is as follows:

./ncloud vpc addRoute \
    --vpcNo <vpc-no> \
    --routeTableNo <route-table-no> \
    --routeList <route-list> \
    [--regionCode <KR|SGN|JPN>] \
    [--output <json|xml>]

Options

This section describes the options available when running addRoute.

Required options

The following options are required for addRoute.

Options Type Required Description
--vpcNo String Required VPC number
--routeTableNo String Required Route table number
--routeList List Required Route list
  • For each route, enter {field='value'} pairs enclosed in quotes and separated by commas.
    • destinationCidrBlock (required): Destination IPv4 address range. Uses CIDR notation. Example: 0.0.0.0/0, 100.10.20.0/24
    • targetTypeCode (required): Destination type. NATGW (NAT Gateway) | VPCPEERING (VPC peering) | VGW (Virtual Private Gateway)
    • targetNo (required): Destination identification number. Check the list of resources corresponding to each destination type via the API.
    • targetName (required): Destination name. Check the list of resources corresponding to each destination type via the API.

Common options

For information about the options common to all vpc subcommands, see VPC options.

Examples

If the route addition request is successful, the configuration information for each route is returned.

Command

The command example is as follows:

./ncloud vpc addRoute \
    --vpcNo 12345678 \
    --routeTableNo 45678901 \
    --routeList "destinationCidrBlock='192.0.2.0/24', targetTypeCode='NATGW', targetNo='56789012', targetName='test-natgw'" \
    --regionCode KR \
    --output json

Output

The output example is as follows:

{
  "addRouteResponse": {
    "totalRows": 3,
    "routeList": [
      {
        "destinationCidrBlock": "0.0.0.0/0",
        "targetName": "INTERNET GATEWAY",
        "routeTableNo": "45678901",
        "targetType": {
          "code": "IGW",
          "codeName": "Internet Gateway"
        },
        "targetNo": "",
        "isDefault": false
      },
      {
        "destinationCidrBlock": "10.0.0.0/16",
        "targetName": "LOCAL",
        "routeTableNo": "45678901",
        "targetType": {
          "code": "LOCAL",
          "codeName": "Local"
        },
        "targetNo": "",
        "isDefault": true
      },
      {
        "destinationCidrBlock": "192.0.2.0/24",
        "targetName": "test-natgw",
        "routeTableNo": "45678901",
        "targetType": {
          "code": "NATGW",
          "codeName": "NAT Gateway"
        },
        "targetNo": "56789012",
        "isDefault": false
      }
    ],
    "requestId": "f6a7b8c9-d0e1-2345-fabc-678901234567",
    "returnCode": "0",
    "returnMessage": "success"
  }
}