Creates an IPsec-VPN connection.

Usage notes

  • The CreateVpnConnection operation is asynchronous. After you send the request, the system returns a request ID. However, the operation is still being performed in the system background. You can call DescribeVpnGateway to query the status of a VPN gateway.
    • If a VPN gateway is in the updating state, the IPsec-VPN connection is being created.
    • If a VPN gateway is in the active state, the IPsec-VPN connection has been created.
  • You cannot repeatedly call CreateVpnConnection to create an IPsec-VPN connection on a VPN gateway within the specified period of time.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes CreateVpnConnection

The operation that you want to perform. Set the value to CreateVpnConnection.

RegionId String Yes cn-shanghai

The ID of the region where you want to create the IPsec-VPN connection. You can call the DescribeRegions operation to query the most recent region list.

ClientToken String No 02fb3da4-130e-11e9-8e44-001****

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 make sure that it is unique among different requests. ClientToken can contain only ASCII characters.

Note If you do not set this parameter, ClientToken is set to the value of RequestId. The value of RequestId may be different for each API request.
CustomerGatewayId String Yes cgw-p0w2jemrcj5u61un8****

The ID of the customer gateway.

VpnGatewayId String Yes vpn-bp1q8bgx4xnkm****

The ID of the VPN gateway.

Name String No IPsec

The name of the IPsec-VPN connection.

The name must be 2 to 128 characters in length, and can contain letters, digits, periods (.), underscores (_), and hyphens (-). It must start with a letter but cannot start with http:// or https://.

LocalSubnet String Yes 10.10.1.0/24,10.10.2.0/24

The CIDR block on the VPC side. The CIDR block is used in Phase 2 negotiations.

Separate CIDR blocks with commas (,). Example: 192.168.1.0/24,192.168.2.0/24.

The following routing modes are supported:

  • If you set LocalSubnet and RemoteSubnet to 0.0.0.0/0, the routing mode of the IPsec-VPN connection is set to Destination Routing Mode.
  • If you set LocalSubnet and RemoteSubnet to specific CIDR blocks, the routing mode of the IPsec-VPN connection is set to Protected Data Flows.
RemoteSubnet String Yes 10.10.3.0/24,10.10.4.0/24

The CIDR block on the data center side. This CIDR block is used in Phase 2 negotiations.

Separate CIDR blocks with commas (,). Example: 192.168.3.0/24,192.168.4.0/24.

The following routing modes are supported:

  • If you set LocalSubnet and RemoteSubnet to 0.0.0.0/0, the routing mode of the IPsec-VPN connection is set to Destination Routing Mode.
  • If you set LocalSubnet and RemoteSubnet to specific CIDR blocks, the routing mode of the IPsec-VPN connection is set to Protected Data Flows.
EffectImmediately Boolean No false

Specifies whether to immediately start IPsec negotiations. Valid values:

  • true: immediately starts IPsec negotiations after the configuration is complete.
  • false: starts IPsec negotiations when inbound traffic is detected. This is the default value.
IkeConfig String No {"Psk":"1234****","IkeVersion":"ikev1","IkeMode":"main","IkeEncAlg":"aes","IkeAuthAlg":"sha1","IkePfs":"group2","IkeLifetime":86400,"LocalIdIPsec":"47.XX.XX.1","RemoteId":"47.XX.XX.2"}

