You need to enable JavaScript to run this app.
导航

CreateVpnConnection

最近更新时间2024.04.18 17:23:56

首次发布时间2022.04.28 07:17:15

调用CreateVpnConnection创建一个新的IPsec连接。

调用说明

创建IPsec连接时支持“感兴趣流”和“目的路由”两种路由模式,默认为“感兴趣流”模式,如需“目的路由”,请求参数中LocalSubnetRemoteSubnet都传入0.0.0.0/0

调试

请求参数

名称类型是否必选
示例值
描述
ActionStringCreateVpnConnection要执行的操作,取值:CreateVpnConnection。
VersionString2020-04-01API版本信息。

VpnConnectionName

String

IPsecVPN-10wd

IPsec连接的名称。

  • 以中文、字母、数字开头,只能包含中文、字母、数字、点号(.)、下划线(_)和短划线(-)。
  • 长度限制为1 ~ 128个字符。
  • 不填默认为IPsec连接的ID。

Description

String

test

IPsec连接的描述信息。

  • 以中文、字母、数字开头,只能包含中文、字母、数字、点号(.)、空格( )、下划线(_)、中划线(-)、等号(=)、英文逗号(,)、中文逗号(,)、中文句号(。)。
  • 长度限制为0 ~ 255个字符。
  • 不填默认为空字符串。

AttachType

String

VpnGateway

IPsec连接关联的资源类型。

  • VpnGateway(默认):VPN网关
  • TransitRouter:中转路由器

VpnGatewayId

String

vgw-3tex2x1cwd4c6c0v****

IPsec连接关联的VPN网关的ID。您可调用DescribeVpnGateways查询VPN网关的ID信息。

说明

AttachType不传或传入值为VpnGateway,必须填写此参数。若AttachType传入值为TransitRouter,无需填写此参数。

CustomerGatewayIdStringcgw-3tehy13n2l4c6c0v****IPsec连接关联的用户网关的ID。若传入的用户网关的IP地址为0.0.0.0,则NegotiateInstantly仅可传入falseIkeConfigIkeConfig.Version仅可传入ikev1IkeConfig.Mode仅可传入aggressive。您可调用DescribeCustomerGateways查询用户网关的ID信息。

LocalSubnet.N

List of String

LocalSubnet.1=10.0.XX.0/24&LocalSubnet.2=10.0.XX.0/24

IPsec连接的本端网段。

  • 参数 - N表示本端网段的序号。
  • 最多支持传入5个网段。
  • 多个网段之间用&分隔。

RemoteSubnet.N

List of String

RemoteSubnet.1=172.16.XX.0/24&RemoteSubnet.2=172.16.XX.0/24

IPsec连接的对端网段。

  • 参数 - N表示对端网段的序号。
  • 最多支持传入5个网段。
  • 多个网段之间用&分隔。

IkeConfig

List of String

IkeConfig.Psk=Test123***&IkeConfig.Version=v1&IkeConfig.Mode=main&IkeConfig.EncAlg=aes&IkeConfig.AuthAlg=sha1&IkeConfig.DhGroup=group2&IkeConfig.Lifetime=86400

IPsec连接中IKE配置的信息。其中参数IkeConfig.Psk为必填参数,其他参数均为非必填参数。

说明

