Creates an IPsec-VPN connection.
Operation description
-
If the VPN gateway instance supports creating IPsec-VPN connections in dual-tunnel mode, you can configure the following request parameters in addition to the required parameters when you call the CreateVpnConnection operation:
ClientToken, Name, EffectImmediately, AutoConfigRoute, Tags array, TunnelOptionsSpecification array, and EnableTunnelsBgp.
For information about the regions and zones that support creating IPsec-VPN connections in dual-tunnel mode, refer to Upgrade IPsec-VPN connections to the dual-tunnel mode.
-
If the VPN gateway instance supports only creating IPsec-VPN connections in single-tunnel mode, you can configure the following request parameters in addition to the required parameters when you call the CreateVpnConnection operation:
ClientToken, CustomerGatewayId, Name, EffectImmediately, IkeConfig, IpsecConfig, HealthCheckConfig, AutoConfigRoute, EnableDpd, EnableNatTraversal, BgpConfig, RemoteCaCertificate, and Tags array.
-
The CreateVpnConnection operation is asynchronous. The system returns an instance ID, but the IPsec-VPN connection is not yet created and the creation task is still running in the background. You can call the DescribeVpnGateway operation to query the status of the VPN gateway instance and determine the creation status of the IPsec-VPN connection:
If the VPN gateway instance is in the updating state, the IPsec-VPN connection is being created.
If the VPN gateway instance is in the active state, the IPsec-VPN connection is created.
-
The CreateVpnConnection operation does not support creating multiple IPsec-VPN connections concurrently under the same VPN gateway.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
vpc:CreateVpnConnection |
create |
*CustomerGateway
*VpnConnection
*VpnGateway
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
Yes |
The region ID of the IPsec-VPN connection. You can call the DescribeRegions operation to query region IDs. |
cn-shanghai |
| ClientToken |
string |
No |
The client token that is used to ensure the idempotence of the request. You can use the client to generate the value, but you must ensure that it is unique among different requests. The client token can contain only ASCII characters. Note
If you do not specify this parameter, the system automatically uses the RequestId of the API request as the ClientToken. The RequestId of each API request is unique. |
02fb3da4-130e-11e9-8e44-001**** |
| CustomerGatewayId |
string |
No |
This parameter is required when you create an IPsec-VPN connection in single-tunnel mode. The ID of the customer gateway. |
cgw-p0w2jemrcj5u61un8**** |
| VpnGatewayId |
string |
Yes |
The instance ID of the VPN gateway. |
vpn-bp1q8bgx4xnkm**** |
| Name |
string |
No |
The name of the IPsec-VPN connection. The name must be 1 to 100 characters in length, and cannot start with http:// or https://. |
IPsec |
| LocalSubnet |
string |
Yes |
The CIDR block on the VPC side that needs to communicate with the data center. This parameter is used for Phase 2 negotiations. Separate multiple CIDR blocks with commas (,). Example: 192.168.1.0/24,192.168.2.0/24. Description of the routing mode of the IPsec-VPN connection:
|
10.10.1.0/24,10.10.2.0/24 |
| RemoteSubnet |
string |
Yes |
The CIDR block on the data center side that needs to communicate with the VPC. This parameter is used for Phase 2 negotiations. Separate multiple CIDR blocks with commas (,). Example: 192.168.3.0/24,192.168.4.0/24. Description of the routing mode of the IPsec-VPN connection:
|
10.10.3.0/24,10.10.4.0/24 |
| EffectImmediately |
boolean |
No |
Specifies whether the configurations of the IPsec-VPN connection take effect immediately. Valid values:
|
false |
| IkeConfig |
string |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. The configurations for Phase 1 negotiations:
|
{"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 |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. The configurations for Phase 2 negotiations:
|
{"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400} |
| HealthCheckConfig |
string |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. The health check configurations:
|
{"enable":"true","dip":"192.168.10.1","sip":"10.10.1.1","interval":"3","retry":"3"} |
| AutoConfigRoute |
boolean |
No |
Specifies whether to automatically configure routes. Valid values:
|
true |
| EnableDpd |
boolean |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. Specifies whether to enable the dead peer detection (DPD) feature. Valid values:
|
true |
| EnableNatTraversal |
boolean |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. Specifies whether to enable the NAT traversal feature. Valid values:
|
true |
| BgpConfig |
string |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. The BGP configurations:
Note
|
{"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"} |
| RemoteCaCertificate |
string |
No |
This parameter is supported when you create an IPsec-VPN connection in single-tunnel mode. If the current VPN gateway instance is a ShangMi (SM) VPN gateway, you must configure the CA certificate of the peer.
|
-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
| Tags |
array<object> |
No |
The list of tags to be added to the IPsec-VPN connection. You can add up to 20 tags to an IPsec-VPN connection at a time. |
|
|
object |
No |
The tag information. |
||
| Key |
string |
No |
The tag key. This parameter cannot be an empty string once specified. The tag key can be up to 64 characters in length, and cannot start with aliyun or acs:. It cannot contain http:// or https://. You can specify up to 20 tag keys at a time. |
TagKey |
| Value |
string |
No |
The tag value. The tag value can be up to 128 characters in length and can be an empty string. It cannot start with aliyun or acs:, and cannot contain http:// or https://. Each tag key corresponds to one tag value. You can specify up to 20 tag values at a time. |
TagValue |
| TunnelOptionsSpecification |
array<object> |
No |
The tunnel configurations.
|
|
|
array<object> |
No |
The tunnel configuration information. |
||
| CustomerGatewayId |
string |
No |
The ID of the customer gateway associated with the tunnel. Note
|
cgw-p0wy363lucf1uyae8**** |
| EnableDpd |
boolean |
No |
Specifies whether to enable the dead peer detection (DPD) feature for the tunnel. Valid values:
|
true |
| EnableNatTraversal |
boolean |
No |
Specifies whether to enable the NAT traversal feature for the tunnel. Valid values:
|
true |
| RemoteCaCertificate |
string |
No |
If the current VPN gateway instance is a ShangMi (SM) VPN gateway, you must configure the CA certificate of the peer for the tunnel.
|
-----BEGIN CERTIFICATE----- MIIB7zCCAZW**** -----END CERTIFICATE----- |
| Role |
string |
No |
The role of the tunnel. Valid values:
|
master |
| TunnelBgpConfig |
object |
No |
The BGP configurations for the tunnel. |
|
| LocalAsn |
integer |
No |
The autonomous system number (ASN) on the local side (Alibaba Cloud side) of the tunnel. Valid values: 1 to 4294967295. Default value: 45104. Note
|
65530 |
| LocalBgpIp |
string |
No |
The BGP IP address on the local side (Alibaba Cloud side) of the tunnel. This IP address must be within the BGP CIDR block. |
169.254.10.1 |
| TunnelCidr |
string |
No |
The BGP CIDR block of the tunnel. The CIDR block must be within the 169.254.0.0/16 range and have a mask length of 30, and cannot be 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, or 169.254.169.252/30. Note
The BGP CIDR block of each tunnel under the same VPN gateway instance must be unique. |
169.254.10.0/30 |
| TunnelIkeConfig |
object |
No |
The configurations for Phase 1 negotiations. |
|
| IkeAuthAlg |
string |
No |
The authentication algorithm for Phase 1 negotiations. Valid values: md5, sha1, sha256, sha384, and sha512. Default value: md5. |
md5 |
| IkeEncAlg |
string |
No |
The encryption algorithm for Phase 1 negotiations. Valid values: aes, aes192, aes256, des, and 3des. Default value: aes. |
aes |
| IkeLifetime |
integer |
No |
The SA lifecycle negotiated in Phase 1. Unit: seconds. Valid values: 0 to 86400. Default value: 86400. |
86400 |
| IkeMode |
string |
No |
The negotiation mode of the IKE version. Valid values: main and aggressive. Default value: main.
|
main |
| IkePfs |
string |
No |
The Diffie-Hellman key exchange algorithm used in Phase 1 negotiations. Default value: group2. |
group2 |
| IkeVersion |
string |
No |
The version of the IKE protocol. Valid values: ikev1 and ikev2. Default value: ikev1. Compared with IKEv1, IKEv2 simplifies the SA negotiation process and provides better support for scenarios with multiple CIDR blocks. |
ikev1 |
| LocalId |
string |
No |
The identifier on the local side (Alibaba Cloud side) of the tunnel, which is used for Phase 1 negotiations. The identifier can be up to 100 characters in length and cannot contain spaces. The default value is the IP address of the tunnel. LocalId supports the FQDN format. If you use the FQDN format, we recommend that you set the negotiation mode to aggressive. |
47.21.XX.XX |
| Psk |
string |
No |
The pre-shared key used for authentication between the tunnel and the peer.
Note
The pre-shared key of the tunnel must be the same as that of the peer. Otherwise, the system cannot establish the tunnel. |
123456**** |
| RemoteId |
string |
No |
The identifier of the peer, which is used for Phase 1 negotiations. The identifier can be up to 100 characters in length and cannot contain spaces. The default value is the IP address of the customer gateway associated with the tunnel. RemoteId supports the FQDN format. If you use the FQDN format, we recommend that you set the negotiation mode to aggressive. |
47.42.XX.XX |
| TunnelIpsecConfig |
object |
No |
The configurations for Phase 2 negotiations. |
|
| IpsecAuthAlg |
string |
No |
The authentication algorithm for Phase 2 negotiations. Valid values: md5, sha1, sha256, sha384, and sha512. Default value: md5. |
md5 |
| IpsecEncAlg |
string |
No |
The encryption algorithm for Phase 2 negotiations. Valid values: aes, aes192, aes256, des, and 3des. Default value: aes. |
aes |
| IpsecLifetime |
integer |
No |
The SA lifecycle negotiated in Phase 2. Unit: seconds. Valid values: 0 to 86400. Default value: 86400. |
86400 |
| IpsecPfs |
string |
No |
The Diffie-Hellman key exchange algorithm used in Phase 2 negotiations. Default value: group2. Valid values: disabled, group1, group2, group5, and group14. |
group2 |
| EnableTunnelsBgp |
boolean |
No |
This parameter is supported when you create an IPsec-VPN connection in dual-tunnel mode. Specifies whether to enable the BGP feature for the tunnel. Valid values: true and false (default). |
true |
| DryRun |
boolean |
No |
Specifies whether to only precheck the request. Valid values:
|
false |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
The returned result. |
||
| RequestId |
string |
The request ID. |
082AD562-B8DB-4BB2-861F-DA1FCA01FD76 |
| VpnConnectionId |
string |
The ID of the IPsec-VPN connection. |
vco-bp15oes1py4i6**** |
| Name |
string |
The name of the IPsec-VPN connection. |
test |
| CreateTime |
integer |
The timestamp when the IPsec-VPN connection was created. Unit: milliseconds. The timestamp is in the UNIX format, which represents the total duration from 00:00:00 on January 1, 1970 (UTC) to the time when the IPsec-VPN connection was created. |
1544666102000 |
Examples
Success response
JSON format
{
"RequestId": "082AD562-B8DB-4BB2-861F-DA1FCA01FD76",
"VpnConnectionId": "vco-bp15oes1py4i6****",
"Name": "test",
"CreateTime": 1544666102000
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 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. | The IPsec-VPN feature is not enabled for the VPN gateway. |
| 400 | VpnRouteEntry.AlreadyExists | The specified route entry is already exist. | The route already exists. |
| 400 | VpnRouteEntry.Conflict | The specified route entry has conflict. | Route conflicts exist. |
| 400 | NotSupportVpnConnectionParameter.IpsecPfs | The specified vpn connection ipsec Ipsec Pfs is not support. | The PFS parameter set for the IPsec-VPN connection is not supported. |
| 400 | NotSupportVpnConnectionParameter.IpsecAuthAlg | The specified vpn connection ipsec Auth Alg is not support. | The authentication algorithm specified for the IPsec-VPN connection is not supported. |
| 400 | VpnRouteEntry.ConflictSSL | The specified route entry has conflict with SSL client. | The route conflicts with the SSL client. |
| 400 | VpnRouteEntry.BackupRoute | Validate backup route entry failed. | Active/standby routes failed authentication. |
| 400 | VpnRouteEntry.InvalidWeight | Invalid route entry weight value. | The weight specified for the route is invalid. |
| 400 | InvalidParameter.VpnConnectionName | The specified vpn connection name is invalid. | The VPN connection name does not meet the requirements. |
| 400 | OperationUnsupported.SetDPD | Current version of the VPN does not support setting DPD. | The VPN gateway version does not support DPD. |
| 400 | OperationUnsupported.SetNatTraversal | Current version of the VPN does not support setting NAT traversal. | The VPN gateway version does not support NAT traversal. |
| 400 | QuotaExceeded.PolicyBasedRoute | The maximum number of policy-based routes is exceeded. Existing routes: %s. Routes to be created: %s. Maximum routes: %s. | The quota of policy-based routes is reached. Existing routes: %s. Routes to be created: %s. Quota: %s. |
| 400 | MissingParameter.TunnelCidr | The parameter TunnelCidr is mandatory when BGP is enabled. | You must specify the tunnel CIDR block when you enable BGP. |
| 400 | OperationUnsupported.EnableBgp | Current version of the VPN does not support enable BGP. | The current version of the VPN gateway does not support BGP. |
| 400 | MissingParam.CustomerGatewayAsn | Asn of customer gateway is mandatory when BGP is enabled. | The ASN of the customer gateway cannot be empty when you enable BGP. |
| 400 | IllegalParam.LocalAsn | The specified LocalAsn is invalid. | The local ASN is invalid. |
| 400 | IllegalParam.BgpConfig | The specified BgpConfig is invalid. | The BGP configuration is invalid. |
| 400 | IllegalParam.EnableBgp | VPN connection must enable BGP when VPN gateway has enabled BGP. | The error message returned because the VPN connection must use BGP if BGP is enabled for the VPN gateway. |
| 400 | IllegalParam.TunnelCidr | The specified TunnelCidr is invalid. | The TunnelCidr parameter is set to an invalid value. |
| 400 | InvalidLocalBgpIp.Malformed | The specified LocalBgpIp is malformed. | The local BGP IP address is in an abnormal state. |
| 400 | IllegalParam.LocalBgpIp | The specified LocalBgpIp is invalid. | The local BGP IP address is invalid. |
| 400 | IllegalParam.LocalSubnet | The specified "LocalSubnet" (%s) is invalid. | The specified "LocalSubnet" (%s) is invalid. |
| 400 | IllegalParam.RemoteSubnet | The specified "RemoteSubnet" (%s) is invalid. | The specified "RemoteSubnet" (%s) is invalid. |
| 400 | OperationFailed.MissCertificate | The VPN gateway has not associated any certificates. | The error message returned because the VPN gateway is not associated with a certificate. |
| 400 | MissingParam.RemoteId | The remote ID is mandatory when creating national standard VPN connection. | The error message returned because the peer ID is not specified. You must specify the peer ID when you create a VPN connection encrypted by SM. |
| 400 | CustomerGateway.ConflictRouteEntry | The specified customer gateway has conflict with route entry. | The customer gateway conflicts with the current routes. |
| 400 | VpnTask.CONFLICT | Vpn task has conflict. | The VPN operation conflicts. Try again later. |
| 400 | Forbidden.TagKey.Duplicated | The specified tag key already exists. | The tag resources are duplicate. |
| 400 | SizeLimitExceeded.TagNum | The maximum number of tags is exceeded. | The number of tags has reached the upper limit. |
| 400 | InvalidParameter.TagValue | The specified parameter TagValue is invalid. | The error message returned because the specified tag value is invalid. |
| 400 | InvalidParameter.TagKey | The specified parameter TagKey is invalid. | The error message returned because the specified tag key is invalid. |
| 400 | Duplicated.TagKey | The specified parameter TagKey is duplicated. | The error message returned because the specified tag key already exists. |
| 400 | InternalError | The request processing has failed due to some unknown error, exception or failure. | |
| 400 | InvalidTunnelCidr.Malformed | The specified TunnelCidr is malformed. | The specified tunnel CIDR block is invalid. |
| 400 | VpnConnectionParamInvalid.SameVpnAndCgwDifferentIkeConfigs | IPSec connections associated with the same user gateway and VPN gateway should have the same pre-shared key and IKE configuration. | The pre-shared key and IKE parameters must be the same for IPsec-VPN connections that are associated with the same VPN gateway and customer gateway. |
| 400 | VpnConnectionParamInvalid.SameVpnAndCgwTrafficSelectorOverlap | Traffic selectors of IPSec connections associated with the same user gateway and VPN gateway should not overlap. | The protected data flows of IPsec-VPN connections that are associated with the same VPN gateway and customer gateway cannot overlap. |
| 400 | CustomerGateway.ConflictVpnIp | The customer gateway associated with the IPSec connection should not have the same IP address as the VPN gateway. | The customer gateway and VPN gateway of an IPsec-VPN connection cannot use the same IP address. |
| 400 | VpnGateway.IPsecServerAndVpnConnectionConflict | The IPSec connection and IPSec server cannot be configured on the same VPN gateway at the same time. | You cannot configure an IPsec server and an IPsec-VPN connection at the same time for one VPN gateway. |
| 400 | InvalidSslVpnServerCertId.NotFound | The parameter is incorrect. The corresponding SSL VPN server certificate cannot be found. | The parameter is incorrect. The corresponding SSL VPN server certificate cannot be found. |
| 400 | MissingParameter.TunnelOptionsSpecification | The required parameters are missing when creating a tunnel for dual-tunnel VPN. | The required parameters are missing when creating a tunnel for dual-tunnel VPN. |
| 400 | CreateDbrRoutesQuotaFull.QuotaFull | The number of created destination routes exceeds the quota limit. | The number of created destination routes exceeds the quota limit. |
| 400 | CreatePbrRoutesQuotaFull.QuotaFull | The number of policy routes exceeds the quota limit. | The number of policy routes exceeds the quota limit. |
| 400 | CreateVpnConnectionsQuotaFull.QuotaFull | The number of VPN connections exceeds the quota limit. | The number of VPN connections exceeds the quota limit. |
| 400 | DryRunOperation | Request validation has been passed with DryRun flag set. | The request passed the dry run. |
| 400 | OperationFailed.OpenCdtServiceFirst | The operation is failed because of %s. | The billing method requires CDT billing enabled. Enable CDT billing and try again. |
| 400 | EncAlgInvalid.DesIncompatible | Des/3des in IkeEncAlg and IpsecEncAlg does not support multi algorithm. | Des/3des in IkeEncAlg and IpsecEncAlg does not support multi algorithm. |
| 400 | IkeVersionInvalid.GcmIncompatible | Ikev1 does not support IkeEncAlg of gcm16. | Ikev1 does not support IkeEncAlg of gcm16. |
| 400 | CustomerGateway.AsnNotConfigured | ASN of CustomerGateway is required when enabling BGP on an IPSec connection. | When BGP is enabled for IPSec connection, ASN needs to be configured on the customer gateway. |
| 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. | When the VPC to which the VPN gateway belongs is attached to a FULL-mode CEN, the VPN gateway cannot enable 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. | You do not have the permissions to manage the specified resource. Apply for the permissions and try again. |
| 404 | InvalidCustomerGatewayInstanceId.NotFound | The specified customer gateway instance id does not exist. | The specified customer gateway does not exist. Check whether the ID of the customer gateway is correct. |
| 404 | InvalidVpnGatewayInstanceId.NotFound | The specified vpn gateway instance id does not exist. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.