The configuration of Phase 1 negotiations:

  • IkeConfig.Psk: The pre-shared key that is used for authentication between the VPN gateway and the data center. The key must be 1 to 100 characters in length.

    If you do not specify a pre-shared key, the system generates a random 16-bit string as the pre-shared key. You can call the DescribeVpnConnection operation to query the pre-shared key that is generated by the system.
    Note The pre-shared key of the IPsec-VPN connection must be the same as the authentication key of the data center. Otherwise, you cannot establish a connection between the data center and the VPN gateway.
  • IkeConfig.IkeVersion: the version of the IKE protocol. Valid values: ikev1 and ikev2. Default value: ikev1.
  • IkeConfig.IkeMode: the negotiation mode of IKE V1. Valid values: main and aggressive. Default value: main.
  • IkeConfig.IkeEncAlg: the encryption algorithm that is used in Phase 1 negotiations. Valid values: aes, aes192, aes256, des, and 3des. Default value: aes.
  • IkeConfig.IkeAuthAlg: the authentication algorithm that is used in Phase 1 negotiations. Valid values: md5 and sha1. Default value: md5.
  • IkeConfig.IkePfs: The Diffie-Hellman (DH) key exchange algorithm that is used in Phase 1 negotiations. Valid values: group1, group2, group5, and group14. Default value: group2.
  • IkeConfig.IkeLifetime: the SA lifetime determined by Phase 1 negotiations. Unit: seconds. Valid values: 0 to 86400. Default value: 86400.
  • IkeConfig.LocalIdIPsec: the identifier of the VPN gateway. The identifier of the VPN gateway cannot exceed 100 characters in length. The default value is the IP address of the VPN gateway.
  • IkeConfig.RemoteId: the identifier of the customer gateway. The identifier of the customer gateway cannot exceed 100 characters in length. The default value is the IP address of the customer gateway.
IpsecConfig String No {"IpsecEncAlg":"aes","IpsecAuthAlg":"sha1","IpsecPfs":"group2","IpsecLifetime":86400}

The configuration of Phase 2 negotiations:

  • IpsecConfig.IpsecEncAlg: the encryption algorithm that is used in Phase 2 negotiations. Valid values: aes, aes192, aes256, des, and 3des. Default value: aes.
  • IpsecConfig. IpsecAuthAlg: the authentication algorithm that is used in Phase 2 negotiations. Valid values: md5 and sha1. Default value: md5.
  • IpsecConfig. IpsecPfs: the Diffie-Hellman key exchange algorithm that is used in Phase 2 negotiations. Valid values: disabled, group1, group2, group5, and group14 Default value: group2. IkeConfig. IkeLifetime: the SA lifetime determined by Phase 2 negotiations. Unit: seconds. Valid values: 0 to 86400. Default value: 86400.
HealthCheckConfig String No {"enable":"true","dip":"192.168.10.1","sip":"10.10.1.1","interval":"3","retry":"3"}

The health check configuration:

  • HealthCheckConfig.enable: specifies whether to enable health checks. Valid values: true and false. Default value: false.
  • HealthCheckConfig.dip: the destination IP address configured for health checks.
  • HealthCheckConfig.sip: the source IP address configured for health checks.
  • HealthCheckConfig.interval: the time interval of health check retries. Unit: seconds.
  • HealthCheckConfig.retry: the maximum number of health check retries.
AutoConfigRoute Boolean No true

Specifies whether to automatically configure routes. Valid values:

  • true (default): automatically configures routes.
  • false: does not automatically configure routes.
EnableDpd Boolean No true

Specifies whether to enable the dead peer detection (DPD) feature. Valid values:

  • true (default): enables DPD. The initiator of the IPsec-VPN connection sends DPD packets to verify the existence and availability of the peer. If no feedback is received from the peer within a specified period of time, the connection fails. ISAKMP SAs and IPsec SAs are deleted. The IPsec tunnel is also deleted.
  • false: no. The IPsec initiator does not send DPD packets.
EnableNatTraversal Boolean No true

Specifies whether to enable NAT traversal. Valid values:

  • true (default): enables NAT traversal. After NAT traversal is enabled, the initiator does not check the UDP ports during IKE negotiations and can automatically discover NAT gateway devices along the VPN tunnel.
  • false: no
BgpConfig String No {"EnableBgp":"true","LocalAsn":"45104","TunnelCidr":"169.254.11.0/30","LocalBgpIp":"169.254.11.1"}

The Border Gateway Protocol (BGP) configuration:

  • BgpConfig.EnableBgp: specifies whether to enable BGP. Valid values: true and false. Default value: false.
  • BgpConfig.LocalAsn: the ASN on the Alibaba Cloud side. Valid values: 1 to 4294967295. Default value: 45104.
  • BgpConfig.TunnelCidr: the CIDR block of the IPsec tunnel. The CIDR block must belong to 169.254.0.0/16. The subnet mask of the CIDR block must be 30 bits in length.
  • LocalBgpIp: the BGP IP address on the Alibaba Cloud side. This IP address must fall within the CIDR block of the IPsec tunnel.
