调用CreateRouteEntry接口在VPC路由器或边界路由器上创建自定义路由条目。

API描述

使用该接口为VPC路由器的路由表添加自定义路由条目时,请注意:
  • 同一个路由表中自定义路由条目不能超过200条。
  • 自定义路由条目的目标网段(DestinationCidrBlock)不能和VPC内的交换机的网段相同,也不能包含交换机的网段或者被交换机的网段包含。
  • 自定义路由条目的目标网段(DestinationCidrBlock)不能指向100.64.0.0/10,也不能被100.64.0.0/10包含。
  • 同一路由表下的路由条目的目标网段(DestinationCidrBlock)不允许相同。
  • 如果指定的目标网段(DestinationCidrBlock)是一个IP地址,会按照32位掩码来处理。
  • 多条自定义路由条目可以指向同一个下一跳(NextHopId)。
  • 自定义路由条目的下一跳(NextHopId)必须和路由表在同一个VPC。
  • 支持通过NextHopList参数配置ECMP路由:
    • 添加普通(非ECMP)自定义路由时,需指定DestinationCidrBlockNextHopTypeNextHopId参数,且不能指定NextHopList参数。
    • 添加ECMP路由时,需指定DestinationCidrBlockNextHopList参数,且不能指定NextHopTypeNextHopId参数。
使用该接口为边界路由器的路由表创建自定义路由条目时,请注意:
  • 同一个路由表中自定义路由条目不能超过200条。
  • 不支持NextHopList参数。
  • 自定义路由条目的目标网段(DestinationCidrBlock)不能指向100.64.0.0/10,也不能被100.64.0.0/10包含。
  • 同一路由表下的路由条目的目标网段(DestinationCidrBlock)不允许相同。
  • 如果指定的目标网段(DestinationCidrBlock)是一个IP地址,会按照32位掩码来处理。
  • 多条自定义路由条目可以指向同一个下一跳(NextHopId)。
  • 自定义路由条目的下一跳(NextHopId)必须是该VBR关联的路由器接口。
  • 只允许在VBR状态是Active,而且对应的物理专线状态是Enabled且没有被欠费锁定的情况下在VBR上新建路由条目。
  • 仅支持添加普通路由(非ECMP),需指定DestinationCidrBlockNextHopTypeNextHopId参数,且不能指定NextHopList参数。

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String CreateRouteEntry

要执行的操作,取值:CreateRouteEntry

DestinationCidrBlock String 192.168.0.1/24

自定义路由条目的目标网段,支持IPv4和IPv6的目标网段。需满足以下要求:

  • 目标网段不能指向100.64.0.0/10或被100.64.0.0/10包含。
  • 同一张路由表内的不同路由条目的目标网段不能相同。
RouteTableId String vtb-bp145q7glnuzd****

要创建自定义路由条目的路由表ID。

RegionId String cn-hangzhou

路由表所属地域的ID。您可以通过调用DescribeRegions接口获取地域ID。

NextHopId String i-j6c2fp57q8rr4jlu****

自定义路由条目的下一跳实例的ID。

ClientToken String 02fb3da4-130e-11e9-8e44-001****

保证请求幂等性。从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符,且不能超过64个字符。更多详情,请参见如何保证幂等性

RouteEntryName String test

要创建的自定义路由条目的名称。

名称长度为2~128个字符之间,以英文字母或中文开头,可包含数字、短划线(-)和下划线(_)。

Description String test

自定义路由条目的描述信息。

NextHopType String RouterInterface

自定义路由条目的下一跳的类型,取值:

  • Instance(默认值):ECS实例。
  • HaVip:高可用虚拟IP。
  • RouterInterface:路由器接口。
  • NetworkInterface:弹性网卡。
  • VpnGateway:VPN网关。
  • IPv6Gateway:IPv6网关。
  • NatGateway:NAT网关。
  • Attachment:转发路由器。
NextHopList.N.NextHopId String ri-2zeo3xzyf3cd8r4****

ECMP路由的下一跳实例的ID。

NextHopList.N.Weight Integer 10

ECMP路由的下一跳的路由权重。

NextHopList.N.NextHopType String RouterInterface

ECMP路由的下一跳的类型,目前只能取值:RouterInterface(路由器接口)。

返回数据

名称 类型 示例值 描述
RequestId String 0ED8D006-F706-4D23-88ED-E11ED28DCAC0

请求ID。

RouteEntryId String rte-sn6vjkioxte1gz83z****

自定义路由条目的ID。

