This topic describes how to create multiple private IPsec-VPN connections between a data center and a virtual private cloud (VPC). You can use the connections to encrypt data transmission between the data center and the VPC, and implement load balancing based on equal-cost multi-path (ECMP) routing.
Scenarios

The preceding scenario is used as an example in this topic. An enterprise owns a data center in Shanghai and created a VPC in the China (Hangzhou) region. Applications are deployed on an Elastic Compute Service (ECS) instance in the VPC. The enterprise wants to create private connections between the data center and the VPC. The enterprise also wants to encrypt the private connections and use the connections to implement load balancing based on ECMP routing.
Network design
Network settings
The following network settings are used in this topic:
- The data center is connected to Alibaba Cloud through two Express Connect circuits, and communicates with the VPC through a Cloud Enterprise Network (CEN) instance. The two Express Connect circuits ensure network redundancy and forward traffic.
- After the data center and the VPC are connected through Express Connect circuits, you can create IPsec-VPN connections over the Express Connect circuits. You can create two IPsec-VPN connections over each Express Connect circuit. The connections encrypt data transmission between the data center and the VPC, and balance the load of traffic based on ECMP routing.
- When you create the IPsec-VPN connections, set Gateway Type to Private.
- Set the Associate Resource parameter of the IPsec-VPN connections to CEN. This way, the IPsec-VPN connections are aggregated for ECMP routing. Note You can associate IPsec-VPN connections only with Enterprise Edition transit routers on CEN instances.
- The data center, the virtual border routers (VBRs), and the IPsec-VPN connections use BGP to automatically learn and advertise routes. This facilitates route configuration. When one of the IPsec-VPN connections fails, traffic is redirected to another IPsec-VPN connection. This ensures service reliability.
Network planning
Item | CIDR block and IP address |
---|---|
VPC | Primary CIDR block: 172.16.0.0/16
|
IPsec-VPN connections | BGP configurations:
|
VBR | VBR1 configurations:
VBR2 configurations:
|
On-premises gateway devices | VPN IP addresses of the on-premises gateway devices:
|
BGP configurations of premises gateway devices:
| |
Data center | CIDR blocks to be connected to the VPC:
|
Preparations
- A VPC is created in the China (Hangzhou) region. Applications are deployed on the ECS instance in the VPC. For more information, see Create a VPC with an IPv4 CIDR block.
- A CEN instance is created. An Enterprise Edition transit router is created in the China (Hangzhou) and China (Shanghai) regions. For more information, see Create a CEN instance and Create a transit router. Important When you create a transit router, you must configure a CIDR block for the transit router. Otherwise, IPsec-VPN connections cannot be associated with the transit router.
If you have already created a transit router, you can configure a CIDR block for the transit router. For more information, see Create a CIDR block for a transit router.
- You understand the security group rules of the ECS instance in the VPC. Make sure that the rules allow the ECS instance to communicate with the data center. For more information, see Query security group rules and Add a security group rule.
Procedure

