呼叫 CreateVpnConnection 介面建立 IPsec 連線。
介面說明
-
如果 VPN 閘道器執行個體支援建立雙通道模式的 IPsec-VPN 連線,則呼叫
CreateVpnConnection介面時除支援設定必填參數外,還支援設定以下請求參數:ClientToken、Name、EffectImmediately、AutoConfigRoute、Tags 陣列、TunnelOptionsSpecification 陣列、EnableTunnelsBgp。
支援建立雙通道模式 IPsec-VPN 連線的地域和可用區資訊,請參閱IPsec-VPN 連線升級為雙通道模式。
-
如果 VPN 閘道器執行個體僅支援建立單通道模式的 IPsec-VPN 連線,則呼叫
CreateVpnConnection介面時除支援設定必填參數外,還支援設定以下請求參數:ClientToken、CustomerGatewayId、Name、EffectImmediately、IkeConfig、IpsecConfig、HealthCheckConfig、AutoConfigRoute、EnableDpd、EnableNatTraversal、BgpConfig、RemoteCaCertificate、Tags 陣列。
-
CreateVpnConnection 介面屬於非同步介面,即系統返回一個執行個體 ID,但該 IPsec 連線尚未建立成功,系統後台的建立任務仍在進行。您可以呼叫 DescribeVpnGateway 查詢 VPN 閘道器執行個體的狀態,來確定 IPsec 連線
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
|
操作 |
存取層級 |
資源類型 |
條件關鍵字 |
關聯操作 |
|
vpc:CreateVpnConnection |
create |
*CustomerGateway
*VpnConnection
*VpnGateway
|
無 | 無 |
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| RegionId |
string |
是 |
IPsec 連線所在的地域 ID。您可以透過呼叫 DescribeRegions 介面取得地域 ID。 |
cn-shanghai |
| ClientToken |
string |
否 |
用戶端 Token,用於保證請求的冪等性。 從您的用戶端產生一個參數值,確保不同請求間該參數值唯一。ClientToken 只支援 ASCII 字元。 說明
若您未指定,則系統自動使用 API 請求的 RequestId 作為 ClientToken 識別碼。每次 API 請求的 RequestId 不一樣。 |
02fb3da4-130e-11e9-8e44-001**** |
| CustomerGatewayId |
string |
否 |
建立單通道模式的 IPsec-VPN 連線時支援設定該參數,且該參數必填。 使用者閘道器的 ID。 |
cgw-p0w2jemrcj5u61un8**** |
| VpnGatewayId |
string |
是 |
VPN 閘道器執行個體 ID。 |
vpn-bp1q8bgx4xnkm**** |
| Name |
string |
否 |
IPsec 連線的名稱。 長度為 1~100 個字元,不能以 |
IPsec |
| LocalSubnet |
string |
是 |
需要和本地資料中心互通的 VPC 側的網段,用於第二階段協商。 多個網段之間用半形逗號(,)分隔,例如:192.168.1.0/24,192.168.2.0/24。 關於 IPsec 連線路由模式的說明:
|
10.10.1.0/24,10.10.2.0/24 |
| RemoteSubnet |
string |
是 |
需要和 VPC 互通的本地資料中心側的網段,用於第二階段協商。 多個網段之間用半形逗號(,)分隔,例如:192.168.3.0/24,192.168.4.0/24。 關於 IPsec 連線路由模式的說明:
|
10.10.3.0/24,10.10.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} |
| HealthCheckConfig |
string |
否 |
建立單通道模式的 IPsec-VPN 連線時支援設定該參數。 健康檢查設定資訊:
|
{"enable":"true","dip":"192.168.10.1","sip":"10.10.1.1","interval":"3","retry":"3"} |
| AutoConfigRoute |
boolean |
否 |
是否自動設定路由。取值:
|
true |
| EnableDpd |
boolean |
否 |
建立單通道模式的 IPsec-VPN 連線時支援設定該參數。 是否開啟 DPD(對等體存活偵測)功能。取值:
|
true |
| EnableNatTraversal |
boolean |
否 |
建立單通道模式的 IPsec-VPN 連線時支援設定該參數。 是否開啟 NAT 穿越功能。取值:
|
true |
| BgpConfig |
string |
否 |
建立單通道模式的 IPsec-VPN 連線時支援設定該參數。 BGP 的設定資訊:
說明
|
{"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"} |
| RemoteCaCertificate |
string |
否 |
建立單通道模式的 IPsec-VPN 連線時支援設定該參數。 如果當前 VPN 閘道器執行個體為國密型 VPN 閘道器,您需要設定對端的 CA 憑證。
|
-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
| Tags |
array<object> |
否 |
IPsec 連線待新增的標籤清單。 一次最多支援為 IPsec 連線新增 20 個標籤。 |
|
|
object |
否 |
標籤資訊。 |
||
| Key |
string |
否 |
標籤鍵。一旦輸入該值,則不允許為空字串。 最多支援 64 個字元,不能以 一次最多支援輸入 20 個標籤鍵。 |
TagKey |
| Value |
string |
否 |
標籤值。 標籤值最多支援 128 個字元,可以為空字串,不能以 一個標籤鍵對應一個標籤值。一次最多支援輸入 20 個標籤值。 |
TagValue |
| TunnelOptionsSpecification |
array<object> |
否 |
設定通道。
|
|
|
array<object> |
否 |
設定通道資訊。 |
||
| CustomerGatewayId |
string |
否 |
通道關聯的使用者閘道器 ID。 說明
|
cgw-p0wy363lucf1uyae8**** |
| EnableDpd |
boolean |
否 |
是否為通道開啟 DPD(對等體存活偵測)功能。取值:
|
true |
| EnableNatTraversal |
boolean |
否 |
是否為通道開啟 NAT 穿越功能。取值:
|
true |
| RemoteCaCertificate |
string |
否 |
如果當前 VPN 閘道器執行個體為國密型 VPN 閘道器,您需要為通道設定對端的 CA 憑證。
|
-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
| Role |
string |
否 |
通道的角色。取值:
|
master |
| TunnelBgpConfig |
object |
否 |
為通道新增 BGP 設定。 |
|
| LocalAsn |
integer |
否 |
通道本端(阿里雲側)的自治系統號。自治系統號取值範圍:1~4294967295。預設值:45104。 說明
|
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。 說明
在一個 VPN 閘道器執行個體下,每個通道的 BGP 網段需保持唯一。 |
169.254.10.0/30 |
| TunnelIkeConfig |
object |
否 |
第一階段協商的設定資訊。 |
|
| IkeAuthAlg |
string |
否 |
第一階段協商的驗證演算法。 取值:md5、sha1、sha256、sha384、sha512。預設值:md5。 |
md5 |
| 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。預設值:ikev1。 相對於 IKEv1 版本,IKEv2 版本簡化了 SA 的協商過程並且對於多網段的場景提供了更好的支援。 |
ikev1 |
| LocalId |
string |
否 |
通道本端(阿里雲側)的識別碼,用於第一階段的協商。長度限制為 100 個字元,不能包含空格。預設值為通道的 IP 位址。 LocalId 支援 FQDN 格式,如果您使用 FQDN 格式,協商模式建議選擇為 aggressive(野蠻模式)。 |
47.21.XX.XX |
| Psk |
string |
否 |
預共用金鑰,用於通道與通道對端之間的身份驗證。
說明
通道及通道對端的預共用金鑰需一致,否則系統無法正常建立通道。 |
123456**** |
| RemoteId |
string |
否 |
通道對端的識別碼,用於第一階段的協商。長度限制為 100 個字元,不能包含空格。預設值為通道關聯的使用者閘道器的 IP 位址。 RemoteId 支援 FQDN 格式,如果您使用 FQDN 格式,協商模式建議選擇為 aggressive(野蠻模式)。 |
47.42.XX.XX |
| TunnelIpsecConfig |
object |
否 |
第二階段協商的設定資訊。 |
|
| IpsecAuthAlg |
string |
否 |
第二階段協商的驗證演算法。 取值:md5、sha1、sha256、sha384、sha512。預設值:md5。 |
md5 |
| 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(預設值)。 |
true |
| DryRun |
boolean |
否 |
是否只預檢此次請求。取值:
|
false |
返回參數
|
名稱 |
類型 |
描述 |
樣本值 |
|
object |
返回結果。 |
||
| RequestId |
string |
請求 ID。 |
082AD562-B8DB-4BB2-861F-DA1FCA01FD76 |
| VpnConnectionId |
string |
IPsec 連線的 ID。 |
vco-bp15oes1py4i6**** |
| Name |
string |
IPsec 連線的名稱。 |
test |
| CreateTime |
integer |
IPsec 連線的建立時間戳記。單位:毫秒。 時間戳記的格式採用 Unix 時間戳記,表示從格林威治時間 1970 年 01 月 01 日 00 時 00 分 00 秒至建立 IPsec 連線時的總時長。 |
1544666102000 |
樣本
正常返回樣本
JSON格式
{
"RequestId": "082AD562-B8DB-4BB2-861F-DA1FCA01FD76",
"VpnConnectionId": "vco-bp15oes1py4i6****",
"Name": "test",
"CreateTime": 1544666102000
}
錯誤碼
|
HTTP status code |
錯誤碼 |
錯誤資訊 |
描述 |
|---|---|---|---|
| 400 | Resource.QuotaFull | The quota of resource is full | |
| 400 | InvalidVpnConnection.AlreadyExists | Vpn connection already exists. | |
| 400 | VpnGateway.Configuring | The specified service is configuring. | |
| 400 | VpnGateway.FinancialLocked | The specified service is financial locked. | |
| 400 | VpnGateway.IpsecVpnDisabled | The vpn gateway does not enable IPSec VPN. | VPN 閘道器未啟用 IPsec VPN 功能。 |
| 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.ConflictSSL | The specified route entry has conflict with SSL client. | 路由項目與 SSL 用戶端衝突。 |
| 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 | OperationUnsupported.SetDPD | Current version of the VPN does not support setting DPD. | 目前 VPN 閘道版本不支援 DPD 功能。 |
| 400 | OperationUnsupported.SetNatTraversal | Current version of the VPN does not support setting NAT traversal. | 目前 VPN 閘道版本不支援 NAT 穿越功能。 |
| 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 version of the VPN 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 | IllegalParam.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 gateway 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 | 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 | VpnConnectionParamInvalid.SameVpnAndCgwDifferentIkeConfigs | IPSec connections associated with the same user gateway and VPN gateway should have the same pre-shared key and IKE configuration. | 偵測到多個 IPsec 連線關聯了相同的 VPN 閘道器和使用者閘道器,多個 IPsec 連線的預共用金鑰和 IKE 階段的設定參數需保持相同。 |
| 400 | VpnConnectionParamInvalid.SameVpnAndCgwTrafficSelectorOverlap | Traffic selectors of IPSec connections associated with the same user gateway and VPN gateway should not overlap. | 偵測到多個 IPsec 連線關聯了相同的 VPN 閘道器和使用者閘道器,多個 IPsec 連線的感興趣流量網段不能重疊。 |
| 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 | VpnGateway.IPsecServerAndVpnConnectionConflict | The IPSec connection and IPSec server cannot be configured on the same VPN gateway at the same time. | 一個 VPN 閘道器不支援同時設定 IPSec 伺服器與 IPSec 連線。 |
| 400 | InvalidSslVpnServerCertId.NotFound | The parameter is incorrect. The corresponding SSL VPN server certificate cannot be found. | 參數不正確,未找到相應的 SSL VPN 伺服器的憑證。 |
| 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 | CreatePbrRoutesQuotaFull.QuotaFull | The number of policy routes exceeds the quota limit. | 原則路由數量超過配額限制。 |
| 400 | CreateVpnConnectionsQuotaFull.QuotaFull | The number of VPN connections exceeds the quota limit. | VPN 連線數量超過配額限制。 |
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | DryRun 驗證通過。 |
| 400 | OperationFailed.OpenCdtServiceFirst | The operation is failed because of %s. | 您目前指定的計費類型需開通 CDT 計費,請開通 CDT 後重試。 |
| 400 | EncAlgInvalid.DesIncompatible | Des/3des in IkeEncAlg and IpsecEncAlg does not support multi algorithm. | IKE 加密演算法以及 IPsec 加密演算法中,des/3des 不支援多演算法相容。 |
| 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。 |
| 400 | OperationFailed.CenLevelNotSupport | When the VPC to which the VPN gateway belongs is attached to a FULL-mode CEN, the VPN gateway cannot enable BGP. | 當 VPN 閘道器所屬 VPC 加入的雲端企業網且開啟了路由同步時,VPN 閘道器不能開啟 BGP。 |
| 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 是否正確。 |
| 404 | InvalidVpnGatewayInstanceId.NotFound | The specified vpn gateway instance id does not exist. |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。