全部產品
Search
文件中心

Cloud Enterprise Network:CreateTransitRouterVpnAttachment

更新時間:Jul 15, 2026

轉發路由器支援連接 VPN 閘道器的 IPsec 連線。本地資料中心可以透過 IPsec 連線直接連接至轉發路由器,然後透過轉發路由器實現與其他網路的互通,呼叫 CreateTransitRouterVpnAttachment 介面建立 VPN 連線。

介面說明

  • 建立 VPN 連線後,VPN 連線預設不與任何轉發路由器路由表建立路由學習關係和關聯轉發關係。

  • 在呼叫 CreateTransitRouterVpnAttachment 介面的過程中,如果您指定了 CenIdRegionId 參數的值,則無需指定 TransitRouterId 參數的值;如果您指定了 TransitRouterIdRegionId 參數的值,則無需指定 CenId 參數的值。

前提條件

  • 在建立 VPN 連線前,請確保您已經在轉發路由器執行個體所在的地域建立了一個 IPsec 連線,且 IPsec 連線未綁定任何資源。具體操作,請參見 CreateVpnAttachment

  • 如果轉發路由器執行個體需要連接跨帳號的 IPsec 連線,則需確保 IPsec 連線已對轉發路由器執行個體授權。具體操作,請參見 GrantInstanceToTransitRouter

  • 在建立 VPN 連線之前,請確保您已設定轉發路由器的 TR 位址區段。具體操作,請參見 CreateTransitRouterCidr

調試

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

調試

授權資訊

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

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

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

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

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

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

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

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

操作

存取層級

資源類型

條件關鍵字

關聯操作

cen:CreateTransitRouterVpnAttachment

create

CenInstance

