功能介绍
创建VPN连接,连接VPN网关与对端网关。
URI
POST /v5/{project_id}/vpn-connection
| 名称 | 类型 | 是否必选 | 说明 | 
|---|---|---|---|
| project_id | String | 是 | 项目ID,可以通过获取项目ID获取项目ID。 | 
请求消息
- 请求参数
表2 请求参数 名称 类型 是否必选 描述 vpn_connection 是 vpn_connection对象 表3 CreateVpnConnectionRequestBodyContent 名称 类型 是否必选 描述 name String 否 - 功能说明:VPN连接名称,不填时会自动生成格式为vpn-****的名称。例如:vpn-13be。
- 取值范围:1-64个字符,支持数字、英文字母、中文(\u4e00 - \u9fa5)、_(下划线)、-(中划线)。
 vgw_id String 是 - 功能说明:VPN网关ID
- 约束:36位UUID,当VPN网关的flavor配置为GM时,VPN网关必须已导入过VPN网关证书。
 可以通过查询VPN网关列表查看VPN网关的ID。 vgw_ip String 是 - 功能说明:
当VPN网关的network_type配置为public时,vgw_ip为VPN网关EIP的ID。 当VPN网关的network_type配置为private时,vgw_ip为VPN网关使用的接入私网IP。 
- 约束:36位UUID或点分十进制IPv4地址(如192.168.45.7)
 可以通过查询VPN网关查看VPN网关所使用的EIP的ID或接入私网IP。 style String 否 cgw_id String 是 - 功能说明:对端网关ID
- 约束:36位UUID,当VPN网关的flavor配置为GM时,对端网关必须已导入过对端网关证书。
 peer_subnets Array of String 否 tunnel_local_address String 否 tunnel_peer_address String 否 enable_nqa Boolean 否 - 功能说明:开启NQA检测
- 取值范围:true,false
- 默认值:false
- 约束:当style为static时填写,否则不填。
 psk String 否 policy_rules 否 - 功能说明:策略模式的策略规则组
- 约束:最多填写5个。style为policy时填写,为static或bgp时不填。
 ikepolicy 否 ike策略对象 ipsecpolicy 否 ipsec策略对象 ha_role String 否 - 功能说明:双活模式VPN网关下创建连接可不填,主备模式VPN网关下创建连接时,'master'表示主连接,'slave'表示备连接。
- 默认值:master
- 约束:双活模式VPN网关在主EIP或者主私网地址建立的连接必须填'master',在主EIP2或者主私网地址2建立的连接必须填'slave'。
 表4 PolicyRule 名称 类型 是否必选 描述 rule_index Integer 否 source String 否 - 功能说明:源地址网段。
- 约束:不能与其他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的生存周期,当该生存周期超时后IKE SA将自动更新。
- 取值范围:60-604800,单位:秒。
- 默认值:86400
 local_id_type String 否 local_id String 否 peer_id_type String 否 peer_id String 否 dpd 否 对等体存活检测对象 表6 Dpd 名称 类型 是否必选 描述 timeout Integer 否 - 功能说明:对等体存活检测报文重传间隔
- 取值范围:2-60,单位:秒。
- 默认值:15
 interval Integer 否 - 功能说明:对等体存活检测空闲时间
- 取值范围:10-3600,单位:秒。
- 默认值:30
 msg String 否 
- 请求样例
- 创建静态路由模式连接。
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****" } }
- 创建策略模式连接。
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" ] }] } }
- 创建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" } } }
 
- 创建静态路由模式连接。
响应消息
- 响应参数
返回状态码为 201: successful operation。 表8 响应Body参数列表 名称 类型 描述 vpn_connection vpn_connection对象 request_id String 请求ID 表9 ResponseVpnConnection 名称 类型 描述 id String - 功能说明:VPN连接ID
- 格式:36位UUID
 name String - 功能说明:VPN连接名称,不填时会自动生成。
- 取值范围:1-64个字符,支持数字、英文字母、中文(\u4e00 - \u9fa5)、_(下划线)、-(中划线)。
 vgw_id String - 功能说明:VPN网关ID
