This topic describes how to add Elastic Compute Service (ECS) instances in a virtual private cloud (VPC) to an Application Load Balancer (ALB) instance in a different region. To add ECS instances in a VPC to an ALB instance in a different region, you must use transit routers of Cloud Enterprise Network (CEN). Transit routers are used to route network traffic from the ALB instance to the ECS instances.
Scenario
The example in this topic is based on the following scenario. A company created a VPC (VPC1) in the China (Chengdu) region and deployed an ALB instance in VPC1. The company created a VPC (VPC2) in the China (Hangzhou) region and created ECS instances in VPC2. The company wants to add the ECS instances in VPC2 to the ALB instance in VPC1.
To achieve this goal, the company uses a CEN instance and attaches both VPCs to it. This effectively allows the ECS instances in VPC2 to function as the backend servers of the ALB instance in VPC1.

Precautions
- If you want to add ECS instances to an ALB instance in a different region, you must first add the ECS instances to a server group of the IP type.
- The following table lists the regions where you can specify ECS instances in another region as backend servers of ALB.
Area Region China China (Chengdu), China (Qingdao), China (Beijing), China (Guangzhou), China (Hangzhou), China (Ulanqab), China (Shanghai), China (Shenzhen), China (Zhangjiakou), and China (Hong Kong) Asia Pacific Indonesia (Jakarta), Japan (Tokyo), Malaysia (Kuala Lumpur), Australia (Sydney), Singapore, and India (Mumbai) Europe and Americas Germany (Frankfurt), UK (London), US (Virginia), and US (Silicon Valley) - VPC1 and VPC2 must be attached to the same CEN instance.
- When you associate Enterprise Edition transit routers with the VPCs, elastic network interfaces (ENIs) are automatically created. Then, the ENIs are attached to the vSwitch in each zone. The ENIs are used to forward network traffic from the VPCs to the Enterprise Edition transit routers. When you create the VPCs, you must specify at least one vSwitch in each zone of the Enterprise Edition transit routers. This way, network traffic can be routed from the VPCs to the transit routers. For more information, see Regions and zones that support Enterprise Edition transit routers.
- You can add only internal-facing servers and cannot add Internet-facing servers.
- You cannot add ALB or CLB instances that reside in the same VPC.
- Enterprise edition transit routers support cross-region data forwarding. Basic edition transit routers do not support cross-region data forwarding.
- Each region in a network managed by a CEN instance can have only one VPC in which one or more ALB instances can add backend servers across regions.
- You cannot enable ALB instances in multiple VPCs in the same region to use the same transit router to access backend servers in the VPCs across regions.
- You cannot enable ALB instances in multiple VPCs in the same region to use multiple transit routers to access backend servers in the same VPC across regions.
- You cannot enable ALB instances in multiple VPCs in the same region to use the same transit router to access backend servers in the VPCs across regions.
- Network traffic between an ALB instance and its backend servers can be routed based only on the system route table. VPC custom route tables are not supported.
Prerequisites
- A VPC (VPC1) is created in the China (Chengdu) region. Another VPC (VPC2) is created in the China (Hangzhou) region.
- Two vSwitches (VSW1 and VSW2) are created in VPC1. VSW1 is deployed in Zone A and VSW2 is deployed in Zone B.
- Two vSwitches (VSW3 and VSW4) are created in VPC2. VSW3 is deployed in Zone H and VSW4 is deployed in Zone I.
- ECS instances are created in VPC1 to send connection requests. An ECS instance named ECS1 is created in VPC2 and an application is deployed on ECS1 to receive connection requests. For more information, see Create an instance by using the wizard.
- An ALB instance is created in VPC1. For more information, see Create an ALB instance.
- A CEN instance is created and a bandwidth plan is associated with the CEN instance. For more information, see Create a CEN instance and Work with a bandwidth plan.
- A transit router is deployed in the China (Chengdu) region. Another transit router is deployed in the China (Hangzhou) region. For more information, see Create a transit router.
The following table describes how networks are planned. You can plan the CIDR blocks based on your business requirements. Make sure that the CIDR blocks do not overlap with each other.
Region | VPC | vSwitch | Zone | CIDR block |
---|---|---|---|---|
China (Chengdu) | VPC1 Primary CIDR block: 172.16.0.0/12 | VSW1 | Zone A | 172.16.0.0/24 |
VSW2 | Zone B | 172.16.6.0/24 | ||
China (Hangzhou) | VPC2 Primary CIDR block: 192.168.0.0/16 | VSW3 | Zone H | 192.168.8.0/24 |
VSW4 | Zone I | 192.168.7.0/24 |
Procedure