acs:cen:*:{#accountId}:ceninstance/{#ceninstanceId}

TransitRouter

acs:cen:*:{#accountId}:centransitrouter/{#TransitRouterId}

請求參數

名稱

類型

必填

描述

樣本值

ClientToken

string

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

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

說明

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

123e4567-e89b-12d3-a456-42665544****

DryRun

boolean

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

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

  • false(預設值):傳送正常請求,通過檢查後直接建立 VPN 連線。

false

CenId

string

雲企業網執行個體 ID。

cen-rsgxs8ng2awen2****

TransitRouterId

string

轉發路由器執行個體 ID。

tr-p0wm740vjnbaprv0m****

RegionId

string

轉發路由器執行個體所屬的地域 ID。

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

cn-hangzhou

TransitRouterAttachmentName

string

VPN 連線的名稱。

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

nametest

TransitRouterAttachmentDescription

string

VPN 連線的描述資訊。

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

desctest

VpnId

string

IPsec 連線 ID。

vco-p0w042cqwvlhl4zyw****

VpnOwnerId

integer

IPsec 連線所屬的阿里雲帳號(主帳號)ID。

  • 如果不輸入本參數,預設使用目前登入的阿里雲帳號 ID。

  • 如果您要連接跨帳號的 IPsec 連線時,本參數必填。

1210123456123456

AutoPublishRouteEnabled

boolean

是否允許轉發路由器執行個體自動向 IPsec 連線發佈路由條目。取值:

  • true(預設值):允許。

  • false:不允許。

true

ChargeType

string

計費方式。

僅取值:POSTPAY(預設值),表示按使用量付費。

POSTPAY

Zone

array<object>

目前地域下的可用區 ID。

系統將在您指定的可用區下建立資源。

說明

如果綁定的 IPsec 連線是雙隧道模式,此欄位不填值。

object

可用區 ID。

ZoneId

string

可用區 ID。

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

cn-hangzhou-h

Tag

array<object>

標籤資訊列表。

一次最多支援輸入 20 個標籤資訊。

object

標籤資訊。

Key

string

資源的標籤鍵。

一旦傳入該值,則不允許為空字串。最多支援 64 個字元,不能以 aliyun 或者 acs: 開頭,不能包含 http:// 或者 https://

一次最多支援輸入 20 個標籤的標籤鍵。

TagKey

Value

string

資源的標籤值。

標籤值可以為空或輸入不超過 128 個字元的字串,不能以 aliyun 或者 acs: 開頭,不能包含 http:// 或者 https://

每一個標籤鍵對應一個標籤值,一次最多支援輸入 20 個標籤鍵對應的標籤值。

TagValue

返回參數

名稱

類型

描述

樣本值

object

返回結果。

TransitRouterAttachmentId

string

VPN 連線 ID。

tr-attach-y5dup2qwfyh9lu****

RequestId

string

請求 ID。

8B5DD40A-3A29-5AC0-B8DA-05FD10D5C893

樣本

正常返回樣本

JSON格式

{
  "TransitRouterAttachmentId": "tr-attach-y5dup2qwfyh9lu****",
  "RequestId": "8B5DD40A-3A29-5AC0-B8DA-05FD10D5C893"
}

錯誤碼

HTTP status code

錯誤碼

錯誤資訊

描述

400 NoPermission.AliyunServiceRolePolicyForCEN You are not authorized to create the service linked role. Role Name: AliyunServiceRolePolicyForCEN. Service Name: cen.aliyuncs.com. Make sure that the user has been granted the ram:CreateServiceLinkedRole permission. 您沒有權限建立服務連結角色,角色名稱:AliyunServiceRolePolicyForCEN,服務名稱:cen.aliyuncs.com。請確保已授予目前使用者 ram:CreateServiceLinkedRole 權限。
400 OperationUnsupported.TransitRouterRegionId The specified TransitRouterRegion does not support the operation.
400 InvalidCenId.NotFound CenId is not found. 參數中指定的 CenId 不存在。
400 InvalidStatus.ResourceStatus The resource is not in a valid state for the attachment operation. 目前資源狀態不支援此操作,請稍後重試。
400 InvalidTransitRouterId.NotFound TransitRouterId is not found. 參數中指定的 TransitRouterId 不存在。
400 Forbbiden.TransitRouterServiceNotOpen The user has not open transit router service. 轉發路由器服務未開啟,請開啟後重試。
400 InvalidTransitRouterMode.NeedUpgrade TransitRouter need to upgrade. 目前轉發路由器模式不支援。
400 InvalidAvailable.NoResource No resource in the available zone. 目前可用區資源不足。
400 OperationUnsupported.VpnAttachment The specified region does not support the operation. 目前區域不支援此操作。
400 OperationUnsupported.TransitRouterType The specified TransitRouterType does not support the operation. 當前 TransitRouter 類型不支援該操作。
400 OperationFailed.AllocateCidrFailed Operation failed because vpn allocate cidr failed. VPN 申請 CIDR 失敗。
400 OperationUnsupported.ZoneId The specified ZoneId does not support the operation.
400 MissingParam.CenIdOrRegionId Either CenId or RegionId must be specified. CenId 或 RegionId 是必選參數。
400 IllegalParam.RegionId RegionId is illegal. 參數中指定的 Region 無效。
400 OperationUnsupported.CenFullLevel CEN full level does not support TransitRouter Full 模式的 CEN 不支援 VPN Bpg。
400 InvalidOperation.CenInstanceStatus The CEN instance is not in a valid state for the operation.
400 IllegalParam.ZoneMappings The Specified Parameter ZoneMappings is illegal 參數中指定的 ZoneMappings 不合法。
400 IncorrectStatus.TransitRouter The status of TransitRouter is incorrect. 目前 TR 的狀態不支援此操作,請稍後重試。
400 InvalidOperation.VpnNetworkTypeInvalid The network type of child-instance is invalid. 該執行個體的 network type 不合法。
400 QuotaExceeded.CenQuotaVpnAttachPerTransitRouter The maximum number of VPN attachment per Transit Router is exceeded. 每個轉發路由器支援建立的 VPN 連線個數超限,可提交工單提升額度。
400 QuotaFull.ChildInstanceRelatedCen The childinstance has exceed the quota of the times that a childinstance can be attached as an attachment. 該執行個體綁定 CEN 數量已達到上限,無法載入。
400 Forbidden.ResourceOwnerTransitRouterServiceNotOpen The resource owner user has not opened transit router service. 資源所屬帳號轉發路由器服務未開通,請通知對方開通後重試。
400 OperationUnsupported.VcoTunnelNotMatchZoneParam The tunnel type of the entered Vco does not match the Zone parameter. 輸入的 Vco 隧道類型和 Zone 參數不匹配。
400 Forbidden.ResourceOwnerTransitRouterServiceExpired The transit router service of the account to which the resource belongs has been suspended due to arrears. Please notify the other party to renew the service and try again. 資源所屬帳號的轉發路由器服務已欠費停服,請通知對方續費後重試。
400 Forbidden.TransitRouterServiceExpired The transit router service is out of service. 轉發路由器服務已欠費停服,請續費後重試。
400 InvalidParameter Invalid parameter. 參數不合法。
400 Unauthorized The AccessKeyId is unauthorized. 帳號無權限操作。
400 IllegalParam.TransitRouterRegionId TransitRouterRegionId is illegal. TransitRouterRegionId 不合法。
400 InvalidVpnId.NotFound The specified vpn connection instance id does not exist. 指定的 VPN 連線不存在,請您檢查該 VPN 連線 ID 是否正確。
400 InvalidParameter.ResourceType The specified parameter ResourceType is invalid.
400 InvalidParameter.VpnId The specified parameter VpnId is invalid.
400 IllegalParam.ChargeType The specified ChargeType is illegal. 付費類型無效。
400 Forbidden.AttachChildInstanceAcrossBid Operation is not supported for current account. 目前帳號不允許綁定不同 bid 帳號下的子執行個體資源。
400 InvalidParameter.TagValue The specified parameter TagValue is invalid. 輸入的參數 Tag Value 不合法。

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

變更歷史

更多資訊,參考變更詳情