- 格式:36位UUID
 vgw_ip String - 功能说明: VPN网关EIP的ID或接入私网IP
- 格式:36位UUID或点分十进制IPv4地址(如192.168.45.7)
 style String cgw_id String - 功能说明:对端网关ID
- 格式:36位UUID
 peer_subnets Array of String 对端子网。当VPN网关的关联模式为ER并且style字段为BGP或POLICY时不返回。 tunnel_local_address String 路由模式下配置在VPN网关上的tunnel接口地址。仅当style为STATIC或BGP时有效。 tunnel_peer_address String 路由模式下配置在用户侧设备上的tunnel接口地址。仅当style为STATIC或BGP时有效。 enable_nqa Boolean - 功能说明:开启NQA检测。仅当style为STATIC时返回。
- 取值范围:true,false。
 policy_rules 策略模式的策略规则组。当style为POLICY时返回实际的策略规则组,当style为STATIC或BGP时不返回。 ikepolicy ike策略对象 ipsecpolicy ipsec策略对象 created_at String 创建时间 updated_at String 最后一次更新时间 enterprise_project_id String - 功能说明:企业项目ID
- 格式:36位UUID。与vgw_id所标识VPN网关的企业项目ID一致。
 connection_monitor_id String - 功能说明:VPN连接监控ID
- 格式:36位UUID
 ha_role String - 功能说明:主备模式VPN网关下的连接时,'master'表示主连接,'slave'表示备连接。双活模式下的连接ha_role都是'master'。
- 默认值:master
 表10 PolicyRule 名称 类型 描述 rule_index Integer - 功能说明:规则ID
- 取值范围:0-50
 source String 源地址网段 destination Array of String 目的地址网段。单个网段格式示例:192.168.52.0/24。每个PolicyRule最多返回50个。 表11 IkePolicy 名称 类型 描述 ike_version String - 功能说明:IKE版本号
- 取值范围:v1, v2
 phase1_negotiation_mode String authentication_algorithm String - 功能说明:认证算法
- 取值范围: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组,当VPN网关flavor为GM时不返回。
- 取值范围:group1,group2,group5,group14,group15,group16,group19,group20,group21。
 authentication_method String lifetime_seconds Integer - 功能说明:表示SA的生存周期,当该生存周期超时后IKE SA将自动更新。
- 取值范围:60-604800,单位:秒。
 local_id_type String - 功能说明:本端ID类型,当VPN网关flavor为GM时不返回。
- 取值范围:ip,fqdn。
 local_id String 本端ID。当local_id_type为ip时返回VPN连接所使用的网关IP;当local_id_type为fqdn时返回创建或更新VPN连接时指定的本端ID。 当VPN网关flavor为GM时不返回。 peer_id_type String - 功能说明:对端ID类型,当VPN网关flavor为GM时不返回。
- 取值范围:ip,fqdn。
 peer_id String 对端ID。当peer_id_type为ip时返回对端网关的IP;当peer_id_type为fqdn时返回创建或更新VPN连接时指定的对端ID。 当VPN网关flavor为GM时不返回。 dpd 对等体存活检测对象 表12 Dpd 名称 类型 描述 timeout Integer - 功能说明:对等体存活检测报文重传间隔
- 取值范围:2-60,单位:秒。
 interval Integer - 功能说明:对等体存活检测空闲时间
- 取值范围:10-3600,单位:秒。
 msg String 表13 IpsecPolicy 名称 类型 描述 authentication_algorithm String - 功能说明:认证算法
- 取值范围: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密钥组,当VPN网关flavor为GM时不返回。
- 取值范围:group1,group2,group5,group14,group15,group16,group19,group20,group21,disable。
 transform_protocol String lifetime_seconds Integer - 功能说明:表示配置IPSec连接建立的隧道以时间为基准的生存周期。
- 取值范围:30-604800,单位:秒
 encapsulation_mode String 
- 响应样例
- 创建静态路由模式连接的响应。
{ "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" }
- 创建策略模式连接的响应。
{ "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" }
- 创建bgp路由模式连接的响应。
{ "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" }
 
- 创建静态路由模式连接的响应。
状态码
请参见状态码
 
   
    
 
                