示例

请求示例

http(s)://[Endpoint]/?Action=CreateRouteEntry
&DestinationCidrBlock=192.168.0.1/24
&RouteTableId=vtb-bp145q7glnuzd****
&<公共请求参数>

正常返回示例

XML格式

<CreateRouteEntryResponse>
  <RouteEntryId>rte-sn6vjkioxte1gz83z****</RouteEntryId>
  <RequestId>0ED8D006-F706-4D23-88ED-E11ED28DCAC0</RequestId>
</CreateRouteEntryResponse>

JSON格式

{
    "CreateRouteEntryResponse": {
        "RouteEntryId": "rte-sn6vjkioxte1gz83z****",
        "RequestId": "0ED8D006-F706-4D23-88ED-E11ED28DCAC0"
    }
}

错误码

HttpCode 错误码 错误信息 描述
400 MissingParameter Miss mandatory parameter. 缺少必要参数,请您检查必填参数是否都已填后再进行操作。
400 InvalidCidrBlock.Malformed Specified CIDR block is not valid. 该CIDR格式不正确。
400 InvalidCIDRBlock.Duplicate Specified CIDR block is already exists. 该网段已经在该路由表中存在。
400 IncorrectVpcStatus Current VPC status does not support this operation. 当前VPC的状态无法支持这个操作。
400 IncorrectInstanceStatus Current instance status does not support this operation. 当前实例的状态不支持该操作。
400 QuotaExceeded Route entry quota exceeded in this route table. 超过路由条目配额。
400 IncorrectRouteEntryStatus Some route entry status blocked this operation. 无法执行该操作,当前路由表中有路由条目的状态为pending或modifying。
400 InvalidCidrBlock Specified CIDR block is not valid. 可能的报错原因:1.您不在10.0.0.0/8的路由网段的白名单中,不能使用该网段。2.添加的自定义路由目标网段不能从属于同一个VPC下面所有交换机的网段。3.网段不能是100.64.0.0/10。
400 InvalidNextHopType Specified parameter "NextHopType" is not valid 该下一跳类型不合法。
400 InvalidNextHop.NotFound Specified next hop does not exist. 该下一跳地址不存在。
400 InvalidVRouter.NotFound vRouter not exists. 路由器不存在,请您检查输入的路由器是否正确。
400 InvalidVPC.NotFound vpc not exists. 专有网络不存在,请您检查输入的专有网络是否正确。
400 InvalidNexthopTypeAndList.BothNull both nexthopType and nextHopList are null. 下一跳类型和下一跳列表都为空。
400 InvalidNexthopTypeAndList.BothNotNull both nexthopType and nextHopList are not null. 下一跳类型和下一跳列表不能同时为空。
400 InvalidRouterInterface invalid router interface. 该路由器接口不存在。
400 InvalidOppositeRouterType nexthop list cannot only contain router interface whose opposite router interface is on vbr. 下一跳的路由器接口的对端路由器类型必须为边界路由器。
400 InvalidNexthopListSize nexthop size is illegal. Must be between 2 and 4. 必须指定2~4个路由器接口作为下一跳。
400 InvalidEntryRuleQuota.NotFound Route entry quota rule not exists. 路由条目配额规则不存在。
400 Forbidden.CheckEntryRuleQuota Route entry quota rule check error. 检查路由条目配额时发生了错误。
400 InvalidVBRStatus invalid virtual border router status. 边界路由器状态不合法。
400 InvalidPhysicalConnectionBusinessStatus invalid physical connection business status. 物理专线状态不合法。
400 IncorrectHaVipStatus This operation is denied because satus of the specified HaVip is neither Available nor InUse. 无法执行该操作,因为HAVIP的状态是Available或InUse。
400 CountLimitExceed.HaVipRouteEntry There can be 5 route entry to HaVip at most in one route table. 指向该 HaVip 实例的路由条目数量已达上限。
400 InvalidRouteEntry.Duplicate The route entry already exist. 指定的路由条目已存在。
400 IncorrectRouteEntryStatus Specified routeEntry status error. 无法执行该操作,当前路由表中有路由条目的状态为pending或modifying。
400 IncorrectRouteEntryStatus VBR has NotStable route entry. 无法执行该操作,边界路由表中有路由条目的状态为pending或modifying。
400 InvalidParam The Ecmp routerEntry with router interfaces local vgw vip not match. 路由条目与路由器接口本地视频网关VIP不匹配。
400 INVALID_WEIGHT_PARAM Specified value of weight invalid 该权重不合法。
400 FORBIDDEN_USE_VPC_AS_INTERNET_GATEWAY The Specified CIDR must be in vpc CIDR. 该网段必须是VPC网段的子集。
400 INVALID_VPC_ID The Specified VpcId not match. 该 VPC 不存在,请您检查输入的 VPC 是否正确。
400 InvalidRouteEntrySize The Specified routerEntry size not legal. 等价路由需要选择2~4个路由器接口作为路由下一跳。
400 InvalidRouteEntry Specified routeEntry not exist. 该路由条目不存在。
400 InvalidAttachment.NotFound The attachment is not found. Attachment不存在
400 OperationFailed.ActiveNetworkInterfaceNotFound No active network interface is found on the attachment. Attachment上不存在可用的弹性网卡。
400 InvalidNetworkInterface.NotFound The network interface is not found on the attachment. Attachment上的弹性网卡不存在。
400 OperationFailed.QueryAttachmentInfo Failed to query attachment information. 查询attachment信息失败。
400 IllegalParam.AttachmentId The attachment is invalid. Attachment非法
400 OperationFailed.NotSupportIPV6 The specified next hop does not support IPv6. 指定的下一跳不支持ipv6功能。
400 IncorrectStatus.Ipv6Address The IPv6 address of the specified next hop is being assigned or deleted. 指定的下一跳的ipv6地址此时正在被创建或删除中。
400 OperationUnsupported.Ipv6EntryOnPrimaryNetworkInterface You cannot create IPv6 route entries on a primary network interface. 不允许创建下一跳为主网卡的ipv6路由。
400 OperationUnsupported.SpecifyIpOnIpv6Entry You cannot specify the private IP address when you create IPv6 route entries. 创建ipv6路由不允许指定private ip参数。
400 OperationUnsupported.MutipleIpv6Address You cannot specify a next hop that has bound multiple IPv6 addresses. 不允许指定绑定了多个IPV6地址的下一跳。
400 OperationDenied.Ipv6EntryOnCustomTable You cannot create any IPv6 route entry on a custom route table. 不允许在自定义路由表上创建IPv6路由。
400 OperationDenied.CloudBoxVbrEntryAllowedInCustomRouteTable The operation is not allowed because only the custom routing table can add a routing entry with the next hop pointing to the cloud box type VBR. 指定操作被禁止,因为只有自定义路由表能够添加下一跳指向云盒类型VBR的路由条目。
400 OperationDenied.RouteTableAssociateNotCloudBoxVSwitch The operation is not allowed because of the routing table is bound to a non-cloud box type vswitch, and routing entries pointing to the cloud box VBR cannot be added. 指定操作被禁止,因为路由表绑定到了非云盒类型的VSwitch上,不能添加指向云盒VBR的路由条目。
400 OperationDenied.VbrMisMatchCloudBox The operation is not allowed because the routing table is bound to a cloud box vswitch, and routing entries pointing to other cloud box VBRs cannot be added. 指定操作被禁止,因为路由表绑定到了一个云盒VSwitch上,不能添加指向其他云盒VBR的路由条目。
400 OperationDenied.VbrIdle The operation is not allowed because the next hop of the added routing entry is a VBR type RI at the opposite end, which cannot be in an idle state. 指定操作被禁止,因为添加的路由条目下一跳是对端为vbr类型的RI,不能处于空闲状态。
400 OperationDenied.RouterInterfaceToDifferentVpc The operation is not allowed because the router interface is connected to different VPCs. 指定操作被禁止,因为路由器接口指向不同的vpc。
400 OperationDenied.RouterInterfaceFromDifferentZones The operation is not allowed because the router interface resides in different zones. 指定操作被禁止,因为路由器接口来自不同的可用区。
400 OperationFailed.PconnTrafficNotEnable The operation is failed because of PconnTrafficNotEnable. 操作失败,因为出云流量未开通。
403 IncorrectInstanceStatus The current status of the resource does not support this operation. 当前资源的状态不支持该操作。
404 InvalidInstanId.NotFound Specified instance does not exist. 指定的实例不存在,请您检查该实例是否正确。
404 InvalidNextHopId.NotFound Specified next hop does not exist. 该下一跳不存在。
404 InvalidRouteTableId.NotFound Specified route table does not exist. 该路由表不存在。
404 InvalidHaVipId.NotFound The specified HaVip does not exist in the specified VPC. 该HAVIP在VPC中不存在。

访问错误中心查看更多错误码。