Step 1: Deploy Express Connect circuits
You must deploy an Express Connect circuit to connect the data center to Alibaba Cloud.
- Create dedicated connections over Express Connect circuits. In this example, two dedicated connections over Express Connect circuits are created in the China (Shanghai) region. The Express Connect circuits are named Express Connect Circuit 1 and Express Connect Circuit 2. For more information, see Create and manage a dedicated connection over an Express Connect circuit.When you apply for the second Express Connect circuit, you may need to specify a redundant Express Connect circuit based on the access point.
- If you want to connect the Express Connect circuits to the same access point, you must specify the redundant Express Connect circuit. Set Redundant Connection ID to the first Express Connect circuit. This way, the Express Connect circuits will be connected to different access devices.
- If you want to connect the Express Connect circuits to different access points, you do not need to specify the redundant Express Connect circuit. In this case, you do not need to specify Redundant Connection ID.
In this example, the Express Connect circuits are connected to different access points.
- Create VBRs.
- Configure a BGP group for each VBR.
- Configure a BGP peer for each VBR.
- Configure BGP routing for the on-premises gateway devices. After you configure BGP routing for the on-premises gateway devices, the on-premises gateway devices and the VBRs establish peering connections, and automatically learn and advertise routes. The following configurations are used for reference only. The commands may vary based on the network device vendor. Contact the vendor to obtain the information about specific commands.
# Configure On-premises Gateway Device 1. router bgp 65530 //Enable BGP and configure the ASN of the data center. In this example, 65530 is used. bgp router-id 10.0.0.1 //Enter the ID of the BGP router. In this example, 10.0.0.1 is used. bgp log-neighbor-changes neighbor 10.0.0.2 remote-as 45104 //Establish a peering connection to VBR1. ! address-family ipv4 network 192.168.0.0 mask 255.255.255.0 //Advertise the CIDR block of the data center. network 192.168.1.0 mask 255.255.255.0 network 192.168.2.0 mask 255.255.255.0 neighbor 10.0.0.2 activate //Activate the BGP peer. exit-address-family ! # Configure On-premises Gateway Device 2. router bgp 65530 //Enable BGP and configure the ASN of the data center. In this example, 65530 is used. bgp router-id 10.0.1.1 //Enter the ID of the BGP router. In this example, 10.0.1.1 is used. bgp log-neighbor-changes neighbor 10.0.1.2 remote-as 45104 //Establish a peering connection to VBR2. ! address-family ipv4 network 192.168.0.0 mask 255.255.255.0 //Advertise the CIDR block of the data center. network 192.168.1.0 mask 255.255.255.0 network 192.168.2.0 mask 255.255.255.0 neighbor 10.0.1.2 activate //Activate the BGP peer. exit-address-family !
Step 2: Configure a CEN instance
After you deploy the Express Connect circuits, the data center is connected to Alibaba Cloud through the Express Connect circuits. However, the data center and the VPC cannot communicate with each other. To enable communication between the data center and the VPC, you must connect the VBRs and the VPC to a CEN instance.
- Create a VPC connection.
- Create VBR connections.
- Return to the Create Connection in the Actions column. tab, find the transit router that you want to manage and click
- Purchase a bandwidth plan. The transit router associated with the VBRs and the transit router associated with the VPC are deployed in different regions. By default, the VBRs cannot communicate with the VPC in this scenario. To allow the VBRs to communicate with the VPC across regions, you need to create an inter-region connection between the transit router in the China (Hangzhou) region and the transit router in the China (Shanghai) region.
You can allocate bandwidth to an inter-region connection from a bandwidth plan or pay for the bandwidth usage of the inter-region connection on a pay-by-data-transfer basis. In this example, a bandwidth plan is used.
Purchase a bandwidth plan to allocate bandwidth for inter-region communication before you create an inter-region connection.
- Create an inter-region connection
Step 3: Create IPsec-VPN connections
After you complete the preceding steps, the data center can communicate with the VPC over private connections. However, data transmission between the data center and the VPC is not encrypted. To encrypt data transmission, you must create IPsec-VPN connections between the data center and Alibaba Cloud.
- Log on to the VPN Gateway console.
- Creates customer gateways. Before you create IPsec-VPN connections, you need to create customer gateways to provide information about the on-premises gateway devices to Alibaba Cloud.
- Create IPsec-VPN connections. After you create customer gateways, you need to create IPsec-VPN connections between Alibaba Cloud and the data center.After the IPsec-VPN connections are created, the system assigns a private gateway IP address to each IPsec-VPN connection. The gateway IP address is an endpoint on the Alibaba Cloud side of the IPsec-VPN connection. You can view the gateway IP address of an IPsec-VPN connection on the details page, as shown in the following figure.
The following table describes the gateway IP addresses that are assigned to IPsec-VPN Connection 1, IPsec-VPN Connection 2, IPsec-VPN Connection 3, and IPsec-VPN Connection 4.
IPsec-VPN connection Gateway IP address IPsec-VPN Connection 1 192.168.168.1 IPsec-VPN Connection 2 192.168.168.2 IPsec-VPN Connection 3 192.168.168.3 IPsec-VPN Connection 4 192.168.168.4 Note- The system assigns gateway IP addresses to IPsec-VPN connections only after you associate the IPsec-VPN connections with transit routers. When you create an IPsec-VPN connection, if you set Associate Resource to Do Not Associate or VPN Gateway, the system does not assign a gateway IP address to the IPsec-VPN connection.
- After a private IPsec-VPN connection is associated with a transit router, the system automatically advertises the gateway IP address of the IPsec-VPN connection to the route table of the transit router.
- Download the peer configurations of the IPsec-VPN connections. On the IPsec Connections page, find the IPsec-VPN connection that you created. In the Actions column, choose .
Download the peer configurations of the four IPsec-VPN connections to your on-premises machine so that you can use the configurations when you add VPN configurations to the on-premises gateway devices.
- Add VPN configurations and BGP configurations to the on-premises gateway devices. After the IPsec-VPN connections are created, perform the following steps to add the VPN and BGP configurations in the peer configurations that you downloaded to the On-premises Gateway Device 1 and On-premises Gateway Device 2. This way, the data center can communicate with Alibaba Cloud over the IPsec-VPN connections.
The following configurations are used for reference only. The commands may vary based on the network device vendor. Contact the vendor to obtain the information about specific commands.
Step 4: Configure routes and routing policies
After you complete the preceding configurations, you must add routes and routing policies on Alibaba Cloud so that the IPsec-VPN connections can work as expected. You must also route traffic between the data center and Alibaba Cloud to encrypted tunnels.
- Add custom routes to the VBRs. Route traffic destined for the data center to the Express Connect circuits.
- Add routing policies to the CEN instance.
Step 5: Test the network connectivity
After you configure the routes, the data center can communicate with the VPC through private and encrypted connections. The traffic between the data center and VPC is load-balanced based on ECMP routing by using the four IPsec-VPN connections. This section describes how to test the network connectivity and how to check whether the four IPsec-VPN connections are used to load-balance the traffic.
- Test the network connectivity.
- Check whether traffic is load-balanced. Send requests to the ECS instance from multiple clients in the data center or use iPerf3 to send requests to the ECS instance. If you can view traffic monitoring data on the details pages of IPsec-VPN Connection 1, IPsec-VPN Connection 2, IPsec-VPN Connection 3, and IPsec-VPN Connection 4, traffic between the data center and the VPC is load-balanced through the four IPsec-VPN connections. For more information about how to install and use iPerf3, see Test the performance of an Express Connect circuit.
Routing configuration
In this topic, the default routing configuration is used to create the IPsec-VPN connections, VPC connection, VBR connections, and inter-region connection. When the default routing configuration is used, CEN automatically learns and distributes routes to enable the data center to communicate with the VPC. The following sections describe the default routing configuration.
IPsec-VPN connection
If you associate an IPsec-VPN connection with a transit router when you create the IPsec-VPN connection, the system automatically applies the following routing configuration to the IPsec-VPN connection:
- The IPsec-VPN connection is associated with the default route table of the transit router. The transit router forwards traffic from the IPsec-VPN connection based on the default route table.
- The destination-based routes that you configure for the IPsec-VPN connection and the routes learned from the data center through the IPsec-VPN connection by using BGP dynamic routing are automatically propagated to the default route table of the transit router.
- The transit router automatically propagates the routes in the default route table to the BGP route table associated with the IPsec-VPN connection.
- The routes learned from the VPC through the IPsec-VPN connection by using BGP dynamic routing are automatically propagated to the data center.
VPC connection
If you use the default routing configuration (with all advanced features enabled) when you create a VPC connection, the system automatically applies the following routing configuration to the VPC:
- Associate with Default Route Table of Transit Router
After this feature is enabled, the VPC connection is automatically associated with the default route table of the transit router. The transit router forwards the traffic of the VPC based on the default route table.
- Propagate System Routes to Default Route Table of Transit Router
After this feature is enabled, the system routes of the VPC are advertised to the default route table of the transit router. This way, the VPC can communicate with other network instances that are connected to the transit router.
- Automatically Creates Route That Points to Transit Router and Adds to All Route Tables of Current VPC
After this feature is enabled, the system automatically adds the following three routes to all route tables of the VPC: 10.0.0.0/8, 172.16.0.0/12, and 192.168.0.0/16. The routes point to the VPC connection.
VBR connection
If you use the default routing configuration (with all advanced features enabled) when you create a VBR connection, the system automatically applies the following routing configuration to the VBR:
- Associate with Default Route Table of Transit Router
After this feature is enabled, the VBR connection is automatically associated with the default route table of the transit router. The transit router forwards the traffic of the VBR based on the default route table.
- Propagate System Routes to Default Route Table of Transit Router
After this feature is enabled, the system routes of the VBR are automatically advertised to the default route table of the transit router.
- Propagate Routes to VBR
After this feature is enabled, the system automatically advertises the routes in the route table that is associated with the VBR connection to the VBR.
Inter-region connection
If you use the default routing configuration (with all advanced features enabled) when you create an inter-region connection, the system automatically applies the following routing configuration to the inter-region connection:
- Associate with Default Route Table of Transit Router
After this feature is enabled, the inter-region connection is automatically associated with the default route table of the transit router. The transit router uses the default route table to forward network traffic across regions.
- Propagate System Routes to Default Route Table of Transit Router
After this feature is enabled, the inter-region connection advertises system routes to the default route table of the transit router.
- Automatically Advertise Routes to Peer Region
After this feature is enabled, the routes of the transit router deployed in the current region are automatically advertised to the route table of the peer transit router. The routes are used for inter-region communication between network instances.
View routes
- For more information about routes of transit routers, see View routes of an Enterprise Edition transit router.
- For more information about routes of VPCs, see Create and manage a route table.
- For more information about routes of VBRs, perform the following steps:
- Log on to the Express Connect console.
- In the left-side navigation pane, click Virtual Border Routers (VBRs).
- In the top navigation bar, select the region where the VBR is deployed.
- On the Virtual Border Routers (VBRs) page, click the ID of the VBR that you want to manage.
On the details page of the VBR, view the custom routes, BGP routes, and CEN routes of the VBR on the Routes tab.
- To view the routes of an IPsec-VPN connection, go to the details page of the IPsec-VPN connection:
- Log on to the VPN Gateway console.
- In the top navigation bar, select the region in which the IPsec-VPN connection is created.
- In the left-side navigation pane, choose .
- On the IPsec Connections page, find the IPsec-VPN connection and click its ID.
Go to the details page of the IPsec-VPN connection and view the route entries on the BGP Route Table tab.