调用CreateVpnConnection接口创建IPsec连接。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | CreateVpnConnection |
系统规定参数。取值:CreateVpnConnection。 |
RegionId | String | 是 | cn-shanghai |
IPsec连接所在的地域ID。您可以通过调用DescribeRegions接口获取地域ID。 |
ClientToken | String | 否 | 02fb3da4-130e-11e9-8e44-001**** |
客户端Token,用于保证请求的幂等性。 从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符。 说明 若您未指定,则系统自动使用API请求的RequestId作为ClientToken标识。每次API请求的RequestId可能不一样。
|
CustomerGatewayId | String | 是 | cgw-p0w2jemrcj5u61un8**** |
用户网关的ID。 |
VpnGatewayId | String | 是 | vpn-bp1q8bgx4xnkm**** |
VPN网关实例ID。 |
Name | String | 否 | IPsec |
IPsec连接的名称。 长度为2~128个字符,必须以字母或中文开头,可包含数字、半角句号(.)、下划线(_)和短划线(-),但不能以 |
LocalSubnet | String | 是 | 10.10.1.0/24,10.10.2.0/24 |
需要和本地数据中心互连的VPC侧的网段,用于第二阶段协商。 多个网段之间用半角逗号(,)分隔,例如:192.168.1.0/24,192.168.2.0/24。 关于IPsec连接路由模式的说明:
|
RemoteSubnet | String | 是 | 10.10.3.0/24,10.10.4.0/24 |
本地数据中心侧的网段,用于第二阶段协商。 多个网段之间用半角逗号(,)分隔,例如:192.168.3.0/24,192.168.4.0/24。 关于IPsec连接路由模式的说明:
|
EffectImmediately | Boolean | 否 | false |
选择IPsec连接的配置是否立即生效。取值:
|
IkeConfig | String | 否 | {"Psk":"1234****","IkeVersion":"ikev1","IkeMode":"main","IkeEncAlg":"aes","IkeAuthAlg":"sha1","IkePfs":"group2","IkeLifetime":86400,"LocalIdIPsec":"47.XX.XX.1","RemoteId":"47.XX.XX.2"} |
第一阶段协商的配置信息:
|
IpsecConfig | String | 否 | {"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400} |
第二阶段协商的配置信息:
|
HealthCheckConfig | String | 否 | {"enable":"true","dip":"192.168.10.1","sip":"10.10.1.1","interval":"3","retry":"3"} |
健康检查配置信息:
|
AutoConfigRoute | Boolean | 否 | true |
是否自动配置路由。取值:
|
EnableDpd | Boolean | 否 | true |
是否开启DPD(对等体存活检测)功能。取值:
|
EnableNatTraversal | Boolean | 否 | true |
是否开启NAT穿越功能。取值:
|
BgpConfig | String | 否 | {"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"} |
BGP的配置信息:
说明
|
RemoteCaCertificate | String | 否 | c20ycDI1NnYxIENBIChURVNUIFN**** |
国密型VPN网关创建IPsec连接时,对端的CA证书。
|
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | 082AD562-B8DB-4BB2-861F-DA1FCA01FD76 |
请求ID。 |
VpnConnectionId | String | vco-bp15oes1py4i6**** |
IPsec连接的ID。 |
Name | String | test |
IPsec连接的名称。 |
CreateTime | Long | 1544666102000 |
IPsec连接的创建时间戳。单位:毫秒。 时间戳的格式采用Unix时间戳,表示从格林威治时间1970年01月01日00时00分00秒至创建IPsec连接时的总时长。 |
示例
请求示例
http(s)://[Endpoint]/?Action=CreateVpnConnection
&RegionId=cn-shanghai
&ClientToken=02fb3da4-130e-11e9-8e44-001****
&CustomerGatewayId=cgw-p0w2jemrcj5u61un8****
&VpnGatewayId=vpn-bp1q8bgx4xnkm****
&Name=IPsec
&LocalSubnet=10.10.1.0/24,10.10.2.0/24
&RemoteSubnet=10.10.3.0/24,10.10.4.0/24
&EffectImmediately=false
&IkeConfig={"Psk":"1234****","IkeVersion":"ikev1","IkeMode":"main","IkeEncAlg":"aes","IkeAuthAlg":"sha1","IkePfs":"group2","IkeLifetime":86400,"LocalIdIPsec":"47.XX.XX.1","RemoteId":"47.XX.XX.2"}
&IpsecConfig={"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400}
&HealthCheckConfig={"enable":"true","dip":"192.168.10.1","sip":"10.10.1.1","interval":"3","retry":"3"}
&AutoConfigRoute=true
&EnableDpd=true
&EnableNatTraversal=true
&BgpConfig={"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"}
&公共请求参数
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateVpnConnectionResponse>
<RequestId>082AD562-B8DB-4BB2-861F-DA1FCA01FD76</RequestId>
<VpnConnectionId>vco-bp15oes1py4i6****</VpnConnectionId>
<Name>test</Name>
<CreateTime>1544666102000</CreateTime>
</CreateVpnConnectionResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "082AD562-B8DB-4BB2-861F-DA1FCA01FD76",
"VpnConnectionId" : "vco-bp15oes1py4i6****",
"Name" : "test",
"CreateTime" : 1544666102000
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
400 | Resource.QuotaFull | The quota of resource is full | 资源配额已达上限。 |
400 | InvalidVpnConnection.AlreadyExists | Vpn connection already exists. | VPN 连接已经存在,不用再次添加。 |
400 | VpnGateway.Configuring | The specified service is configuring. | 服务正在配置中,请您稍后再试。 |
400 | VpnGateway.FinancialLocked | The specified service is financial locked. | 该服务已欠费,请您先充值再操作。 |
400 | VpnRouteEntry.Conflict | The specified route entry has conflict. | 路由条目存在冲突。 |
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 | IllegalParam.LocalSubnet | The specified "LocalSubnet" (%s) is invalid. | 本端网段(%s)不合法。 |
400 | IllegalParam.RemoteSubnet | The specified "RemoteSubnet" (%s) is invalid. | 对端网段(%s)不合法。 |
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加入到的CEN开启了FULL模式时,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. | 指定的 VPN 网关不存在,请您检查 VPN 网关是否正确。 |
访问错误中心查看更多错误码。