After you create a VPN Gateway, you must configure an IPsec-VPN connection in both Alibaba Cloud and your on-premises data center to connect the data center to your VPC.
New VPN gateway support only dual-tunnel mode.
Existing single-tunnel VPN gateway support only single-tunnel IPsec-VPN connections. To ensure high availability, we recommend upgrading to dual-tunnel mode. After the upgrade, the VPN gateway will no longer support single-tunnel connections.
How it works
By default, IPsec-VPN connections use a dual-tunnel mode to ensure high availability and business continuity.
Tunnel roles: The system uses two different public IP addresses of the VPN gateway to establish two tunnels. Tunnel roles are fixed.
Tunnel 1 (using IP address 1) is the active tunnel by default and carries all service traffic.
Tunnel 2 (using IP address 2) is the standby tunnel and remains on standby.
Health checks and failover: The system automatically performs health checks on the active tunnel. If the active tunnel fails, the VPN gateway automatically switches traffic to the standby tunnel. After the active tunnel recovers, traffic automatically switches back.
Zone-disaster recovery:
The two tunnels of an IPsec-VPN connection are deployed in different zones by default. If one zone fails, the tunnel in the other zone remains available. This provides cross-zone disaster recovery.
In regions that support only one zone, both tunnels are deployed in the same zone. These deployments do not support zone-level disaster recovery but still provide link redundancy.
Create an IPsec-VPN connection
Prerequisites
Before you begin, make sure that you have created a VPN gateway and a customer gateway.
1. Configure the IPsec-VPN connection
Console
Go to the IPsec Connections page in the VPC console, click Bind VPN Gateway, and configure the following parameters:
IPsec Settings: Select the Region where the VPN gateway is deployed.
Gateway Settings: Select the VPN gateway that you want to attach.
Route Settings:
Routing Mode:
Destination Routing Mode (Default): Traffic is forwarded based on the destination IP address. Recommended for scenarios where routes are learned via BGP or configured statically.
Protected Data Flows: Traffic is forwarded based on source and destination IP addresses. Recommended for scenarios where you need to limit communication to specific CIDR blocks.
You must specify the Local Network (VPC CIDR block) and Remote Network (on-premises CIDR block).
The system automatically generates a policy-based route. In this route, the Source CIDR Block is the connection's Local Network, the Destination CIDR Block is the connection's Remote Network, and the next hop is the IPsec-VPN connection. The route can be published to a VPC route table but is not published by default.
Ensure that the interesting traffic configuration on your on-premises gateway mirrors these settings (local and remote networks swapped).
To add multiple network segments, click the Add
icon. Multiple segments require IKEv2.
Effective Immediately: Select Yes to enable the connection quickly or avoid traffic delays. Select No if you want to save resources and traffic is infrequent.
Dual-Tunnel Settings:
Enable BGP: Specifies whether to use BGP dynamic routing.
Disabled (Default): Uses static routing. Recommended for simple network topologies.
Enabled: Use dynamic routing for automatic route distribution and learning. Prerequisite: You must configure an ASN for the associated customer gateway.
Local ASN: The Autonomous System Number (ASN) for the Alibaba Cloud side (used by both tunnels).
Default: 45104
Range: 1 to 4294967295
Recommendation: Use a private ASN when configuring the ASN for your on-premises device.
Tunnel 1 (Primary) and Tunnel 2 (Backup) configurations:
Customer Gateway: Select the customer gateway associated with your on-premises device. You can associate the same customer gateway with both tunnels.
Pre-Shared Key: Enter the pre-shared key used for identity authentication.
Requirement: The key must match the configuration on your on-premises gateway.
Consistency: The keys for both tunnels must be identical.
Default: If left blank, the system automatically generates a random key.
Confirm the configuration
Review the configuration and then click OK at the bottom of the page.
In the dialog box that appears, click Cancel. You can configure the routing later.
In the Actions column of the target IPsec-VPN connection, click Generate Peer Configuration. In the IPsec-VPN Connection Configuration dialog box, copy the configuration and save it locally to configure the on-premises gateway device.
API
Call the CreateVpnConnection operation to create an IPsec-VPN connection.
2. Configure VPN gateway and VPC routes
Configure the routes as described in Configure routes for a VPN gateway.
3. Configure the on-premises gateway device
Use the peer configuration that you downloaded in the "Configure the IPsec-VPN connection" step to complete the IPsec and BGP (if enabled) configurations on your on-premises gateway device, such as a firewall or router. For specific configuration instructions, see the documentation for your device. See Configure an on-premises gateway device for a reference example.
Manage IPsec-VPN connections
Enable or disable BGP
Before you enable BGP for an IPsec-VPN connection, make sure that the associated customer gateway has an ASN configured. If it does not, you must delete and recreate the IPsec-VPN connection and associate it with a customer gateway that has an ASN configured.
The following BGP configuration items are related to the IPsec-VPN connection:
Local ASN: The Autonomous System Number (ASN) for the Alibaba Cloud side (used by both tunnels).
Default: 45104
Range: 1 to 4294967295
Recommendation: Use a private ASN when configuring the ASN for your on-premises device.
Tunnel CIDR Block: The
/30subnet within169.254.0.0/16used for BGP peering.Uniqueness: Each tunnel on a VPN gateway must use a unique CIDR block.
Excluded Blocks: The following blocks are reserved and cannot be used:
169.254.0.0/30through169.254.5.0/30169.254.169.252/30
Local BGP IP address: The BGP IP address for the Alibaba Cloud side.
Constraint: Must belong to the Tunnel CIDR Block.
Example: If the CIDR block is
169.254.10.0/30, you can use169.254.10.1.
For details on BGP limits and route advertisement, see Configure BGP dynamic routing.
Console
Enable BGP
When you create an IPsec-VPN connection, you can enable BGP by selecting Enable BGP and configuring the Local ASN, Tunnel CIDR Block, and Local BGP IP address.
For an existing IPsec-VPN connection, you can click Enable BGP in the IPsec Connections section on the instance details page.
Disable BGP
On the IPsec-VPN connection details page, in the IPsec Connections section, turn off the Enable BGP switch.
API
When creating a new IPsec-VPN connection, set the EnableTunnelsBgp parameter of the CreateVpnConnection operation to enable BGP, and configure BGP options for each tunnel by setting the TunnelOptionsSpecification -> TunnelBgpConfig parameter.
For an existing IPsec-VPN connection, set the EnableTunnelsBgp parameter of the ModifyVpnConnectionAttribute operation to enable or disable BGP, and configure BGP options for each tunnel by setting the TunnelOptionsSpecification -> TunnelBgpConfig parameter.
Modify tunnel configurations
Console
Go to the IPsec-VPN Connections page in the VPC console, switch to the target region, and click the target IPsec-VPN connection ID.
On the IPsec-VPN connection details page, find the target tunnel, and in the Actions column, click Edit.
On the edit page, modify the tunnel configuration and then click OK.
API
Call the ModifyTunnelAttribute operation to modify tunnel configurations.
Modify IPsec-VPN connection configurations
If an IPsec-VPN connection is attached to a VPN gateway, you cannot modify the associated VPN gateway. You can only modify the Routing Mode and Effective Immediately settings.
Console
Go to the IPsec-VPN Connections page in the VPC console, switch to the destination region, and click Edit in the Actions column of the target IPsec-VPN connection.
On the Modify IPsec-VPN Connection page, modify settings such as the IPsec-VPN connection name and remote CIDR block, and then click OK.
For detailed descriptions of the parameters, see Create an IPsec-VPN connection.
API
Call the ModifyVpnConnectionAttribute operation to modify IPsec-VPN connection configurations.
Delete an IPsec-VPN connection
Console
Go to the IPsec-VPN Connections page in the VPC console, switch to the destination region, and click Delete in the Actions column of the target IPsec-VPN connection.
In the dialog box that appears, confirm the information, and then click OK.
API
Call the DeleteVpnConnection operation to delete an IPsec-VPN connection.
Billing
An IPsec-VPN connection is free of charge. However, you are charged for the associated VPN gateway. For more information, see IPsec-VPN billing.
FAQ
Why does the tunnel status show "Phase 1 Negotiation Failed"?
If you have configured both sides, check for these common issues:
Pre-shared key mismatch: Verify the pre-shared keys on both the Alibaba Cloud and on-premises gateways. They must be identical, including case and special characters.
IKE parameter mismatch: Ensure all IKE parameters (Version, Negotiation Mode, Encryption/Authentication Algorithms, DH Group) match exactly on both sides.
Network connectivity: Confirm the public IP of your on-premises gateway is reachable. Ensure no firewall or ISP policies are blocking UDP ports 500 and 4500.
The tunnel status is normal, but I cannot ping the server on the other end. Why?
Successful Phase 2 negotiation confirms the encrypted tunnel is established but does not guarantee data transmission. Check the following configurations:
Route configuration: Verify that route tables in both the Alibaba Cloud VPC and your on-premises data center correctly direct traffic to the IPsec-VPN connection.
Security groups and network ACLs: Ensure that the security group rules for your ECS instances allow ICMP or service traffic from the on-premises CIDR block.
On-premises firewall policy: Confirm that your on-premises firewall allows traffic from the VPC CIDR block.
Why is the "Enable BGP" option unavailable?
The option is disabled if the associated customer gateway does not have an Autonomous System Number (ASN) configured.
Solution:
Delete the current IPsec-VPN connection.
Create a new customer gateway and ensure you configure an ASN.
Recreate the IPsec-VPN connection using the new customer gateway.
Can I set Tunnel 2 as the active tunnel?
No. Tunnel roles are fixed and cannot be changed:
Tunnel 1 (IP Address 1) is always the active tunnel.
Tunnel 2 (IP Address 2) is always the standby tunnel.
Can I create a single-tunnel IPsec-VPN connection?
It depends on your VPN Gateway type:
New VPN gateways: No. Newly purchased instances support only dual-tunnel IPsec-VPN connections.
Existing single-tunnel gateways: Yes. You can continue to create single-tunnel connections for these instances.
Recommendation: Upgrade to dual-tunnel mode to ensure high availability.
Note: After the upgrade, the instance will no longer support creating single-tunnel connections.