功能介紹
創(chuàng)建VPN連接,連接VPN網(wǎng)關(guān)與對端網(wǎng)關(guān)。
URI
POST /v5/{project_id}/vpn-connection
名稱 |
類型 |
是否必選 |
說明 |
---|---|---|---|
project_id |
String |
是 |
項目ID,可以通過獲取項目ID獲取項目ID。 |
請求消息
- 請求參數(shù)
表2 請求參數(shù) 名稱
類型
是否必選
描述
vpn_connection
是
vpn_connection對象
表3 CreateVpnConnectionRequestBodyContent 名稱
類型
是否必選
描述
name
String
否
- 功能說明:VPN連接名稱,不填時會自動生成格式為vpn-****的名稱。例如:vpn-13be。
- 取值范圍:1-64個字符,支持?jǐn)?shù)字、英文字母、中文(\u4e00 - \u9fa5)、_(下劃線)、-(中劃線)。
vgw_id
String
是
- 功能說明:VPN網(wǎng)關(guān)ID
- 約束:36位UUID,當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時,VPN網(wǎng)關(guān)必須已導(dǎo)入過VPN網(wǎng)關(guān)證書。
可以通過查詢VPN網(wǎng)關(guān)列表查看VPN網(wǎng)關(guān)的ID。
vgw_ip
String
是
- 功能說明:
當(dāng)VPN網(wǎng)關(guān)的network_type配置為public時,vgw_ip為VPN網(wǎng)關(guān)EIP的ID。
當(dāng)VPN網(wǎng)關(guān)的network_type配置為private時,vgw_ip為VPN網(wǎng)關(guān)使用的接入私網(wǎng)IP。
- 約束:36位UUID或點分十進制IPv4地址(如192.168.45.7)
可以通過查詢VPN網(wǎng)關(guān)查看VPN網(wǎng)關(guān)所使用的EIP的ID或接入私網(wǎng)IP。
style
String
否
cgw_id
String
是
- 功能說明:對端網(wǎng)關(guān)ID
- 約束:36位UUID,當(dāng)VPN網(wǎng)關(guān)的flavor配置為GM時,對端網(wǎng)關(guān)必須已導(dǎo)入過對端網(wǎng)關(guān)證書。
peer_subnets
Array of String
否
tunnel_local_address
String
否
tunnel_peer_address
String
否
enable_nqa
Boolean
否
- 功能說明:開啟NQA檢測
- 取值范圍:true,false
- 默認(rèn)值:false
- 約束:當(dāng)style為static時填寫,否則不填。
psk
String
否
policy_rules
否
- 功能說明:策略模式的策略規(guī)則組
- 約束:最多填寫5個。style為policy時填寫,為static或bgp時不填。
ikepolicy
否
ike策略對象
ipsecpolicy
否
ipsec策略對象
ha_role
String
否
- 功能說明:雙活模式VPN網(wǎng)關(guān)下創(chuàng)建連接可不填,主備模式VPN網(wǎng)關(guān)下創(chuàng)建連接時,'master'表示主連接,'slave'表示備連接。
- 默認(rèn)值:master
- 約束:雙活模式VPN網(wǎng)關(guān)在主EIP或者主私網(wǎng)地址建立的連接必須填'master',在主EIP2或者主私網(wǎng)地址2建立的連接必須填'slave'。
表4 PolicyRule 名稱
類型
是否必選
描述
rule_index
Integer
否
source
String
否
- 功能說明:源地址網(wǎng)段。
- 約束:不能與其他PolicyRule下的source相同。
destination
Array of String
否
表5 IkePolicy 名稱
類型
是否必選
描述
ike_version
String
否
phase1_negotiation_mode
String
否
authentication_algorithm
String
否
encryption_algorithm
String
否
dh_group
String
否
authentication_method
String
否
lifetime_seconds
Integer
否
- 功能說明:表示SA的生存周期,當(dāng)該生存周期超時后IKE SA將自動更新。
- 取值范圍:60-604800,單位:秒。
- 默認(rèn)值:86400
local_id_type
String
否
local_id
String
否
peer_id_type
String
否
peer_id
String
否
dpd
否
對等體存活檢測對象
表6 Dpd 名稱
類型
是否必選
描述
timeout
Integer
否
- 功能說明:對等體存活檢測報文重傳間隔
- 取值范圍:2-60,單位:秒。
- 默認(rèn)值:15
interval
Integer
否
- 功能說明:對等體存活檢測空閑時間
- 取值范圍:10-3600,單位:秒。
- 默認(rèn)值:30
msg
String
否
- 請求樣例
- 創(chuàng)建靜態(tài)路由模式連接。
POST https://{Endpoint}/v5/{project_id}/vpn-connection { "vpn_connection": { "vgw_id": "b32d91a4-****-****-****-e907174eb11d", "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde", "cgw_id": "5247ae10-****-****-****-dd36659a7f5d", "peer_subnets": [ "192.168.44.0/24" ], "psk": "abcd****" } }
- 創(chuàng)建策略模式連接。
POST https://{Endpoint}/v5/{project_id}/vpn-connection { "vpn_connection": { "vgw_id": "b32d91a4-****-****-****-e907174eb11d", "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde", "style": "policy", "cgw_id": "5247ae10-****-****-****-dd36659a7f5d", "peer_subnets": [ "192.168.44.0/24" ], "psk": "abcd****", "policy_rules": [{ "rule_index": 1, "source": "10.0.0.0/24", "destination": [ "192.168.0.0/24" ] }] } }
- 創(chuàng)建bgp路由模式連接。
POST https://{Endpoint}/v5/{project_id}/vpn-connection { "vpn_connection": { "name": "vpn-1655", "vgw_id": "b32d91a4-****-****-****-e907174eb11d", "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde", "style": "bgp", "cgw_id": "5247ae10-****-****-****-dd36659a7f5d", "peer_subnets": [ "192.168.44.0/24" ], "tunnel_local_address": "169.254.56.225/30", "tunnel_peer_address": "169.254.56.226/30", "psk": "abcd****", "ikepolicy": { "ike_version": "v2", "authentication_algorithm": "sha2-512", "encryption_algorithm": "aes-256", "dh_group": "group16", "lifetime_seconds": 172800, "local_id_type": "fqdn", "local_id": "123***", "peer_id_type": "fqdn", "peer_id": "456***", "dpd": { "timeout": 30, "interval": 60, "msg": "seq-notify-hash" } }, "ipsecpolicy": { "authentication_algorithm": "sha2-512", "encryption_algorithm": "aes-256", "pfs": "group16", "transform_protocol": "esp", "lifetime_seconds": 7200, "encapsulation_mode": "tunnel" } } }
- 創(chuàng)建靜態(tài)路由模式連接。
響應(yīng)消息
- 響應(yīng)參數(shù)
返回狀態(tài)碼為 201: successful operation。
表8 響應(yīng)Body參數(shù)列表 名稱
類型
描述
vpn_connection
vpn_connection對象
request_id
String
請求ID
表9 ResponseVpnConnection 名稱
類型
描述
id
String
- 功能說明:VPN連接ID
- 格式:36位UUID
name
String
- 功能說明:VPN連接名稱,不填時會自動生成。
- 取值范圍:1-64個字符,支持?jǐn)?shù)字、英文字母、中文(\u4e00 - \u9fa5)、_(下劃線)、-(中劃線)。
vgw_id
String
- 功能說明:VPN網(wǎng)關(guān)ID
- 格式:36位UUID
vgw_ip
String
- 功能說明: VPN網(wǎng)關(guān)EIP的ID或接入私網(wǎng)IP
- 格式:36位UUID或點分十進制IPv4地址(如192.168.45.7)
style
String
cgw_id
String
- 功能說明:對端網(wǎng)關(guān)ID
- 格式:36位UUID
peer_subnets
Array of String
對端子網(wǎng)。當(dāng)VPN網(wǎng)關(guān)的關(guān)聯(lián)模式為ER并且style字段為BGP或POLICY時不返回。
tunnel_local_address
String
路由模式下配置在VPN網(wǎng)關(guān)上的tunnel接口地址。僅當(dāng)style為STATIC或BGP時有效。
tunnel_peer_address
String
路由模式下配置在用戶側(cè)設(shè)備上的tunnel接口地址。僅當(dāng)style為STATIC或BGP時有效。
enable_nqa
Boolean
- 功能說明:開啟NQA檢測。僅當(dāng)style為STATIC時返回。
- 取值范圍:true,false。
policy_rules
策略模式的策略規(guī)則組。當(dāng)style為POLICY時返回實際的策略規(guī)則組,當(dāng)style為STATIC或BGP時不返回。
ikepolicy
ike策略對象
ipsecpolicy
ipsec策略對象
created_at
String
創(chuàng)建時間
updated_at
String
最后一次更新時間
enterprise_project_id
String
- 功能說明:企業(yè)項目ID
- 格式:36位UUID。與vgw_id所標(biāo)識VPN網(wǎng)關(guān)的企業(yè)項目ID一致。
connection_monitor_id
String
- 功能說明:VPN連接監(jiān)控ID
- 格式:36位UUID
ha_role
String
- 功能說明:主備模式VPN網(wǎng)關(guān)下的連接時,'master'表示主連接,'slave'表示備連接。雙活模式下的連接ha_role都是'master'。
- 默認(rèn)值:master
表10 PolicyRule 名稱
類型
描述
rule_index
Integer
- 功能說明:規(guī)則ID
- 取值范圍:0-50
source
String
源地址網(wǎng)段
destination
Array of String
目的地址網(wǎng)段。單個網(wǎng)段格式示例:192.168.52.0/24。每個PolicyRule最多返回50個。
表11 IkePolicy 名稱
類型
描述
ike_version
String
- 功能說明:IKE版本號
- 取值范圍:v1, v2
phase1_negotiation_mode
String
authentication_algorithm
String
- 功能說明:認(rèn)證算法
- 取值范圍:sha2-512,sha2-384,sha2-256,sha1,md5,sm3。
encryption_algorithm
String
- 功能說明:加密算法
- 取值范圍:aes-256-gcm-16,aes-128-gcm-16,aes-256,aes-192,aes-128,3des,sm4。
dh_group
String
- 功能說明:第一階段密鑰交換使用的DH組,當(dāng)VPN網(wǎng)關(guān)flavor為GM時不返回。
- 取值范圍:group1,group2,group5,group14,group15,group16,group19,group20,group21。
authentication_method
String
lifetime_seconds
Integer
- 功能說明:表示SA的生存周期,當(dāng)該生存周期超時后IKE SA將自動更新。
- 取值范圍:60-604800,單位:秒。
local_id_type
String
- 功能說明:本端ID類型,當(dāng)VPN網(wǎng)關(guān)flavor為GM時不返回。
- 取值范圍:ip,fqdn。
local_id
String
本端ID。當(dāng)local_id_type為ip時返回VPN連接所使用的網(wǎng)關(guān)IP;當(dāng)local_id_type為fqdn時返回創(chuàng)建或更新VPN連接時指定的本端ID。
當(dāng)VPN網(wǎng)關(guān)flavor為GM時不返回。
peer_id_type
String
- 功能說明:對端ID類型,當(dāng)VPN網(wǎng)關(guān)flavor為GM時不返回。
- 取值范圍:ip,fqdn。
peer_id
String
對端ID。當(dāng)peer_id_type為ip時返回對端網(wǎng)關(guān)的IP;當(dāng)peer_id_type為fqdn時返回創(chuàng)建或更新VPN連接時指定的對端ID。
當(dāng)VPN網(wǎng)關(guān)flavor為GM時不返回。
dpd
對等體存活檢測對象
表12 Dpd 名稱
類型
描述
timeout
Integer
- 功能說明:對等體存活檢測報文重傳間隔
- 取值范圍:2-60,單位:秒。
interval
Integer
- 功能說明:對等體存活檢測空閑時間
- 取值范圍:10-3600,單位:秒。
msg
String
表13 IpsecPolicy 名稱
類型
描述
authentication_algorithm
String
- 功能說明:認(rèn)證算法
- 取值范圍:sha2-512,sha2-384,sha2-256,sha1,md5,sm3。
encryption_algorithm
String
- 功能說明:加密算法
- 取值范圍:aes-256-gcm-16,aes-128-gcm-16,aes-256,aes-192,aes-128,3des,sm4。
pfs
String
- 功能說明:PFS使用的DH密鑰組,當(dāng)VPN網(wǎng)關(guān)flavor為GM時不返回。
- 取值范圍:group1,group2,group5,group14,group15,group16,group19,group20,group21,disable。
transform_protocol
String
lifetime_seconds
Integer
- 功能說明:表示配置IPSec連接建立的隧道以時間為基準(zhǔn)的生存周期。
- 取值范圍:30-604800,單位:秒
encapsulation_mode
String
- 響應(yīng)樣例
- 創(chuàng)建靜態(tài)路由模式連接的響應(yīng)。
{ "vpn_connection": { "id": "98c5af8a-6ee2-4482-99a2-ae2280a6f4c3", "name": "vpn-b2cb", "vgw_id": "b32d91a4-****-****-****-e907174eb11d", "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde", "style": "STATIC", "cgw_id": "5247ae10-****-****-****-dd36659a7f5d", "peer_subnets": ["192.168.44.0/24"], "tunnel_local_address": "169.254.56.225/30", "tunnel_peer_address": "169.254.56.226/30", "enable_nqa": false, "ikepolicy": { "ike_version": "v2", "authentication_algorithm": "sha2-256", "encryption_algorithm": "aes-128", "dh_group": "group15", "authentication_method": "pre-share", "lifetime_seconds": 86400, "local_id_type": "ip", "local_id": "10.***.***.134", "peer_id_type": "ip", "peer_id": "88.***.***.164", "dpd": { "timeout": 15, "interval": 30, "msg": "seq-hash-notify" } }, "ipsecpolicy": { "authentication_algorithm": "sha2-256", "encryption_algorithm": "aes-128", "pfs": "group15", "transform_protocol": "esp", "lifetime_seconds": 3600, "encapsulation_mode": "tunnel" }, "created_at": "2022-11-26T13:41:34.626Z", "updated_at": "2022-11-26T13:41:34.626Z", "enterprise_project_id": "0", "ha_role":"master" }, "request_id": "f91082d4-6d49-479c-ad1d-4e552a9f5cae" }
- 創(chuàng)建策略模式連接的響應(yīng)。
{ "vpn_connection": { "id": "98c5af8a-****-****-****-ae2280a6f4c3", "name": "vpn-799d", "vgw_id": "b32d91a4-****-****-****-e907174eb11d", "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde", "style": "POLICY", "cgw_id": "5247ae10-****-****-****-dd36659a7f5d", "peer_subnets": ["192.168.44.0/24"], "tunnel_local_address": "169.254.56.225/30", "tunnel_peer_address": "169.254.56.226/30", "policy_rules": [{ "rule_index": 1, "source": "10.0.0.0/24", "destination": [ "192.168.44.0/24" ] }], "ikepolicy": { "ike_version": "v2", "authentication_algorithm": "sha2-256", "encryption_algorithm": "aes-128", "dh_group": "group15", "authentication_method": "pre-share", "lifetime_seconds": 86400, "local_id_type": "ip", "local_id": "10.***.***.134", "peer_id_type": "ip", "peer_id": "88.***.***.164", "dpd": { "timeout": 15, "interval": 30, "msg": "seq-hash-notify" } }, "ipsecpolicy": { "authentication_algorithm": "sha2-256", "encryption_algorithm": "aes-128", "pfs": "group15", "transform_protocol": "esp", "lifetime_seconds": 3600, "encapsulation_mode": "tunnel" }, "created_at": "2022-11-26T13:41:34.626Z", "updated_at": "2022-11-26T13:41:34.626Z", "enterprise_project_id": "0", "ha_role":"master" }, "request_id": "f91082d4-6d49-479c-ad1d-4e552a9f5cae" }
- 創(chuàng)建bgp路由模式連接的響應(yīng)。
{ "vpn_connection": { "id": "98c5af8a-****-****-****-ae2280a6f4c3", "name": "vpn-1655", "vgw_id": "b32d91a4-****-****-****-e907174eb11d", "vgw_ip": "0c464dad-****-****-****-c22bb0eb0bde", "style": "BGP", "cgw_id": "5247ae10-****-****-****-dd36659a7f5d", "peer_subnets": ["192.168.44.0/24"], "tunnel_local_address": "169.254.56.225/30", "tunnel_peer_address": "169.254.56.226/30", "ikepolicy": { "ike_version": "v2", "authentication_algorithm": "sha2-512", "encryption_algorithm": "aes-256", "dh_group": "group16", "authentication_method": "pre-share", "lifetime_seconds": 172800, "local_id_type": "fqdn", "local_id": "123***", "peer_id_type": "fqdn", "peer_id": "456***", "dpd": { "timeout": 30, "interval": 60, "msg": "seq-notify-hash" } }, "ipsecpolicy": { "authentication_algorithm": "sha2-512", "encryption_algorithm": "aes-256", "pfs": "group16", "transform_protocol": "esp", "lifetime_seconds": 7200, "encapsulation_mode": "tunnel" }, "created_at": "2022-11-26T13:41:34.626Z", "updated_at": "2022-11-26T13:41:34.626Z", "enterprise_project_id": "0", "ha_role":"master" }, "request_id": "f91082d4-6d49-479c-ad1d-4e552a9f5cae" }
- 創(chuàng)建靜態(tài)路由模式連接的響應(yīng)。
狀態(tài)碼
請參見狀態(tài)碼