调用CreateVpnAttachment接口创建IPsec连接,用于绑定转发路由器实例。
使用说明
调用CreateVpnAttachment
接口创建的IPsec连接默认未绑定任何资源,后续您可以通过调用CreateTransitRouterVpnAttachment接口将IPsec连接绑定转发路由器实例。
前提条件
创建IPsec连接前,请确保您已经在IPsec连接所在的地域创建了用户网关。具体操作,请参见CreateCustomerGateway。
如果您需要为IPsec连接添加BGP配置,请确保用户网关已添加了自治系统号。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
请求参数
名称 | 类型 | 是否必选 | 示例值 | 描述 |
---|---|---|---|---|
Action | String | 是 | CreateVpnAttachment |
系统规定参数。取值:CreateVpnAttachment。 |
RegionId | String | 是 | ap-southeast-2 |
IPsec连接所属的地域ID。 您可以通过调用DescribeRegions接口获取地域ID。 |
Name | String | 否 | nametest |
IPsec连接的名称。 名称长度为1~100个字符,不能以 |
CustomerGatewayId | String | 是 | cgw-p0w2jemrcj5u61un8**** |
用户网关ID。 |
NetworkType | String | 否 | public |
IPsec连接的网络类型。取值:
|
LocalSubnet | String | 是 | 10.1.1.0/24,10.1.2.0/24 |
需要和本地数据中心互通的VPC侧的网段,用于第二阶段协商。 多个网段之间用半角逗号(,)分隔,例如:192.168.1.0/24,192.168.2.0/24。 关于IPsec连接路由模式的说明:
|
RemoteSubnet | String | 是 | 10.1.3.0/24,10.1.4.0/24 |
需要和VPC互通的本地数据中心侧的网段,用于第二阶段协商。 多个网段之间用半角逗号(,)分隔,例如: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,"LocalId":"47.XX.XX.1","RemoteId":"47.XX.XX.2"} |
第一阶段协商的配置信息:
|
IpsecConfig | String | 否 | {"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400} |
第二阶段协商的配置信息:
|
BgpConfig | String | 否 | {"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"} |
BGP的配置信息:
说明
|
HealthCheckConfig | String | 否 | {"enable":"true","dip":"192.168.1.1","sip":"10.1.1.1","interval":"3","retry":"3","Policy": "revoke_route"} |
健康检查配置信息:
|
AutoConfigRoute | Boolean | 否 | true |
是否自动配置路由。取值:
|
EnableDpd | Boolean | 否 | true |
是否开启DPD(对等体存活检测)功能。取值:
|
EnableNatTraversal | Boolean | 否 | true |
是否开启NAT穿越功能。取值:
|
RemoteCaCert | String | 否 | -----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
国密型VPN网关创建IPsec连接时,对端的CA证书。 |
ClientToken | String | 否 | 123e4567-e89b-12d3-a456-4266**** |
客户端Token,用于保证请求的幂等性。 从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken只支持ASCII字符。 说明 若您未指定,则系统自动使用API请求的RequestId作为ClientToken标识。每次API请求的RequestId可能不一样。
|
返回数据
名称 | 类型 | 示例值 | 描述 |
---|---|---|---|
RequestId | String | 88187252-0E26-3C4D-9D1D-32A04454EBBA |
请求ID。 |
VpnConnectionId | String | vco-p0wb09rama8qwwgfn**** |
IPsec连接ID。 |
Name | String | nametest |
IPsec连接的名称。 |
CreateTime | Long | 1658201810000 |
创建IPsec连接的时间戳。单位:毫秒。 时间戳的格式采用Unix时间戳,表示从格林威治时间1970年01月01日00时00分00秒至创建IPsec连接时的总时长。 |
Code | String | 200 |
当前任务返回的状态码。200表示任务成功。 |
Success | Boolean | true |
当前任务是否成功执行。
|
Message | String | successful |
当前任务返回的信息。 |
示例
请求示例
http(s)://[Endpoint]/?Action=CreateVpnAttachment
&RegionId=ap-southeast-2
&Name=nametest
&CustomerGatewayId=cgw-p0w2jemrcj5u61un8****
&NetworkType=public
&LocalSubnet=10.1.1.0/24,10.1.2.0/24
&RemoteSubnet=10.1.3.0/24,10.1.4.0/24
&EffectImmediately=false
&IkeConfig={"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={"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400}
&BgpConfig={"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"}
&HealthCheckConfig={"enable":"true","dip":"192.168.1.1","sip":"10.1.1.1","interval":"3","retry":"3","Policy": "revoke_route"}
&AutoConfigRoute=true
&EnableDpd=true
&EnableNatTraversal=true
&ClientToken=123e4567-e89b-12d3-a456-4266****
&公共请求参数
正常返回示例
XML
格式
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateVpnAttachmentResponse>
<RequestId>88187252-0E26-3C4D-9D1D-32A04454EBBA</RequestId>
<VpnConnectionId>vco-p0wb09rama8qwwgfn****</VpnConnectionId>
<Name>nametest</Name>
<CreateTime>1658201810000</CreateTime>
<Code>200</Code>
<Success>true</Success>
<Message>successful</Message>
</CreateVpnAttachmentResponse>
JSON
格式
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "88187252-0E26-3C4D-9D1D-32A04454EBBA",
"VpnConnectionId" : "vco-p0wb09rama8qwwgfn****",
"Name" : "nametest",
"CreateTime" : 1658201810000,
"Code" : "200",
"Success" : true,
"Message" : "successful"
}
错误码
HttpCode | 错误码 | 错误信息 | 描述 |
---|---|---|---|
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.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 | 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 | MissingParam.CustomerGatewayAsn | Asn of customer gateway is mandatory when BGP is enabled. | 开启BGP时,客户网关的自治系统号不可以为空。 |
400 | IllegalParam.LocalSubnet | The specified "LocalSubnet" (%s) is invalid. | 本端网段(%s)不合法。 |
400 | IllegalParam.RemoteSubnet | The specified "RemoteSubnet" (%s) is invalid. | 对端网段(%s)不合法。 |
400 | MissingParam.RemoteId | The remote ID is mandatory when creating national standard VPN connection. | 当创建国密VPN连接时,对端ID是必填参数。 |
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是否正确。 |
访问错误中心查看更多错误码。