调用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代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
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 |
否 |
第一阶段协商的认证算法。 如果 VPN 网关实例类型为普通型,则取值:md5、sha1、sha256、sha384、sha512。默认值:md5。 如果 VPN 网关实例类型为国密型,则取值为 sm3(默认值)。 |
md5 |
| IkeEncAlg |
string |
否 |
第一阶段协商的加密算法。 如果 VPN 网关实例类型为普通型,则取值为 aes、aes192、aes256、des 或 3des。默认值:aes。 如果 VPN 网关实例类型为国密型,则取值为 sm4(默认值)。 |
aes |
| IkeLifetime |
integer |
否 |
第一阶段协商出的 SA 的生存周期。单位:秒。 取值范围:0~86400。默认值:86400。 |
86400 |
| IkeMode |
string |
否 |
IKE 版本的协商模式。取值:main 或 aggressive。默认值:main。
如果 VPN 网关实例类型为国密型,则协商模式仅支持 main。 |
main |
| IkePfs |
string |
否 |
第一阶段协商使用的 Diffie-Hellman 密钥交换算法。默认值:group2。 |
group2 |
| IkeVersion |
string |
否 |
IKE 协议的版本。取值:ikev1 或 ikev2。默认值:ikev1。 相对于 IKEv1 版本,IKEv2 版本简化了 SA 的协商过程并且对于多网段的场景提供了更好的支持。 如果 VPN 网关实例类型为国密型,则 IKE 版本仅支持 ikev1。 |
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 |
否 |
第二阶段协商的认证算法。 如果 VPN 网关实例类型为普通型,则取值:md5、sha1、sha256、sha384、sha512。默认值:md5。 如果 VPN 网关实例类型为国密型,则取值为 sm3(默认值)。 |
md5 |
| IpsecEncAlg |
string |
否 |
第二阶段协商的加密算法。 如果 VPN 网关实例类型为普通型,则取值为 aes、aes192、aes256、des 或 3des。默认值:aes。 如果 VPN 网关实例类型为国密型,则取值为 sm4(默认值)。 |
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 | 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算法。 |
| 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. | 您没有权限操作指定资源,请申请权限后再操作。 |
| 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. |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。