全部產品
Search
文件中心

:CreateTransitRouterVpnAttachment - 建立VPN串連

更新時間:Oct 29, 2025

轉寄路由器支援串連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. CEN執行個體不存在。
400 InvalidStatus.ResourceStatus The resource is not in a valid state for the attachment operation. 當前資源狀態不支援該操作,請稍後重試。
400 InvalidTransitRouterId.NotFound TransitRouterId is not found. 轉寄路由執行個體ID不存在。
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不支援建立企業版轉寄路由器。
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. 當前TransitRouter的狀態不支援該操作,請稍後重試。
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. 付費類型非法

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

變更歷史

更多資訊,參考變更詳情