Create a route entry for a VRouter or VBR.

Note the following before creating a route entry for a VRouter:
  • Up to 48 route entries can be created for a VPC or VBR.

  • The destination CIDR block (DestinationCidrBlock) of the custom route entry cannot be the same as the CIDR block of the VSwitch, and cannot include or be included by the CIDR block of the VSwitch.

  • The destination CIDR block (DestinationCidrBlock) of the custom route entry cannot be 100.64.0.0/10 or be included in 100.64.0.0/10.

  • The destination CIDR blocks of (DestinationCidrBlock) of the route entries in the same route table cannot be the same.

  • If the destination CIDR block (DestinationCidrBlock) is an IP address, it is processed by a 32-bit mask.

  • Multiple route entries can point to the same next hop (NextHopId).
  • The next hop (NextHopId) of the custom route entry and the route table must be in the same VPC.
  • The ECMP route can be configured by using the NextHopList parameter:
    • When adding a normal custom route entry (non-ECMP routing), you must specify theDestinationCidrBlock, NextHopType and NextHopId parameters but do not need to add the NextHopList parameter.

    • When adding an ECMP route entry, you must specify the DestinationCidrBlock and NextHopList parameters, and do not need to specifiy the NextHopType and NextHopId parameters.

Note the following when calling this API to add route entries for a VBR:
  • Up to 48 route entries can be created for a route table.

  • The NextHopList parameter is not supported.

  • The destination CIDR block (DestinationCidrBlock) of the custom route entry cannot be 100.64.0.0/10 or be included in 100.64.0.0/10.

  • The destination CIDR blocks of (DestinationCidrBlock) of the route entries in the same route table cannot be the same.

  • If the destination CIDR block (DestinationCidrBlock) is an IP address, it is processed by a 32-bit mask.

  • Multiple route entries can point to the same next hop (NextHopId).
  • The next hop (NextHopId) of the route entry must be a router interface associated with the VBR.
  • The route entry can only be added when the status of VBR is Active and the status of the corresponding physical connection is Enabled and not financially locked. 

  • Only common route entries (non- ECMP) can be added. You must specify the DestinationCidrBlock, NextHopType, and NextHopId parameters, and do not need to specify the  HopList parameter.

Request parameters

name Parameters Required Description
Action String Yes

The action to perform. Valid value: 

vpc:CreateRouteEntry

RouteTableId String Yes 

The ID of the route table.

DestinationCidrBlock String Yes

The destination CIDR block of the route entry, which must meet the following requirements:

  • The destination CIDR block cannot be 100.64.0.0/10 or any of its subnets.

  • Different route entries in a route table cannot use the same destination CIDR block.

    (Default)
  • If the destination CIDR block is an IP address, the netmask /32 is used by default.

NextHopType String No

The type of the next hop. Valid value: 

  • Instance: ECS instance (Default)

    VpnGateway: VPN Gateway

  • HaVip: High Availability Virtual IP (HaVip)

  • RouterInterface: Router interface

  • NetworkInterface: Elastic Network Interface

Note This parameter must be specified when creating a common (non-ECMP) route entry.
NextHopId String No

The ID of the next hop.

The next hop must be in the VPC or VBR to which the router table belongs.

Note This parameter must be specified when creating a common (non-ECMP) route entry.
NextHopList List No

The list of the next hops. The next hop must meet the following requirements:

  • ECMP route entries are only supported for the VPC route table.

  • You must specify 2 next hops at least and 4 at most.

  • The next hops must be the route interfaces pointing to the connected VBRs.

Note Specify this parameter when you create an ECMP route entry.
ClientToken String No

A client token used to guarantee the idempotence of requests.

This parameter value is generated by the client and must be unique. It cannot exceed 64 ASCII characters.

Table 1. NextHopList
Parameter Parameters Required Description
NextHopType String No

The type of the next hop. Valid value:

  • Instance: ECS instance (default)

    HaVip: High Availability Virtual IP (HaVip)

    RouterInterface: router interface

NextHopId String No The ID of the next-hop instance.
Enabled String Optional Whether the next hop is available:
  • 0: unavailable

  • 1: available

Weight Default value: 1. Optional The routing weight of the next hop.

Response example

Name  Type Required
RequestId String The ID of the request.

Examples

Request example

https://vpc.aliyuncs.com/?Action=CreateRouteEntry
&VpcId=vpc-257gq642n
&RouteTableId=vrt-5citwfp6a
&DestinationCidrBlock=0.0.0.0/0
&NextHopId=i-25skktcp4
&CommonParameters
Response parameter
  • XML format

    <? xml version="1.0" encoding="UTF-8"? >
    <CreateRouteEntryResponse>
        <RequestId>12D086F6-8F31-4658-84C1-006DED011A85</RequestId>
    </CreateRouteEntryResponse>
  • JSON format

    { 
        "RequestId": "12D086F6-8F31-4658-84C1-006DED011A85"
    }