调用CreateVpnAttachment接口创建IPsec连接,用于绑定转发路由器实例。
接口说明
-
绑定转发路由器场景下,IPsec 连接已升级为双隧道模式。创建 IPsec-VPN 连接时,除必填参数外,仅支持配置双隧道模式相关请求参数:ClientToken、Name、NetworkType、EffectImmediately、Tags 数组、ResourceGroupId、TunnelOptionsSpecification 数组、EnableTunnelsBgp。更多信息,请参见绑定转发路由器场景双隧道 IPsec-VPN 连接说明。
-
调用
CreateVpnAttachment接口创建的 IPsec 连接默认未绑定任何资源,后续您可以通过调用 CreateTransitRouterVpnAttachment 接口将 IPsec 连接绑定转发路由器实例。绑定转发路由器实例后,系统会为 IPsec 连接分配网关 IP 地址,您可以调用 DescribeVpnConnection 接口查看。
前提条件
创建 IPsec 连接前,请确保您已经在 IPsec 连接所在的地域创建了用户网关。具体操作,请参见 CreateCustomerGateway 。
如果您需要为 IPsec 连接添加 BGP 配置,请确保用户网关已添加了自治系统号。
调试
您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。
调试
授权信息
|
操作 |
访问级别 |
资源类型 |
条件关键字 |
关联操作 |
|
vpc:CreateVpnAttachment |
create |
*全部资源
|
无 | 无 |
请求参数
|
名称 |
类型 |
必填 |
描述 |
示例值 |
| RegionId |
string |
是 |
IPsec 连接所属的地域 ID。 您可以通过调用 DescribeRegions 接口获取地域 ID。 |
cn-hangzhou |
| Name |
string |
否 |
IPsec 连接的名称。 名称长度为 1~100 个字符,不能以 |
nametest |
| CustomerGatewayId |
string |
否 |
用户网关 ID。 说明
仅创建单隧道模式 IPsec-VPN 连接时需配置本参数,且本参数必填。 |
cgw-p0w2jemrcj5u61un8**** |
| NetworkType |
string |
否 |
IPsec 连接的网络类型。取值:
|
public |
| LocalSubnet |
string |
是 |
需要和本地数据中心互通的 VPC 侧的网段,用于第二阶段协商。 多个网段之间用半角逗号(,)分隔,例如:192.168.1.0/24,192.168.2.0/24。 关于 IPsec 连接路由模式的说明:
|
10.1.1.0/24,10.1.2.0/24 |
| RemoteSubnet |
string |
是 |
需要和 VPC 互通的本地数据中心侧的网段,用于第二阶段协商。 多个网段之间用半角逗号(,)分隔,例如:192.168.3.0/24,192.168.4.0/24。 关于 IPsec 连接路由模式的说明:
|
10.1.3.0/24,10.1.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} |
| BgpConfig |
string |
否 |
创建单隧道模式的 IPsec-VPN 连接时支持配置该参数。 BGP 的配置信息:
说明
|
{"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"} |
| HealthCheckConfig |
string |
否 |
创建单隧道模式的 IPsec-VPN 连接时支持配置该参数。 健康检查配置信息:
|
{"enable":"true","dip":"192.168.1.1","sip":"10.1.1.1","interval":"3","retry":"3","Policy": "revoke_route"} |
| AutoConfigRoute |
boolean |
否 |
是否自动配置路由。取值:
|
true |
| EnableDpd |
boolean |
否 |
创建单隧道模式的 IPsec-VPN 连接时支持配置该参数。 是否开启 DPD(对等体存活检测)功能。取值:
|
true |
| EnableNatTraversal |
boolean |
否 |
创建单隧道模式的 IPsec-VPN 连接时支持配置该参数。 是否开启 NAT 穿越功能。取值:
|
true |
| RemoteCaCert |
string |
否 |
对端的 CA 证书。 说明
当前参数暂不生效。 |
-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
| ClientToken |
string |
否 |
客户端 Token,用于保证请求的幂等性。 从您的客户端生成一个参数值,确保不同请求间该参数值唯一。ClientToken 只支持 ASCII 字符。 说明
若您未指定,则系统自动使用 API 请求的 RequestId 作为 ClientToken 标识。每次 API 请求的 RequestId 不一样。 |
123e4567-e89b-12d3-a456-4266**** |
| Tags |
array<object> |
否 |
IPsec 连接待添加的标签列表。 一次最多支持为 IPsec 连接添加 20 个标签。 |
|
|
object |
否 |
标签信息。 |
||
| Key |
string |
否 |
标签键。一旦输入该值,则不允许为空字符串。 最多支持 64 个字符,不能以 一次最多支持输入 20 个标签键。 |
TagKey |
| Value |
string |
否 |
标签值。 标签值最多支持 128 个字符,可以为空字符串,不能以 一个标签键对应一个标签值。一次最多支持输入 20 个标签值。 |
TagValue |
| ResourceGroupId |
string |
否 |
IPsec 连接所属的资源组 ID。
|
rg-acfmzs372yg**** |
| TunnelOptionsSpecification |
array<object> |
否 |
配置隧道。
|
|
|
array<object> |
否 |
配置隧道信息。 |
||
| CustomerGatewayId |
string |
否 |
隧道关联的用户网关 ID。 说明
创建双隧道模式 IPsec-VPN 连接时本参数必填。 |
cgw-p0w2jemrcj5u61un8**** |
| EnableDpd |
boolean |
否 |
是否为隧道开启 DPD(对等体存活检测)功能。取值:
|
true |
| EnableNatTraversal |
boolean |
否 |
是否为隧道开启 NAT 穿越功能。取值:
|
true |
| TunnelIndex |
integer |
否 |
隧道的创建顺序。
|
1 |
| TunnelBgpConfig |
object |
否 |
为隧道添加 BGP 配置。 说明
当您为 IPsec 连接开启 BGP 功能后(即指定 EnableTunnelsBgp 参数的值为 true)需要配置该参数。 |
|
| LocalAsn |
integer |
否 |
隧道本端(阿里云侧)的自治系统号。自治系统号取值范围:1~4294967295。默认值:45104。 说明
建议您使用自治系统号的私有号码与阿里云建立 BGP 连接。自治系统号的私有号码范围请自行查阅文档。 |
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。 说明
一个 IPsec 连接下两个隧道的隧道网段不能相同。 |
169.254.10.0/30 |
| TunnelIkeConfig |
object |
否 |
第一阶段协商的配置信息。 |
|
| IkeAuthAlg |
string |
否 |
第一阶段协商的认证算法。取值:md5、sha1、sha256、sha384、sha512。默认值:sha1。 |
sha1 |
| IkeEncAlg |
string |
否 |
第一阶段协商的加密算法。取值:aes、aes192、aes256、des 或 3des。默认值:aes。 |
aes |
| IkeLifetime |
integer |
否 |
第一阶段协商出的 SA 的生存周期。单位:秒。 取值范围:0~86400。默认值:86400。 |
86400 |
| IkeMode |
string |
否 |
IKE 版本的协商模式。取值:main 或 aggressive。默认值:main。
|
main |
| IkePfs |
string |
否 |
第一阶段协商使用的 Diffie-Hellman 密钥交换算法。默认值:group2。 |
group2 |
| IkeVersion |
string |
否 |
IKE 协议的版本。取值:ikev1 或 ikev2。默认值:ikev2。 相对于 IKEv1 版本,IKEv2 版本简化了 SA 的协商过程并且对于多网段的场景提供了更好的支持。 |
ikev2 |
| LocalId |
string |
否 |
隧道本端(阿里云侧)的标识,用于第一阶段的协商。长度限制为 100 个字符,不能包含空格。默认值为隧道的 IP 地址。 LocalId 支持 FQDN 格式,如果您使用 FQDN 格式,协商模式建议选择为 aggressive(野蛮模式)。 |
47.XX.XX.1 |
| Psk |
string |
否 |
预共享密钥,用于隧道与隧道对端之间的身份认证。
说明
隧道及隧道对端的预共享密钥需一致,否则系统无法正常建立隧道。 |
123456**** |
| RemoteId |
string |
否 |
隧道对端的标识,用于第一阶段的协商。长度限制为 100 个字符,不能包含空格。默认值为隧道关联的用户网关的 IP 地址。 RemoteId 支持 FQDN 格式,如果您使用 FQDN 格式,协商模式建议选择为 aggressive(野蛮模式)。 |
47.XX.XX.2 |
| TunnelIpsecConfig |
object |
否 |
第二阶段协商的配置信息。 |
|
| IpsecAuthAlg |
string |
否 |
第二阶段协商的认证算法。 取值:md5、sha1、sha256、sha384、sha512。默认值:sha1。 |
sha1 |
| IpsecEncAlg |
string |
否 |
第二阶段协商的加密算法。取值:aes、aes192、aes256、des 或 3des。默认值:aes。 |
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(默认值)。 说明
在添加 BGP 配置前,建议您先了解 BGP 动态路由功能的工作机制和使用限制。更多信息,请参见配置 BGP 动态路由。 |
false |
| DryRun |
boolean |
否 |
是否只预检此次请求。取值:
|
false |
| TunnelBandwidth |
string |
否 |
用于说明 VPN 单条隧道的带宽规格,取值: Standard(默认值):标准型,默认带宽 1Gbps Large(大型):大型,默认带宽 3Gbps |
Standard |
返回参数
|
名称 |
类型 |
描述 |
示例值 |
|
object |
返回结果。 |
||
| RequestId |
string |
请求 ID。 |
88187252-0E26-3C4D-9D1D-32A04454EBBA |
| VpnConnectionId |
string |
IPsec 连接 ID。 |
vco-p0wb09rama8qwwgfn**** |
| Name |
string |
IPsec 连接的名称。 |
nametest |
| CreateTime |
integer |
创建 IPsec 连接的时间戳。单位:毫秒。 时间戳的格式采用 Unix 时间戳,表示从格林威治时间 1970 年 01 月 01 日 00 时 00 分 00 秒至创建 IPsec 连接时的总时长。 |
1658201810000 |
| Code |
string |
当前任务返回的状态码。200 表示任务成功。 |
200 |
| Message |
string |
当前任务返回的信息。 |
successful |
| Success |
boolean |
当前任务是否成功执行。
|
true |
示例
正常返回示例
JSON格式
{
"RequestId": "88187252-0E26-3C4D-9D1D-32A04454EBBA",
"VpnConnectionId": "vco-p0wb09rama8qwwgfn****",
"Name": "nametest",
"CreateTime": 1658201810000,
"Code": "200",
"Message": "successful",
"Success": true
}
错误码
|
HTTP status code |
错误码 |
错误信息 |
描述 |
|---|---|---|---|
| 400 | Resource.QuotaFull | The quota of resource is full | |
| 400 | InvalidVpnConnection.AlreadyExists | Vpn connection already exists. | |
| 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 | MissingParameter.TunnelCidr | The parameter TunnelCidr is mandatory when BGP is enabled. | 开启BGP时,隧道CIDR参数是必填项 |
| 400 | OperationUnsupported.EnableBgp | Current region does not support enable BGP. | 当前地域不支持开启BGP。 |
| 400 | MissingParam.CustomerGatewayAsn | Asn of customer gateway is mandatory when BGP is enabled. | 开启BGP时,客户网关的自治系统号不可以为空。 |
| 400 | IllegalParam.LocalAsn | The specified LocalAsn is invalid. | 本端自治系统号不合法。 |
| 400 | InvalidParameter.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 connecton 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 | OperationFailed.NoAvailableAmount | The available amount of your account is less than 0, please recharge before attempting to purchase. | 您的账户可用额度小于0,请先充值后再尝试购买。 |
| 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 | 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 | 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 | DryRunOperation | Request validation has been passed with DryRun flag set. | DryRun校验通过。 |
| 400 | VpnConnection.InvalidCreateTunnelOptions | The master and slave tunnels must be created at the same time. | 主隧道和备隧道必须同时创建。 |
| 400 | OperationUnsupported.LargeTunnelBandwidth | Large tunnelBandwidth VpnAttachment is unsupported. | 不支持创建大带宽的VpnAttachment。 |
| 400 | IllegalParam.TunnelBandwidth | TunnelBandwidth is illegal. | TunnelBandwidth参数非法。 |
| 400 | EncAlgInvalid.DesIncompatible | Des/3des in IkeEncAlg and IpsecEncAlg does not support multi algorithm. | Ike加密算法以及IPsec加密算法中,des/3des不支持多算法兼容。 |
| 400 | OperationFailed.OpenCdtServiceFirst | The operation is failed because of %s. | 您当前指定的计费类型需开通CDT计费,请开通CDT后重试 |
| 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。 |
| 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是否正确。 |
访问错误中心查看更多错误码。
变更历史
更多信息,参考变更详情。