全部產品
Search
文件中心

Virtual Private Cloud:CreateRouteEntry

更新時間:Jun 17, 2026

呼叫 CreateRouteEntry 在 VPC 路由器或邊界路由器(VBR)上建立自訂路由條目。

介面說明

  • CreateRouteEntry 介面屬於非同步介面,即系統會返回一個執行個體 ID,但該路由的新增尚未完成,系統後台的啟動任務仍在進行。您可以呼叫 DescribeRouteEntryList 查詢路由的新增狀態:
    • 當路由處於 Creating 狀態時,表示路由新增中。

    • 當路由處於 Created 狀態時,表示路由新增完成。

  • CreateRouteEntry 介面不支援在同一個 VPC 或者同一個 VBR 中並行新增自訂路由條目。

  • CreateRouteEntry 介面在並行情況下可能返回 TaskConflict 錯誤碼,請酌情重試。

使用該介面為 VPC 路由器的路由表新增自訂路由條目時,請注意以下事項:

說明

當新增的路由為前綴列表路由時,路由配額的計算為現存路由與前綴列表路由的最大路由條目數之和是否超過路由配額的限制。

  • 同一個路由表中自訂路由條目不能超過 200 條。

  • 自訂路由條目的目標網段(DestinationCidrBlock)不能和 VPC 內的交換器的網段相同,可以包含交換器的網段但是不能被交換器的網段包含。

  • 自訂路由條目的目標網段(DestinationCidrBlock)可以設定為比雲端服務系統路由網段100.64.0.0/10更明細的網段,但不支援和該網段相同。

    重要 由於目標網段為100.64.0.0/10的系統路由用於 VPC 內的雲端產品通訊,建議您謹慎設定更明細的路由,如果設定錯誤將導致雲端產品服務無法正常存取和使用。

  • 同一路由表下的路由條目的目標網段(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的系統路由用於 VPC 內的雲端產品通訊,建議您謹慎設定更明細的路由,如果設定錯誤將導致雲端產品服務無法正常存取和使用。

  • 同一路由表下的路由條目的目標網段(DestinationCidrBlock)不允許相同。

  • 如果指定的目標網段(DestinationCidrBlock)是一個 IP 位址,會按照 32 位元遮罩來處理。

  • 多條自訂路由條目可以指向同一個下一跳(NextHopId)。

  • 自訂路由條目的下一跳(NextHopId)必須是該 VBR 關聯的路由器介面。

  • 只允許在 VBR 狀態是 Active,而且對應的實體專線狀態是 Enabled 且沒有被欠費鎖定的情況下在 VBR 上新建路由條目。

  • 僅支援新增普通路由(非 ECMP),需指定 DestinationCidrBlockNextHopTypeNextHopId 參數,且不能指定 NextHopList 參數。

調試

您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。

調試

授權資訊

下表是API對應的授權資訊,可以在RAM權限原則語句的Action元素中使用,用來給RAM使用者或RAM角色授予調用此API的許可權。具體說明如下:

  • 操作:是指具體的許可權點。

  • 存取層級:是指每個操作的存取層級,取值為寫入(Write)、讀取(Read)或列出(List)。

  • 資源類型:是指操作中支援授權的資源類型。具體說明如下:

    • 對於必選的資源類型,用前面加 * 表示。

    • 對於不支援資源級授權的操作,用全部資源表示。

  • 條件關鍵字:是指雲產品自身定義的條件關鍵字。

  • 關聯操作:是指成功執行操作所需要的其他許可權。操作者必須同時具備關聯操作的許可權,操作才能成功。

操作

存取層級

資源類型

條件關鍵字

關聯操作

vpc:CreateRouteEntry

create

*RouteTable

acs:vpc:{#regionId}:{#accountId}:routetable/{#RouteTableId}

請求參數

名稱

類型

必填

描述

樣本值

RegionId

string

路由表所屬地域的 ID。

您可以透過呼叫 DescribeRegions 介面取得地域 ID。

cn-hangzhou

RouteTableId

string

要新增自訂路由條目的路由表 ID。

vtb-bp145q7glnuzd****

DestinationCidrBlock

string

自訂路由條目的目標網段,支援 IPv4、IPv6、前綴列表的目標網段和前綴列表的執行個體 ID。需滿足以下要求:

  • 目標網段不能指向 100.64.0.0/10 或被 100.64.0.0/10 包含。

  • 同一張路由表內的不同路由條目的目標網段不能相同。

192.168.0.0/24

NextHopId

string

自訂路由條目的下一跳執行個體的 ID。

說明

若選擇 NextHopType 為 ECR,您可以透過 DescribeExpressConnectRouterAssociation 介面取得 AssociationId 作為下一跳 ID。 -。

i-j6c2fp57q8rr4jlu****

ClientToken

string

用戶端 Token,用於保證請求的冪等性。

從您的用戶端產生一個參數值,請確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元。

說明

若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 標識。每次 API 請求的 RequestId 不一樣。

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

RouteEntryName

string

要新增的自訂路由條目的名稱。

名稱長度為 1~128 個字元,不能以http://https://開頭。

test

Description

string

自訂路由條目的描述資訊。

描述長度為 1~256 個字元,不能以http://https://開頭。

test

NextHopType

string

自訂路由條目的下一跳的類型,取值:

  • Instance(預設值):ECS 執行個體。

  • HaVip:高可用虛擬 IP。

  • RouterInterface:路由器介面。

  • NetworkInterface:彈性網路卡。

  • VpnGateway:VPN 閘道。

  • IPv6Gateway:IPv6 閘道。

  • NatGateway:NAT 閘道。

  • Attachment:轉發路由器。

  • VpcPeer:VPC 對等連線。

  • Ipv4Gateway:IPv4 閘道。

  • GatewayEndpoint:閘道終端節點。

  • Ecr:專線閘道。

  • GatewayLoadBalancerEndpoint:閘道型負載平衡終端節點。

枚舉值:

  • HaVip :

    HaVip

  • VpnGateway :

    VpnGateway

  • GatewayLoadBalancerEndpoint :

    GatewayLoadBalancerEndpoint

  • VpcPeer :

    VpcPeer

  • Instance :

    Instance

  • NetworkInterface :

    NetworkInterface

  • NatGateway :

    NatGateway

  • Attachment :

    Attachment

  • Ipv4Gateway :

    Ipv4Gateway

  • GatewayEndpoint :

    GatewayEndpoint

  • Ecr :

    Ecr

  • RouterInterface :

    RouterInterface

  • IPv6Gateway :

    IPv6Gateway

RouterInterface

NextHopList

array<object>

下一跳的資訊。

object

下一跳的資訊。

NextHopId

string

ECMP 路由的下一跳執行個體的 ID。

ri-2zeo3xzyf3cd8r4****

Weight

integer

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

10

NextHopType

string

ECMP 路由的下一跳的類型,目前僅取值:RouterInterface(路由器介面)。

RouterInterface

DryRun

boolean

是否只預檢此次請求。取值:

  • true:傳送檢查請求,不會建立路由條目。檢查項包括是否填寫了必需參數、請求格式、業務限制。如果檢查不通過,則返回對應錯誤。如果檢查通過,則返回錯誤碼DryRunOperation

  • false(預設值):傳送正常請求,通過檢查後返回 HTTP 2xx 狀態碼並直接進行操作。

false

返回參數

名稱

類型

描述

樣本值

object

自訂路由條目的 ID。

RouteEntryId

string

自訂路由條目的 ID。

rte-sn6vjkioxte1gz83z****

RequestId

string

請求 ID。

0ED8D006-F706-4D23-88ED-E11ED28DCAC0

樣本

正常返回樣本

JSON格式

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

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 IllegalParam.CidrBlock The specified CidrBlock is illegal.
400 QuotaExceeded Route entry quota exceeded in this route table.
400 MissingParameter Miss mandatory parameter.
400 InvalidCidrBlock.Malformed Specified CIDR block is not valid.
400 InvalidCIDRBlock.Duplicate Specified CIDR block is already exists.
400 IncorrectVpcStatus Current VPC status does not support this operation.
400 IncorrectInstanceStatus Current instance status does not support this operation.
400 IncorrectRouteEntryStatus Some route entry status blocked this operation.
400 IncorrectVSwitchStatus The current virtual switch status does not support this operation.
400 InvalidCidrBlock Specified CIDR block 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.
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 InvalidRouterType Cannot specify nexthop list in vbr's route table.
400 IncorrectHaVipStatus This operation is denied because satus of the specified HaVip is neither Available nor InUse.
400 CountLimitExceed.HaVipRouteEntry The count of route entry to HaVip in one route table is exceeded.
400 InvalidRouteEntry.Duplicate The route entry already exist.
400 InvalidParam The Ecmp routerEntry with router interfaces local vgw vip not match.
400 INVALID_WEIGHT_PARAM Specified value of weight invalid
400 FORBIDDEN_USE_VPC_AS_INTERNET_GATEWAY The Specified CIDR must be in vpc CIDR.
400 InvalidNexthop The Specified nexthop illegal.
400 INVALID_VPC_ID The Specified VpcId not match.
400 InvalidRouteEntrySize The Specified routerEntry size not legal.
400 TaskConflict The operation is too frequent, please wait a moment and try again.
400 InvalidRouteEntry Specified routeEntry not exist.
400 InvalidDestinationCidrBlock The specified destinationCidrBlock must not included in black list cidr.
400 Forbidden.VRouterNotFound Specified virtual switch is not found during access authentication.
400 DefaultValidate.Error validte fail.
400 Region.NotSupport The specified region does not currently support nextHopType for networkInterface
400 OperationFailed.NotifyCenCreate Failed to notify cen when create route entry.
400 Forbidden.PrivateIpNotFound Private ip address not exist.
400 OperationUnsupported.InactiveMode Vpc multi scope route only support active standby.
400 InvalidRouteEntryName.Malformed Specified RouteEntry name is not valid.
400 IncorrectStatus.MultiScopeRiRouteEntry MultiScope ri status must not in idle.
400 OperationUnsupported.MoreThanOneVpnOrHavip MultiScope can not support more than one vpn/havip.
400 OperationUnsupported.EcmpRiTypeOrNumber Emcp entry not supported if vpc-vbr or vbr-vlan ri does not exist.
400 Duplicated.VpcNextHop Route entry nexthop duplicate.
400 OperationUnsupported.SubRouteTableECMP Vpc subRouteTable don't support ecmp or multiScope.
400 InvalidNexthop.NotFound VRouterEntry nexthop does not exist.
400 IllegalParam.NextHopId Instance not exists or not vpc vm.
400 QuotaExceeded.HaVipRouteEntry Vpc havip route entry quota exceed.
400 InvalidNexthop.DirectEni The direct Eni cannot be nexthop.
400 OperationFailed.InvalidNexthop vpc multi scope route must has a enable nexthop.
400 OperationFailed.NotifyCenDelete Failed to notify cen when delete route entry.
400 InvalidNatGateway.NotFound Natgateway not exist.
400 OperationFailed.CxpRouteExist Cxp route alreay existed.
400 OperationFailed.GetEniInfo Failed to get networkInterface info.
400 OperationUnsupported.InvalidRouterInterfaceType Only vpc vbr interface support ecmp route.
400 InvalidHaVip.NotFound The specified HaVip does not exist in the specified region.
400 OperationFailed.MultiScopeType The specified nexthop type is not support in multiScope.
400 OperationFailed.DistibuteLock Distibute lock fail.
400 QuotaExceeded.VpnRouteEntry Vpn route entry quota exceeded.
400 InvalidAttachment.NotFound The attachment is not found.
400 OperationFailed.ActiveNetworkInterfaceNotFound No active network interface is found on the attachment.
400 InvalidNetworkInterface.NotFound The network interface is not found on the attachment.
400 OperationFailed.QueryAttachmentInfo Failed to query attachment information.
400 IllegalParam.AttachmentId The attachment is invalid.
400 OperationFailed.NotSupportIPV6 The specified next hop does not support IPv6.
400 IncorrectStatus.Ipv6Address The IPv6 address of the specified next hop is being assigned or deleted.
400 OperationUnsupported.Ipv6EntryOnPrimaryNetworkInterface You cannot create IPv6 route entries on a primary network interface.
400 OperationUnsupported.SpecifyIpOnIpv6Entry You cannot specify the private IP address when you create IPv6 route entries.
400 OperationUnsupported.MutipleIpv6Address You cannot specify a next hop that has bound multiple IPv6 addresses.
400 OperationDenied.Ipv6EntryOnCustomTable You cannot create any IPv6 route entry on a custom route table.
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.
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.
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.
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.
400 OperationDenied.RouterInterfaceToDifferentVpc The operation is not allowed because the router interface is connected to different VPCs.
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.
400 ResourceNotFound.VpcPeer The specified resource of %s is not found.
400 IncorrectStatus.VpcPeer The status of %s [%s] is incorrect.
400 OperationDenied.RouteTableTypeNotPermitted The operation is not allowed because the type of route table is not permitted.
400 OperationDenied.GatewayRouteTableNotPermitted The operation is not allowed to create a route pointing to this nextHop type on gateway route table.
400 UnsupportedFeature.VpcPeerIpv6 IPv6 route entries for VPC peering connections cannot be created in this region.
400 OperationDenied.VpcIpv6NotEnabled IPv6 has not been enabled for the VPC.
400 IncorrectStatus.Ipv4Gateway The status of Ipv4Gateway is incorrect.
400 ResourceNotFound.PrefixList The specified resource of prefixList is not found.
400 UnsupportedFeature.CreatePrefixListEcmpRouteEntry The feature of creating ecmp route entry with prefixList is not supported.
400 OperationDenied.RouterInterfaceIpv6NotEnabled Routerinterface does not support IPv6.
400 OperationDenied.NextHopTypeNotPermitted The operation is not allowed because the nextHop type is invalid.
400 ResourceAlreadyAssociated.PrefixList The operation failed because the specified prefixList route entry already exists.
400 OperationFailed.CidrConflictWithPrefixList The specified CIDR block already exists in a prefixList route entry.
400 ResourceNotFound.Ipv4Gateway Specified Ipv4Gateway does not exist.
400 Mismatch.HaVipIdAndRouteTableId The HaVip and RouteTable are mismatched.
400 OperationFailed.OperationLocked The operation failed because the nextHop instance is in the O&M lock state.
400 Mismatch.Ipv4GatewayIdAndRouteTableId The specified IPv4Gateway and RouteTable are not matched.
400 OperationUnsupported.DestinationCidrBlockOverlapWithVSwitch The destination IPv6 network segment specified in the route entry overlaps with the vSwitch network segment.
400 ResourceNotAssociated.Cen The Vpc and Cen are not associated.
400 IncorrectStatus.CenRelation The status of Vpc in Cen is incorrect.
400 OperationDenied.CenTypeInvalid The operation is not allowed because of Cen type is invalid..
400 ResourceNotFound.Cen The specified resource of Cen is not found.
400 ResourceNotFound.NetworkInterface The specified resource of network interface is not found.
400 RouteConflict.AlreadyExist Route conflict exists in routing table.
400 IncorrectStatus.RouterInterface The specified RouterInterface status is invalid.
400 InvalidNexthop.UnsupportedEniBizType The biz type of NetworkInterface is illegal.
400 OperationDenied.RouterInterfaceIpv6 RouterInterface does not support IPv6.
400 InvalidNextHopType Specified parameter "NextHopType" is not valid.
400 OperationDenied.VbrAttachEcrInMiddleStatus The operation is not allowed because of VBR attach or detach ECR in middle status.
400 ResourceNotAssociated.Ecr The ECR is not associated.
400 UnsupportedFeature.RouterInterfaceIpv6 The feature of ipv6 is not supported for the routerInterface.
400 InvalidVpnInstanceId.NotFound The specified VPN was not found.
400 OperationFailed.ScopeActiveRouteEntryType Operation failed because the type of the active route entry is not supported.
400 OperationFailed.ScopeStandbyRouteEntryQuota Operation failed because the quota for standby route entries in the scope has been exceeded.
400 OperationFailed.ScopeActiveRouteEntryQuota Operation failed because the quota for active route entries in the scope has been exceeded.
400 OperationUnsupported.ScopeInvalidRouteType The specified route type is unsupported.
400 OperationFailed.EcmpInvalidRouterInterfaceOppositeType Operation failed because the opposite type of the router interface is invalid for ECMP configuration.
400 OperationUnsupported.Ipv6EcmpRouteEntry The EcmpRouteEntry is not supported for IPv6.
400 OperationUnsupported.Ipv6CidrBlock The specified IPv6 CIDR block is unsupported.
400 OperationUnsupported.Ipv6ForVBR IPv6 route entry is not supported for VirtualBorderRouter.
400 IncorrectStatus.RouteTableStatus The status of the specified RouteTable is incorrect.
400 OperationFailed.InvalidNextHopType Operation failed because Ecmp routeEntry has more than one ri entry and can only support one non-ri entry.
400 UnsupportedRegion The feature is not supported in current region.
400 UnsupportedFeature.VpcAdvancedFeature The VPC does not support some advanced features.
400 OperationDenied.CreateEcmpForPublishedRouteEntry Operation denied because of can not create EcmpRouteEntry for published RouteEntry.
400 OperationDenied.TrAttachmentIpv6Disabled The operation is not allowed because tr attachment Ipv6 is disabled.
400 Mismatch.EniIdAndRouteTableId The operation is not allowed because eni and route table not in same vpc.
400 InvalidDescription.Malformed The Description is illegal.
400 OperationFailed.InstanceDismatchCurrentVpc The specified instance does not exist in current vpc.
400 OperationDenied.RouterInterfaceStatusNotAllowed The operation is not allowed because of RouterInterfaceStatusNotAllowed.
400 OperationFailed.Ipv6AddressNotBind The specified next hop has no IPv6 address.
400 OperationUnsupported.MultipleIpv6Address Operation unsupported because specific route next hop instance has multiple IPv6 address. 操作不支持,因为指定的路由下一跳实例绑定了多个IPv6地址
500 VPC.ERROR error code 500,Internal server error.
500 InternalError The request processing has failed due to some unknown error, exception or failure.
500 IncorrectStatus.Ipv4Gateway The status of Ipv4Gateway is incorrect.
403 IncorrectInstanceStatus The current status of the resource does not support this operation.
404 InvalidParameter Instance not exists or not vpc vm
404 InvalidNatGatewayId.NotFound Specified value of NatGatewayId is not found in our record.
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.
404 InvalidNetworkInterface.NotFound The specified networkInterface does not exist.
404 InvalidVpc.NotFound Specified vpc is not found in our record.
404 InvalidIpv6Gateway.NotFound Specified Ipv6Gateway does not exist.
404 ResourceNotFound.GatewayLoadBalancerEndpoint GatewayLoadBalancerEndpoint instance not found.

訪問錯誤中心查看更多錯誤碼。

變更歷史

更多資訊,參考變更詳情