呼叫 CreateVpnAttachment 介面建立 IPsec 連線,用於綁定轉發路由器執行個體。
介面說明
-
在綁定轉發路由器場景下,IPsec 連線已升級為雙隧道模式。建立 IPsec-VPN 連線時,除必填參數外,僅支援設定雙隧道模式相關請求參數:ClientToken、Name、NetworkType、EffectImmediately、Tags 陣列、ResourceGroupId、TunnelOptionsSpecification 陣列、EnableTunnelsBgp。更多資訊,請參見綁定轉發路由器場景雙隧道 IPsec-VPN 連線說明。
-
呼叫
CreateVpnAttachment介面建立的 IPsec 連線預設未綁定任何資源,後續您可以透過呼叫 CreateTransitRouterVpnAttachment 介面將 IPsec 連線綁定至轉發路由器執行個體。綁定轉發路由器執行個體後,系統會為 IPsec 連線分配閘道器 IP 地址,您可以呼叫 DescribeVpnConnection 介面檢視。
前提條件
建立 IPsec 連線前,請確保您已經在 IPsec 連線所在的地區建立了使用者閘道器。具體操作,請參見 CreateCustomerGateway 。
如果您需要為 IPsec 連線新增 BGP 設定,請確保使用者閘道器已新增自治系統號。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
vpc:CreateVpnAttachment |
create |
*All Resource
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
IPsec 連線所屬的地區 ID。 您可以透過呼叫 DescribeRegions 介面取得地區 ID。 |
cn-hangzhou |
| Name |
string |
否 |
IPsec 連線的名稱。 名稱長度為 1~100 個字元,不能以 |
nametest |
| CustomerGatewayId |
string |
否 |
使用者閘道器 ID。 說明
僅建立單隧道模式 IPsec-VPN 連線時需設定此參數,且此參數為必填。 |
cgw-p0w2jemrcj5u61un8**** |
| NetworkType |
string |
否 |
IPsec 連線的網路類型。取值:
|
public |
| LocalSubnet |
string |
是 |
需要與本機資料中心互通的 VPC 側網段,用於第二階段協商。 多個網段之間使用半形逗號 (,) 分隔,例如:192.168.1.0/24,192.168.2.0/24。 關於 IPsec 連線路由模式的說明:
|
10.1.1.0/24,10.1.2.0/24 |
| RemoteSubnet |
string |
是 |
需要與 VPC 互通的本機資料中心側網段,用於第二階段協商。 多個網段之間使用半形逗號 (,) 分隔,例如:192.168.3.0/24,192.168.4.0/24。 關於 IPsec 連線路由模式的說明:
|
10.1.3.0/24,10.1.4.0/24 |
| EffectImmediately |
boolean |
否 |
選擇 IPsec 連線的設定是否立即生效。取值:
|
false |
| IkeConfig |
string |
否 |
建立單隧道模式的 IPsec-VPN 連線時支援設定此參數。 第一階段協商的設定資訊:
|
{"Psk":"1234****","IkeVersion":"ikev1","IkeMode":"main","IkeEncAlg":"aes","IkeAuthAlg":"sha1","IkePfs":"group2","IkeLifetime":86400,"LocalId":"47.XX.XX.1","RemoteId":"47.XX.XX.2"} |
| IpsecConfig |
string |
否 |
建立單隧道模式的 IPsec-VPN 連線時支援設定此參數。 第二階段協商的設定資訊:
|
{"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400} |
| BgpConfig |
string |
否 |
建立單隧道模式的 IPsec-VPN 連線時支援設定此參數。 BGP 的設定資訊:
說明
|
{"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"} |
| HealthCheckConfig |
string |
否 |
建立單隧道模式的 IPsec-VPN 連線時支援設定此參數。 健康檢查設定資訊:
|
{"enable":"true","dip":"192.168.1.1","sip":"10.1.1.1","interval":"3","retry":"3","Policy": "revoke_route"} |
| AutoConfigRoute |
boolean |
否 |
是否自動設定路由。取值:
|
true |
| EnableDpd |
boolean |
否 |
建立單隧道模式的 IPsec-VPN 連線時支援設定此參數。 是否開啟 DPD(對等體存活偵測)功能。取值:
|
true |
| EnableNatTraversal |
boolean |
否 |
建立單隧道模式的 IPsec-VPN 連線時支援設定此參數。 是否開啟 NAT 穿越功能。取值:
|
true |
| RemoteCaCert |
string |
否 |
對端的 CA 憑證。 說明
目前參數暫不生效。 |
-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
| ClientToken |
string |
否 |
用戶端 Token,用於保證請求的冪等性。 從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元。 說明
若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 識別碼。每次 API 請求的 RequestId 都不一樣。 |
123e4567-e89b-12d3-a456-4266**** |
| Tags |
array<object> |
否 |
IPsec 連線待新增的標籤清單。 一次最多支援為 IPsec 連線新增 20 個標籤。 |
|
|
object |
否 |
標籤資訊。 |
||
| Key |
string |
否 |
標籤鍵。一旦輸入該值,則不允許為空字串。 最多支援 64 個字元,不能以 一次最多支援輸入 20 個標籤鍵。 |
TagKey |
| Value |
string |
否 |
標籤值。 標籤值最多支援 128 個字元,可以為空字串,不能以 一個標籤鍵對應一個標籤值。一次最多支援輸入 20 個標籤值。 |
TagValue |
| ResourceGroupId |
string |
否 |
IPsec 連線所屬的資源群組 ID。
|
rg-acfmzs372yg**** |
| TunnelOptionsSpecification |
array<object> |
否 |
設定隧道。
|
|
|
array<object> |
否 |
設定隧道資訊。 |
||
| CustomerGatewayId |
string |
否 |
隧道關聯的使用者閘道器 ID。 說明
建立雙隧道模式 IPsec-VPN 連線時此參數為必填。 |
cgw-p0w2jemrcj5u61un8**** |
| EnableDpd |
boolean |
否 |
是否為隧道開啟 DPD(對等體存活偵測)功能。取值:
|
true |
| EnableNatTraversal |
boolean |
否 |
是否為隧道開啟 NAT 穿越功能。取值:
|
true |
| TunnelIndex |
integer |
否 |
隧道的建立順序。
|
1 |
| TunnelBgpConfig |
object |
否 |
為隧道新增 BGP 設定。 說明
當您為 IPsec 連線開啟 BGP 功能後(即指定 EnableTunnelsBgp 參數的值為 true)需要設定此參數。 |
|
| LocalAsn |
integer |
否 |
隧道本端(阿里雲側)的自治系統號。自治系統號取值範圍:1~4294967295。預設值:45104。 說明
建議您使用自治系統號的私有號碼與阿里雲建立 BGP 連線。自治系統號的私有號碼範圍請自行查閱文件。 |
65530 |
| LocalBgpIp |
string |
否 |
隧道本端(阿里雲側)的 BGP 地址。該地址為 BGP 網段內的一個 IP 地址。 |
169.254.10.1 |
| TunnelCidr |
string |
否 |
隧道的 BGP 網段。該網段需是一個在 169.254.0.0/16 內的遮罩長度為 30 的網段,且不能是 169.254.0.0/30、169.254.1.0/30、169.254.2.0/30、169.254.3.0/30、169.254.4.0/30、169.254.5.0/30、169.254.6.0/30 和 169.254.169.252/30。 說明
一個 IPsec 連線下兩個隧道的隧道網段不能相同。 |
169.254.10.0/30 |
| TunnelIkeConfig |
object |
否 |
第一階段協商的設定資訊。 |
|
| IkeAuthAlg |
string |
否 |
第一階段協商的驗證演算法。取值:md5、sha1、sha256、sha384、sha512。預設值:sha1。 |
sha1 |
| IkeEncAlg |
string |
否 |
第一階段協商的加密演算法。取值:aes、aes192、aes256、des 或 3des。預設值:aes。 |
aes |
| IkeLifetime |
integer |
否 |
第一階段協商出的 SA 生存週期。單位:秒。 取值範圍:0~86400。預設值:86400。 |
86400 |
| IkeMode |
string |
否 |
IKE 版本的協商模式。取值:main 或 aggressive。預設值:main。
|
main |
| IkePfs |
string |
否 |
第一階段協商使用的 Diffie-Hellman 金鑰交換演算法。預設值:group2。 |
group2 |
| IkeVersion |
string |
否 |
IKE 協定的版本。取值:ikev1 或 ikev2。預設值:ikev2。 相對於 IKEv1 版本,IKEv2 版本簡化了 SA 的協商過程並且對於多網段的場景提供了更好的支援。 |
ikev2 |
| LocalId |
string |
否 |
隧道本端(阿里雲側)的識別碼,用於第一階段的協商。長度限制為 100 個字元,不能包含空格。預設值為隧道的 IP 地址。 LocalId 支援 FQDN 格式,如果您使用 FQDN 格式,協商模式建議選擇為 aggressive(野蠻模式)。 |
47.XX.XX.1 |
| Psk |
string |
否 |
預共用金鑰,用於隧道與隧道對端之間的身份驗證。
說明
隧道及隧道對端的預共用金鑰需一致,否則系統無法正常建立隧道。 |
123456**** |
| RemoteId |
string |
否 |
隧道對端的識別碼,用於第一階段的協商。長度限制為 100 個字元,不能包含空格。預設值為隧道關聯的使用者閘道器 IP 地址。 RemoteId 支援 FQDN 格式,如果您使用 FQDN 格式,協商模式建議選擇為 aggressive(野蠻模式)。 |
47.XX.XX.2 |
| TunnelIpsecConfig |
object |
否 |
第二階段協商的設定資訊。 |
|
| IpsecAuthAlg |
string |
否 |
第二階段協商的驗證演算法。 取值:md5、sha1、sha256、sha384、sha512。預設值:sha1。 |
sha1 |
| IpsecEncAlg |
string |
否 |
第二階段協商的加密演算法。取值:aes、aes192、aes256、des 或 3des。預設值:aes。 |
aes |
| IpsecLifetime |
integer |
否 |
第二階段協商出的 SA 生存週期。單位:秒。 取值範圍:0~86400。預設值:86400。 |
86400 |
| IpsecPfs |
string |
否 |
第二階段協商使用的 Diffie-Hellman 金鑰交換演算法。預設值:group2。 取值:disabled、group1、group2、group5、group14。 |
group2 |
| EnableTunnelsBgp |
boolean |
否 |
建立雙隧道模式的 IPsec-VPN 連線時支援設定此參數。 是否為隧道開啟 BGP 功能。取值:true 或 false(預設值)。 說明
在新增 BGP 設定前,建議您先了解 BGP 動態路由功能的工作機制和使用限制。更多資訊,請參見設定 BGP 動態路由。 |
false |
| DryRun |
boolean |
否 |
是否只預檢此次請求。取值:
|
false |
| TunnelBandwidth |
string |
否 |
用於說明 VPN 單條隧道的頻寬規格,取值: Standard(預設值):標準型,預設頻寬 1Gbps Large(大型):大型,預設頻寬 3Gbps。 |
Standard |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
返回結果。 |
||
| RequestId |
string |
請求 ID。 |
88187252-0E26-3C4D-9D1D-32A04454EBBA |
| VpnConnectionId |
string |
IPsec 連線 ID。 |
vco-p0wb09rama8qwwgfn**** |
| Name |
string |
IPsec 連線的名稱。 |
nametest |
| CreateTime |
integer |
建立 IPsec 連線的時間戳記。單位:毫秒。 時間戳記的格式採用 Unix 時間戳記,表示從格林威治時間 1970 年 01 月 01 日 00 時 00 分 00 秒至建立 IPsec 連線時的總時長。 |
1658201810000 |
| Code |
string |
目前任務返回的狀態碼。200 表示任務成功。 |
200 |
| Message |
string |
目前任務返回的資訊。 |
successful |
| Success |
boolean |
目前任務是否成功執行。
|
true |
樣本
正常返回樣本
JSON格式
{
"RequestId": "88187252-0E26-3C4D-9D1D-32A04454EBBA",
"VpnConnectionId": "vco-p0wb09rama8qwwgfn****",
"Name": "nametest",
"CreateTime": 1658201810000,
"Code": "200",
"Message": "successful",
"Success": true
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | Resource.QuotaFull | The quota of resource is full | |
| 400 | InvalidVpnConnection.AlreadyExists | Vpn connection already exists. | |
| 400 | VpnRouteEntry.AlreadyExists | The specified route entry is already exist. | 該路由已存在。 |
| 400 | VpnRouteEntry.Conflict | The specified route entry has conflict. | 指定的用戶端 IP 集區與 VPN 連線或 SSL 伺服器衝突。 |
| 400 | NotSupportVpnConnectionParameter.IpsecPfs | The specified vpn connection ipsec Ipsec Pfs is not support. | IPsec 連線中指定的 Pfs 參數不支援。 |
| 400 | NotSupportVpnConnectionParameter.IpsecAuthAlg | The specified vpn connection ipsec Auth Alg is not support. | IPsec 連線中指定的驗證演算法不支援。 |
| 400 | VpnRouteEntry.BackupRoute | Validate backup route entry failed. | 主備路由項目驗證失敗。 |
| 400 | VpnRouteEntry.InvalidWeight | Invalid route entry weight value. | 路由權重值不合法。 |
| 400 | InvalidParameter.VpnConnectionName | The specified vpn connection name is invalid. | 指定的 VPN 連線名稱不合規範。 |
| 400 | QuotaExceeded.PolicyBasedRoute | The maximum number of policy-based routes is exceeded. Existing routes: %s. Routes to be created: %s. Maximum routes: %s. | 原則路由條數已達上限,目前已有 %s 條,本次將建立 %s 條,上限為 %s 條。 |
| 400 | MissingParameter.TunnelCidr | The parameter TunnelCidr is mandatory when BGP is enabled. | 開啟 BGP 時,通道 CIDR 參數是必填項。 |
| 400 | OperationUnsupported.EnableBgp | Current region does not support enable BGP. | 目前地域不支援開啟 BGP。 |
| 400 | MissingParam.CustomerGatewayAsn | Asn of customer gateway is mandatory when BGP is enabled. | 開啟 BGP 時,客戶端閘道器的自治系統號不可為空。 |
| 400 | IllegalParam.LocalAsn | The specified LocalAsn is invalid. | LocalAsn 參數不合法。 |
| 400 | InvalidParameter.BgpConfig | The specified BgpConfig is invalid. | 指定的 BGP 設定不合規範。 |
| 400 | IllegalParam.EnableBgp | VPN connection must enable BGP when VPN gateway has enabled BGP. | 當 VPN 閘道器啟用 BGP 時,VPN 連線必須啟用 BGP。 |
| 400 | IllegalParam.TunnelCidr | The specified TunnelCidr is invalid. | 參數 TunnelCidr 不合法。 |
| 400 | InvalidLocalBgpIp.Malformed | The specified LocalBgpIp is malformed. | 指定的本端 BGP 的 IP 異常。 |
| 400 | IllegalParam.LocalBgpIp | The specified LocalBgpIp is invalid. | 本端 BGP 位址不合法。 |
| 400 | IllegalParam.LocalSubnet | The specified "LocalSubnet" (%s) is invalid. | 本端網段 (%s) 不合法。 |
| 400 | IllegalParam.RemoteSubnet | The specified "RemoteSubnet" (%s) is invalid. | 對端網段 (%s) 不合法。 |
| 400 | OperationFailed.MissCertificate | The VPN connecton has not associated any certificates. | 目前 VPN 連線未關聯任何憑證。 |
| 400 | MissingParam.RemoteId | The remote ID is mandatory when creating national standard VPN connection. | 建立國密 VPN 連線時,對端 ID 為必填參數。 |
| 400 | CustomerGateway.ConflictRouteEntry | The specified customer gateway has conflict with route entry. | 目前使用者閘道器和路由存在衝突。 |
| 400 | VpnTask.CONFLICT | Vpn task has conflict. | VPN 操作存在衝突,請稍後重試。 |
| 400 | Forbidden.TagKey.Duplicated | The specified tag key already exists. | 標籤資源重複。 |
| 400 | OperationFailed.NoAvailableAmount | The available amount of your account is less than 0, please recharge before attempting to purchase. | 您的帳戶可用額度小於 0,請先儲值後再嘗試購買。 |
| 400 | SizeLimitExceeded.TagNum | The maximum number of tags is exceeded. | 標籤數量超限。 |
| 400 | InvalidParameter.TagValue | The specified parameter TagValue is invalid. | 指定的參數 TagValue 不合規範。 |
| 400 | InvalidParameter.TagKey | The specified parameter TagKey is invalid. | 指定的參數 TagKey 不合規範。 |
| 400 | Duplicated.TagKey | The specified parameter TagKey is duplicated. | 指定的參數 TagKey 重複。 |
| 400 | InternalError | The request processing has failed due to some unknown error, exception or failure. | |
| 400 | InvalidTunnelCidr.Malformed | The specified TunnelCidr is malformed. | 指定的通道 CIDR 異常。 |
| 400 | CustomerGateway.ConflictVpnIp | The customer gateway associated with the IPSec connection should not have the same IP address as the VPN gateway. | 使用者閘道器的 IP 與 VPN 閘道器 IP 衝突。 |
| 400 | MissingParameter.TunnelOptionsSpecification | The required parameters are missing when creating a tunnel for dual-tunnel VPN. | 雙通道 VPN 在建立通道時,必填參數缺失。 |
| 400 | CreateDbrRoutesQuotaFull.QuotaFull | The number of created destination routes exceeds the quota limit. | 建立目的路由數量超過配額限制。 |
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | DryRun 驗證通過。 |
| 400 | VpnConnection.InvalidCreateTunnelOptions | The master and slave tunnels must be created at the same time. | 主要通道和備用通道必須同時建立。 |
| 400 | OperationUnsupported.LargeTunnelBandwidth | Large tunnelBandwidth VpnAttachment is unsupported. | 不支援建立大頻寬的 VpnAttachment。 |
| 400 | IllegalParam.TunnelBandwidth | TunnelBandwidth is illegal. | TunnelBandwidth 參數無效。 |
| 400 | EncAlgInvalid.DesIncompatible | Des/3des in IkeEncAlg and IpsecEncAlg does not support multi algorithm. | IKE 加密演算法以及 IPsec 加密演算法中,des/3des 不支援多演算法相容。 |
| 400 | OperationFailed.OpenCdtServiceFirst | The operation is failed because of %s. | 您目前指定的計費類型需開通 CDT 計費,請開通 CDT 後重試。 |
| 400 | IkeVersionInvalid.GcmIncompatible | Ikev1 does not support IkeEncAlg of gcm16. | Ikev1 不支援 IKE 加密演算法僅設定 gcm16 演算法。 |
| 400 | CustomerGateway.AsnNotConfigured | ASN of CustomerGateway is required when enabling BGP on an IPSec connection. | IPSec 連線開啟 BGP 時,需要在使用者閘道器上設定 ASN。 |
| 403 | Forbbiden.SubUser | User not authorized to operate on the specified resource as your account is created by another user. | |
| 403 | Forbidden | User not authorized to operate on the specified resource. | EIP 不屬於當前呼叫者,請您檢查該 EIP 是否可被您呼叫。 |
| 404 | InvalidCustomerGatewayInstanceId.NotFound | The specified customer gateway instance id does not exist. | 指定的使用者閘道器執行個體不存在,請檢查使用者閘道器執行個體 ID 是否正確。 |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。