Step 1: Create a server group for the ALB instance
Create a server group of the IP type. Then, add the IP addresses of the ECS instances that you want to specify as backend servers to the server group.
- Log on to the ALB console.
- In the top navigation bar, select the region where the ALB instance is deployed. In this example, China (Chengdu) is selected.
- In the left-side navigation pane, choose .
- On the Server Groups page, click Create Server Group, set the following parameters, and then click Create.
Parameter Description Server Group Type Select the type of server group that you want to create. In this example, IP is selected. Server Group Name Enter a name for the server group. VPC Select a VPC from the drop-down list. In this example, VPC1 is selected. Backend Server Protocol Select a backend protocol. HTTP is selected in this example. Scheduling Algorithm Select a scheduling algorithm. In this example, the default value Weighted Round-robin is used. Resource Group Select the resource group to which the server group belongs. Session Persistence Specify whether to enable or disable session persistence. In this example, session persistence is disabled. Configure Health Check Specify whether to enable the health check feature. In this example, health checks are enabled. Advanced Settings In this example, the default advanced settings are used. For more information, see Create and manage a server group. - On the Server Groups page, find the server group that you want to manage and click Modify Backend Server in the Actions column.
- On the Backend Servers tab, click Add IP Address.
- In the Add Backend Server panel, enter the private IP address of ECS1, turn on Remote IP Address, and then click Next.
- Specify the port and weight of the IP address and click OK. In this example, the port is set to 80 and the default weight is used.
Step 2: Configure a listener for the ALB instance
- Log on to the ALB console.
- In the top navigation bar, select the region where the ALB instance is deployed. In this example, China (Chengdu) is selected.
- On the Instances page, find the ALB instance that is deployed in VPC1 and click Create Listener in the Actions column.
- In the Configure Listener step, set the following parameters and click Next.
Parameter Description Listener Protocol Select a listening protocol. HTTP is selected in this example. Listener Port Specify the port on which the ALB instance listens. The ALB instance listens for requests on the specified port and then forwards the requests to backend servers. Valid values: 1 to 65535. In this example, 80 is specified. Listener Name Specify a name for the listener. Advanced Settings In this example, the default advanced settings are used. - On the Select Server Group wizard page, select IP from the Server Group drop-down list, select the server group created in Step 1, and then click Next.
- On the Confirm wizard page, confirm the configurations and click Submit.
Step 3: Attach the VPCs to the CEN instance
- Log on to the CEN console.
- On the Instances page of the CEN console, click the ID of the CEN instance that you want to manage.
- On the Create Connection in the Actions column. tab, find the transit router that you want to manage and click
- On the Connection with Peer Network Instance page, set the following parameters and click OK.
Parameter Description Network Type In this example, VPC is selected. Region Select the region where the network instance is created. In this example, China (Chengdu) is selected. Transit Router The transit router in the selected region is selected by default. Resource Owner ID Specify whether the network instance belongs to the current or another account. In this example, Your Account is selected.
Billing Method In this example, Pay-As-You-Go is selected. Attachment Name Enter a name for the connection. Network Instance Select the ID of the VPC that you want to connect. In this example, VPC1 is selected. VSwitch Select vSwitches that are deployed in zones supported by Enterprise Edition transit routers. In this example, VSW1 and VSW2 are selected. Advanced Settings The advanced features are selected by default. In this example, the default advanced settings are used.
- After you attach VPC1 to the CEN instance, click Create More Connections and repeat Substep 4 of Step 3: Attach the VPCs to the CEN instance to attach VPC2 to the CEN instance. In this example, the following configurations are used. The default settings are kept for parameters that are not described in this section.
- Region is set to China (Hangzhou).
- VPC2 is selected for Networks.
- VSwitch is set to VSW3 in Hangzhou Zone H and VSW4 in Hangzhou Zone I.
Step 4: Create an inter-region connection
- Log on to the CEN console.
- On the Instances page, click the ID of the CEN instance that you want to manage.
- On the Create Connection in the Actions column. tab, find the transit router that you want to manage and click You can choose the transit router that is associated with VPC1 or the transit router that is associated with VPC2. In this example, the transit router associated with VPC1 is used.
- On the Connection with Peer Network Instance page, set the following parameters and click OK.
Parameter Description Network Type Select Inter-region Connection. Region Select one of the regions to be connected. In this example, China (Chengdu) is selected. Transit Router Select the transit router deployed in the selected region. Attachment Name Specify a name for the inter-region connection. Peer Region Select the other region to be connected. China (Hangzhou) is selected in this example. Bandwidth Allocation Mode In this example, Allocate from Bandwidth Plan is selected. Bandwidth Plan Select a bandwidth plan that is associated with the CEN instance. Bandwidth Specify a valid bandwidth value. Unit: Mbit/s. Advanced Settings In this example, the default advanced settings are used.
Step 5: Add routes to the system route table of VPC1
- Log on to the VPC console.
- On the VPCs page, click the ID of VPC1.
- On the details page, click the Resources tab and then click the number below Route Table.
- On the Route Tables page, find the route table whose Route Table Type is System and click its ID.
- On the details page of the route table, choose Add Route Entry. , and click
- In the Add Route Entry panel, set the following parameters and click OK.
Parameter Description Name Enter a name for the route. Destination CIDR Block Enter the CIDR block that you want to access. In this example, the CIDR block of ECS1 is entered, which is 192.168.7.0/24. Next Hop Type Select the type of the next hop. Transit Router is selected in this example. Transit Router Select a transit router. In this example, the VPC1 connection is selected.
Step 6: Configure back-to-origin routes
View the back-to-origin route of the ALB instance. Add the back-to-origin route to the system route table of VPC2 and the route table of the transit router that is associated with VPC1.
- Perform the following operations to view the back-to-origin route of an ALB instance:
- Log on to the ALB console.
- In the top navigation bar, select the region where the ALB instance is deployed. In this example, China (Chengdu) is selected.
- On the Instances page, click the ID of the ALB instance in VPC1.
- On the Instance Details tab, click View next to Back-to-origin Route.
- Perform the following operations to add the back-to-origin route of ALB to the system route table of VPC2:
- Perform the following operations to add the back-to-origin route of ALB to the transit router associated with VPC1:
Step 7: Check the security group rules of the ECS instances
Packets are sent from the CIDR block of the back-to-origin route to the ECS instances. Make sure that the security group rules of the ECS instances allow access from the CIDR block. In the example in this topic, you need to add inbound rules to the security group of the ECS instance to allow access from the back-to-origin CIDR block (100.64.0.0/10) of ALB. Otherwise, the access to backend services across regions fails. For more information, see Add a security group rule
Step 8: Test network connectivity
- Log on to the ECS instance that is deployed in VPC1. For more information, see Guidelines on ECS instance connection.
- Run the
wget http://domain name of the ALB instance
command to check whether the ECS instance in VPC1 can access ECS1 in VPC2 through the ALB instance.You can view the domain name of the ALB instance on the details page of the ALB instance.The command used in this example is:
If you can receive echo reply packets, the connection is established, as shown in the following figure.wget http://alb-fo89znps6q********.internal.cn-chengdu.alb.aliyuncs.com