若传入的用户网关的IP地址为0.0.0.0IkeConfig.Version仅可传入ikev1IkeConfig.Mode仅可传入aggressive

  • IkeConfig.Psk:预共享密钥,用于第一阶段VPN网关与用户网关之间的身份认证。长度不超过100个字符,只可输入大小写字母、特殊符号~ ` | ! @ # $ % ^ ( ) - _ + = [ ] { } \ , . / : ;以及数字。
  • IkeConfig.Version:IKE密钥交换协议的版本。取值如下
    • ikev1
    • ikev2(默认)
  • IkeConfig.Mode:第一阶段的协商模式。仅IkeConfig.Versionikev1时需传入本参数。取值如下:
    • main(默认)
    • aggressive
  • IkeConfig.EncAlg:第一阶段协商的加密算法。取值如下:
    • aes(默认)
    • aes192
    • aes256
    • des
    • 3des
    • sm4
  • IkeConfig.AuthAlg:第一阶段的认证算法。取值如下:
    • sha1(默认)
    • md5
    • sha256
    • sha384
    • sha512
    • sm3
  • IkeConfig.DhGroup:第一阶段协商使用的DH(Diffie-Hellman)密钥交换算法。取值如下:
    • group1
    • group2(默认)
    • group5
    • group14
  • IkeConfig.Lifetime:第一阶段协商的SA的生存时间,超过生存时间后,将重新发起协商。
    • 取值范围:900~86400,单位:秒。
    • 默认:86400。
  • IkeConfig.LocalId:VPN网关的标识,用于第一阶段的协商,支持IP格式和FQDN( Fully Qualified Domain Name)完全合格域名/全称域名格式。
    • 不传默认为当前所选VPN网关的出口IP地址。
    • 若您手动设置为FQDN格式,协商模式推荐设置为“aggressive”。
    • 长度不超过100个字符,只可输入大小写字母、特殊符号~ ` | ! @ # $ % ^ ( ) - _ + = [ ] { } \ , . / : ;以及数字。
  • IkeConfig.RemoteId:用户网关的标识,用于第一阶段的协商,支持IP格式和FQDN( Fully Qualified Domain Name)完全合格域名/全称域名格式。
    • 不传默认为当前所选用户网关的公网IP地址。
    • 若您手动设置为FQDN格式,协商模式推荐设置为“aggressive”。
    • 长度不超过100个字符,只可输入大小写字母、特殊符号~ ` | ! @ # $ % ^ ( ) - _ + = [ ] { } \ , . / : ;以及数字。

IpsecConfig

List of String

IpsecConfig.EncAlg=aes&IpsecConfig. AuthAlg=sha1&IpsecConfig. DhGroup=group2&IpsecConfig.Lifetime=86400

IPsec连接中的IPsec配置的信息,包含如下参数:

  • IpsecConfig.EncAlg:第二阶段协商的加密算法。取值如下:
    • aes(默认)
    • aes192
    • aes256
    • des
    • 3des
    • sm4
  • IpsecConfig.AuthAlg:第二阶段协商的认证算法。取值如下:
    • sha1(默认)
    • md5
    • sha256
    • sha384
    • sha512
    • sm3
  • IpsecConfig.DhGroup:第二阶段使用的DH(Diffie-Hellman)密钥交换算法。取值如下:
    • group1
    • group2(默认)
    • group5
    • group14
    • disable(不配置DH算法)

说明

若选择group1、group2、group5、group14,将默认开启PFS(Perfect Forward Secrecy)完美前向保密功能,对应的客户端也需要开启PFS功能。若客户端不支持PFS功能,此处需配置为“disable”。

  • IpsecConfig.Lifetime:第二阶段协商的SA的生存时间,超过生存时间后,将重新发起协商。
    • 取值范围:900~86400
    • 单位:秒。
    • 默认:86400。

NatTraversal

Boolean

false

是否开启NAT穿越功能。

  • true:开启。NAT穿越(NAT Traversal)功能开启后,IKE协商时不会对UDP端口号进行验证,并且能够发现VPN连接隧道中NAT网关设备。
  • false(默认):不开启。

DpdAction

String

clear

DPD功能的状态。

  • none:关闭DPD功能。
  • clear(默认):开启DPD功能,DPD超时后清除IKE SA。
  • hold:开启DPD功能,DPD超时后保持当前状态,等待新的流量进入后重新建立连接。
  • restart:开启DPD功能,DPD超时后立即重连。

ClientToken

String

123e4567-e89b-12d3-a456-42665544****

客户端Token,用于保证请求幂等性。

  • 由客户端自动生成一个参数值,确保不同请求间该参数值唯一,避免当调用API超时或服务器内部错误时,客户端多次重试导致重复性操作。
  • 仅支持ASCII字符,且不能超过64个字符。
  • 若不传入ClientToken,则此次API调用不进行幂等校验。
ProjectNameStringProject_1IPsec连接所属的项目。不填默认为default,即创建的资源属于default项目。您可调用ListProjects查询当前账号下项目的信息。

NegotiateInstantly

Boolean

true

是否立即发起协商模式。

说明

若传入的用户网关的IP地址为0.0.0.0,此处仅可传入false

  • true:IPsec连接配置完成后系统立即主动发起协商。
  • false(默认):IPsec连接配置完成后系统不主动发起协商,当有流量通过时被动发起协商。

LogEnabled

Boolean

false

是否启用连接日志。启用连接日之后,您可查看、下载IPsec连接日志,并通过日志信息自行排查IPsec连接的故障问题。

  • true:启用。
  • false:不启用。

说明

启用连接日志前请先确认当前账号已开通日志服务和对象存储服务,并已为VPN连接服务授权跨服务访问日志服务。

返回数据

名称类型
示例值
描述
RequestIdString2022032111142501022524314704AF****请求ID。
VpnConnectionIdStringvgc-3tex2x1cwd4c6c0v****新创建IPsec连接的ID。
OrderIdStringOrder7078570823273845036新创建TR类型IPsec连接的订单ID。

请求示例

GET /?Action=CreateVpnConnection&Version=2020-04-01&VpnConnectionName=test&Description=test&CustomerGatewayId=cgw-274mm8eodvu9s7fap8skw****&VpnGatewayId=vgw-2752abxsju1vk7fap8sgk****&LocalSubnet=192.168.XX.XX/16&RemoteSubnet=172.16.XX.XX/16&IKEConfig.Psk=12345&IKEConfig.Version=ikev2&IKEConfig.EncAlg=aes&IPSecConfig.DhGroup=disable HTTP/1.1
Host: open.volcengineapi.com
ServiceName: vpn
Region: cn-beijing

返回示例

{
    "ResponseMetadata":{
        "RequestId":"2022032111142501022524314704AF****",
        "Action":"CreateVpnConnection",
        "Version":"2020-04-01",
        "Service":"vpn",
        "Region":"cn-beijing"
    },
    "Result":{
        "RequestId":"2022032111142501022524314704AF****",
        "VpnConnectionId":"vgc-2bzvqi8kerd342dx0eg2f****"
    }
}

错误码

此处仅展示当前API的错误码,更多错误码请参见公共错误码

HttpCode错误码错误信息描述
400InvalidName.MalformedThe specified name is malformed.Ensure the maximum length of name is 128.指定的名称格式不合法。名称长度不能超过128个字符。
400InvalidName.MalformedThe specified name is malformed.指定的名称格式不合法。请修复名称格式后重试。
400InvalidDescription.MalformedThe specified description is malformed.Ensure the maximum length of description is 255.指定的描述格式不合法。描述长度不能超过255个字符。
400InvalidDescription.MalformedThe specified description is malformed.指定的描述格式不合法。请修复描述格式后重试。
400InvalidVpnConnectionLocalSubnet.MalformedThe specified LocalSubnet is malformed.指定的本端网段不合法。
400InvalidVpnConnectionRemoteSubnet.MalformedThe specified RemoteSubnet is malformed.指定的对端网段不合法。
400InvalidVpnConnectionIKEPsk.MalformedThe specified IKE Psk is malformed. Ensure the maximum length of IKE Psk is 100.指定的IKE Psk格式不合法。IKE Psk长度不能超过100个字符。
400InvalidVpnConnectionIKEPsk.MalformedThe specified IKE Psk is malformed.指定的IKE Psk不合法。
400InvalidVpnConnectionIKEAuthElg.MalformedThe specified IKE AuthAlg is malformed.指定的IKE AuthAlg不合法。
400InvalidVpnConnectionIKEEncElg.MalformedThe specified IKE EncAlg is malformed.指定的IKE EncAlg不合法。
400InvalidVpnConnectionIKEDhGroup.MalformedThe specified IKE DhGroup is malformed.指定的IKE DhGroup不合法。
400InvalidVpnConnectionIKEMode.Malformed"The specified IKE Mode is malformed.指定的IKE Mode不合法。
400InvalidVpnConnectionIKEVersion.MalformedThe specified IKE Version is malformed.指定的IKE Version不合法。
400InvalidVpnConnectionIKELocalID.MalformedThe specified IKE LocalId is malformed. Ensure the maximum length of IKE LocalId is 100.指定的IKE LocalId格式不合法。IKE LocalId长度不能超过100个字符。
400InvalidVpnConnectionIKELocalID.MalformedThe specified IKE LocalId is malformed.指定的IKE LocalId不合法。
400InvalidVpnConnectionIKERemoteID.MalformedThe specified IKE RemoteId is malformed. Ensure the maximum length of IKE RemoteId is 100.指定的IKE RemoteId格式不合法。IKE RemoteId长度不能超过100个字符。
400InvalidVpnConnectionIKERemoteID.MalformedThe specified IKE RemoteId is malformed.指定的IKE RemoteId不合法。
400InvalidVpnConnectionIKELifetime.MalformedThe specified IKE Lifetime is malformed.指定的IKE Lifetime 不合法。
400InvalidVpnConnectionIPSecAuthElg.MalformedThe specified IPSec AuthAlg is malformed.指定的IPSec AuthAlg不合法。
400InvalidVpnConnectionIPSecEncElg.MalformedThe specified IPSec EncAlg is malformed.指定的IPSec EncAlg不合法。
400InvalidVpnConnectionIPSecDhGroup.MalformedThe specified IPSec DhGroup is malformed.指定的IPSec DhGroup不合法。
400InvalidVpnConnectionIPSecLifetime.MalformedThe specified IPSec Lifetime is malformed.指定的IPSec Lifetime不合法。
400QuotaExceeded.VpnConEachVPNGatewayYou've reached the limit on the number of IPSec connections per VPN gateway that you can create.已达到每个VPN网关可创建的IPSec连接的数量上限。
400QuotaExceeded.LocCIDREachVpnConYou've reached the limit on the number of local subnet per IPSec connection that you can create.已达到每个IPSec连接可创建的本端网段数量上限。
400QuotaExceeded.RemCIDREachVpnConYou've reached the limit on the number of remote subnet per IPSec connection that you can create.已达到每个IPSec连接可创建的对端网段数量上限。
400InvalidVpnConnectionDpdAction.MalformedThe specified DpdAction is malformed.指定的DpdAction不合法。
400IdempotentParameterMismatchArguments on this idempotent request are inconsistent with arguments used in previous request(s).此幂等请求的参数与前一个请求中使用的参数不一致。
400InvalidParameter.ClientTokenMalformedThe specified parameter ClientToken is malformed.指定的参数ClientToken格式不合法,长度不能超过64个ASCII字符。
400InvalidVpnGateway.FirmwareNotSupportedThe specified features aren't supported by the VPN gateway, please upgrade your VPN gateway.VPN网关不支持所选择的功能,请升级您的VPN网关。
400InsufficientResource.VpnConnectionThe specified region does not have enough resources for IPSec connection.IPSec连接可用资源不足。
400InvalidVpnConnectionAttachType.MalformedThe specified AttachType is malformed.指定的绑定资源类型不合法。
400QuotaExceeded.VpnConAttachTypeTransitRouterYou've reached the limit on the number of Transit Router attach type IPSec connections that you can create.已达到绑定类型为中转路由器的IPSec连接的数量上限。
400OrderErrorFailed to create an order in one step.创建订单并支付失败。
400UnsupportedOperationThe request on the specified instance is denied due to the account in arrears status.因账户处于欠费状态,对于该实例的操作请求被拒绝。
400UnsupportedOperationThe request on the specified instance is denied due to the account balance and available vouchers are less than 100 yuan in total.因账户余额及可用代金券共不足100元,对于该实例的操作请求被拒绝。
400InvalidCustomerGateway.InvalidStatusThe specified customer gateway is not in the correct status for the request.指定的用户网关所处的状态无法响应该请求。
400InvalidVpnGateway.InvalidStatusThe specified VPN gateway is not in the correct status for the request.指定的VPN网关所处的状态无法响应该请求。
400InvalidVpnConnectionRemoteId.ConflictThe specified IKE RemoteId conflicts with that of another IPSec connection in the specified VPN gateway.指定的IKE RemoteId与本网关下其他IPSec连接存在冲突。
400InvalidVpnConnection.LogNotSupportedIPSec connection log is not supported in this region.当前地域不支持IPSec连接日志功能。
400LimitExceeded.TLSProjectYou've reached the limit on the number of TLS project per region that you can create.已达到当前账户在单一地域下可创建的TLS日志项目数量上限。
400InvalidVpnGateway.IpsecNotEnabledIPSec of the specified VPN gateway is not enabled.当前VPN网关未开启IPSec功能。
403InvalidVpn.ServiceRoleNotAuthorizedThe service role for VPN has not been authorized.当前账号尚未授权VPN的服务角色。
403InvalidVpnConnection.TlsAccessDeniedTLS service access denied.当前账号未开通日志服务。
403InvalidVpnConnection.TlsNotSupportTLS is not supported in this region.当前账号在此地域不支持TLS服务。
404InvalidProject.NotFoundThe specified Project does not exist.指定的项目不存在。
404InvalidVpnGateway.NotFoundThe specified VPN gateway does not exist.指定的VPN网关不存在。
404InvalidCustomerGateway.NotFoundThe specified customer gateway does not exist.指定的用户网关不存在。
412InvalidVpnGateway.ExpiredThe specified VPN gateway has expired.指定的VPN网关已过期。
412IdempotentProcessingThe request uses the same client token as a previous one that is still in process.幂等请求处理中。