調用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 串連的建立狀態:
當 VPN 閘道執行個體處於 updating 狀態時,表示 IPsec 串連正在建立中。
當 VPN 閘道執行個體處於 active 狀態時,表示 IPsec 串連建立成功。
-
CreateVpnConnection 介面不支援在同一 VPN 閘道下並發建立 IPsec 串連。
調試
您可以在OpenAPI Explorer中直接運行該介面,免去您計算簽名的困擾。運行成功後,OpenAPI Explorer可以自動產生SDK程式碼範例。
調試
授權資訊
請求參數
|
名稱 |
類型 |
必填 |
描述 |
樣本值 |
| 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. | 路由條目存在衝突。 |
| 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. | 目前的版本的VPN不支援開啟BGP |
| 400 | MissingParam.CustomerGatewayAsn | Asn of customer gateway is mandatory when BGP is enabled. | 開啟BGP時,客戶網關的自治系統號不可以為空白。 |
| 400 | IllegalParam.LocalAsn | The specified LocalAsn is invalid. | 本端自治系統號不合法。 |
| 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 | 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。 |
| 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. | IPSec串連關聯的使用者網關與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演算法。 |
| 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. | 您沒有許可權操作指定資源,請申請許可權後再操作。 |
| 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. |
訪問錯誤中心查看更多錯誤碼。
變更歷史
更多資訊,參考變更詳情。