Note
  • This parameter is required when the VPN gateway has dynamic BGP enabled.
  • Before you configure BGP, we recommend that you learn about how BGP works and the limits. For more information, see VPN Gateway supports BGP dynamic routing.
  • We recommend that you use a private ASN to establish a connection with Alibaba Cloud over BGP. Refer to the relevant documentation for the valid range of a private ASN.
RemoteCaCertificate String No c20ycDI1NnYxIENBIChURVNUIFN****

The peer CA certificate when a China Certification VPN gateway is used to create the IPsec-VPN connection.

  • This parameter is required when a China Certification VPN gateway is used to create the IPsec-VPN connection.
  • You can ignore this parameter when a standard VPN gateway is used to create the IPsec-VPN connection.

Response parameters

Parameter Type Example Description
RequestId String 082AD562-B8DB-4BB2-861F-DA1FCA01FD76

The ID of the request.

VpnConnectionId String vco-bp15oes1py4i6****

The ID of the IPsec-VPN connection.

Name String test

The name of the IPsec-VPN connection.

CreateTime Long 1544666102000

The timestamp generated when the IPsec-VPN connection was created. Unit: milliseconds.

This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC.

Examples

Sample requests

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"}
&Common request parameters

Sample success responses

XML format

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 format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "082AD562-B8DB-4BB2-861F-DA1FCA01FD76",
  "VpnConnectionId" : "vco-bp15oes1py4i6****",
  "Name" : "test",
  "CreateTime" : 1544666102000
}

Error codes

HttpCode Error code Error message Description
400 Resource.QuotaFull The quota of resource is full The error message returned because the resource quota is reached.
400 InvalidVpnConnection.AlreadyExists Vpn connection already exists. The error message returned because the IPsec-VPN connection already exists.
400 VpnGateway.Configuring The specified service is configuring. The error message returned because the operation is not allowed when the specified service is being configured. Try again later.
400 VpnGateway.FinancialLocked The specified service is financial locked. The error message returned because the service is suspended due to overdue payments. Top up your account before you enable the service.
400 VpnRouteEntry.AlreadyExists The specified route entry is already exist. The error message returned because the route already exists.
400 VpnRouteEntry.Conflict The specified route entry has conflict. The error message returned because the specified route conflicts with an existing route.
400 VpnRouteEntry.BackupRoute Validate backup route entry failed. The error message returned because active/standby routes failed authentication.
400 OperationUnsupported.SetDPD Current version of the VPN does not support setting DPD. The error message returned because the VPN gateway version does not support DPD.
400 OperationUnsupported.SetNatTraversal Current version of the VPN does not support setting NAT traversal. The error message returned because 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 error message returned because the number of policy-based routes reaches the upper limit. The maximum number of routes that you can create is %s. The number of existing routes is %s. You are creating %s routes.
400 MissingParam.CustomerGatewayAsn Asn of customer gateway is mandatory when BGP is enabled. The error message returned because the ASN of the customer gateway cannot be empty when you enable BGP.
400 IllegalParam.LocalSubnet The specified "LocalSubnet" (%s) is invalid. The error message returned because LocalSubnet (%s) is set to an invalid value.
400 IllegalParam.RemoteSubnet The specified "RemoteSubnet" (%s) is invalid. The error message returned because RemoteSubnet (%s) is set to an invalid value.
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. The error message returned because you cannot enable BGP for a VPN gateway when the FULL mode is enabled for the Cloud Enterprise Network (CEN) instance to which the VPC of the VPN gateway is attached.
403 Forbbiden.SubUser User not authorized to operate on the specified resource as your account is created by another user. The error message returned because you are unauthorized to perform this operation on the specified resource. Acquire the required permissions and try again.
403 Forbidden User not authorized to operate on the specified resource. The error message returned because you are unauthorized to perform this operation on the specified resource. You can apply for the required permissions and try again.
404 InvalidCustomerGatewayInstanceId.NotFound The specified customer gateway instance id does not exist. The error message returned because 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. The error message returned because the specified VPN gateway does not exist. Check whether the specified VPN gateway is valid.

For a list of error codes, visit the API Error Center.