Add VPCs from different Alibaba Cloud accounts to the same CEN instance to enable cross-account network connectivity.
Scenario
Suppose you have two Alibaba Cloud accounts:
Account A: has two VPCs (
VPC1andVPC2) and one CEN (CEN1).Account B has a VPC (
VPC3).
VPC1 and VPC2 are already attached to CEN1 and can communicate with each other, as described in Communication between VPCs in the same region.
The goal is to attach VPC3 to CEN1 so all three VPCs can communicate.
Network plan for the three VPCs:
Parameter | VPC1 | VPC2 | VPC3 |
Account | Account A | Account A | Account B |
Region | China (Hangzhou) | China (Hangzhou) | China (Hangzhou) |
IPv4 CIDR block | 10.0.0.0/16 | 172.16.0.0/16 | 192.168.0.0/16 |
vSwitch 1 | In availability zone J, with CIDR block 10.0.0.0/24 | In availability zone J, with CIDR block 172.16.0.0/24 | In availability zone J, with CIDR block 192.168.0.0/24 |
vSwitch 2 | In availability zone K, with CIDR block 10.0.1.0/24 | In availability zone K, with CIDR block 172.16.1.0/24 | In availability zone K, with CIDR block 192.168.1.0/24 |
ECS instance IP | ECS1: 10.0.0.1 | ECS2: 172.16.0.1 | ECS3: 192.168.0.1 |
When planning your network:
VPC CIDR blocks must not overlap. If they do, migrate resources to VPCs with non-overlapping CIDR blocks.
For zone-level disaster recovery, create vSwitches in at least two availability zones.
The steps in this guide apply to any valid IPv4 CIDR block, including non-RFC 1918 ranges such as 8.x.x.x and 121.x.x.x. The example scenario uses 10.0.0.0/16, 172.16.0.0/16, and 192.168.0.0/16, but the procedure works regardless of which CIDR blocks your VPCs use. The only requirement is that the CIDR blocks of the VPCs you want to connect must not overlap.
Procedure
This is a two-step process:
Log on to Account B and grant Account A authorization to attach
VPC3toCEN1.Log on to Account A and attach
VPC3toCEN1.
Step 1: Grant authorization from Account B to Account A
Log on to the VPC console with Account B.
Click the instance ID of
VPC3, go to the Cross-account Authorization tab, and click Cross-account Authorization. Configure the following settings:Peer Account UID : Enter the ID of Account A (the main account).
Peer CEN Instance ID: Enter the instance ID of the CEN instance
CEN1to whichVPC1andVPC2in Account A are attached.Payer: For this tutorial, select the default, CEN Instance Owner.
CEN Instance Owner: Account A (the owner of the CEN instance) pays the attachment and data processing fees for connecting VPC3 to the transit router.
VPC Users: Account B (the owner of the VPC) pays the attachment and data processing fees for connecting VPC3 to the transit router.
Choose the payer carefully. Changing the payer later may affect your services.
Step 2: Attach VPC3 to CEN1 from Account A
Log on to the CEN console with Account A.
Click the instance ID of
CEN1, find the transit router for the China (Hangzhou) region, and in the Actions column, click Create Connection > Create Intra-Region Connection.On the Create Intra-Region Connection page, configure these settings:
Network Type: Select VPC.
Region: Select China (Hangzhou).
Account: Select Another Account, and enter the Alibaba Cloud account ID of Account B (
VPC3belongs to Account B).Attachment Name: Enter
attach3.Networks: Select the instance ID for
VPC3.If the dropdown is empty, cross-account authorization for
VPC3toCEN1is not configured. Verify that the Peer Account UID is Account A's ID and the Peer CEN Instance ID isCEN1's instance ID.VSwitch: The system automatically selects two vSwitches in
VPC3.The system automatically selects vSwitches from two availability zones for disaster recovery. If
VPC3has vSwitches in only one zone, create one in a different zone first.Advanced Settings: Keep the defaults. These settings are explained in How routing works.
Verify the connection
Ensure that the security group rules for all three ECS instances allow inbound ICMP traffic.
Log on to
ECS3in Account B and runpingto reachECS1:ping 10.0.0.1[root@iZbp xxx ~]# ping 10.0.0.1 PING 10.0.0.1 (10.0.0.1) 56(84) bytes of data. 64 bytes from 10.0.0.1: icmp_seq=1 ttl=63 time=0.580 ms 64 bytes from 10.0.0.1: icmp_seq=2 ttl=63 time=0.421 ms 64 bytes from 10.0.0.1: icmp_seq=3 ttl=63 time=0.281 ms 64 bytes from 10.0.0.1: icmp_seq=4 ttl=63 time=0.295 ms 64 bytes from 10.0.0.1: icmp_seq=5 ttl=63 time=0.296 ms 64 bytes from 10.0.0.1: icmp_seq=6 ttl=63 time=0.247 ms 64 bytes from 10.0.0.1: icmp_seq=7 ttl=63 time=0.269 msA successful ping confirms that
VPC3andVPC1can communicate. Runping 172.16.0.1to verify connectivity betweenVPC3andVPC2.
Routing
When the VPC attachment is created, the system automatically configures routing based on three advanced features enabled by default:
Three options are enabled by default: Associate with default route table of transit router (associates the VPC connection with the transit router's default route table), Propagate system routes to default route table of transit router (advertises VPC system routes to the transit router, enabling communication with other attached network instances), and Automatically create route that points to transit router and add to all route tables of current VPC (adds three routes — 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 — to all VPC route tables, with next hops pointing to the transit router; by default, transit routers do not advertise routes to VPCs). To customize routing, clear these checkboxes and configure route associations and propagation manually. See Route management.
For IPv6 traffic, after creating the VPC connection, enable route synchronization or manually add IPv6 route entries pointing to the VPC connection in the VPC.
TR default route table
Destination CIDR block | Next hop | Route type |
10.0.0.0/24 |
| Propagated |
10.0.1.0/24 |
| Propagated |
172.16.0.0/24 |
| Propagated |
172.16.1.0/24 |
| Propagated |
192.168.0.0/24 |
| Propagated |
192.168.1.0/24 |
| Propagated |
VPC1 system route table
Destination CIDR block | Next hop | Route type |
10.0.0.0/24 | Local | System |
10.0.1.0/24 | Local | System |
10.0.0.0/8 |
| Custom |
172.16.0.0/12 |
| Custom |
192.168.0.0/16 |
| Custom |
VPC2 system route table
Destination CIDR block | Next hop | Route type |
172.16.0.0/24 | Local | System |
172.16.1.0/24 | Local | System |
10.0.0.0/8 |
| Custom |
172.16.0.0/12 |
| Custom |
192.168.0.0/16 |
| Custom |
VPC3 system route table
Destination CIDR block | Next hop | Route type |
192.168.0.0/24 | Local | System |
192.168.1.0/24 | Local | System |
10.0.0.0/8 |
| Custom |
172.16.0.0/12 |
| Custom |
192.168.0.0/16 |
| Custom |
FAQ
Connecting cross-region and cross-account VPCs
The process is similar to Connect VPCs across regions, except the VPCs belong to different accounts. Complete cross-account authorization (Step 1) before creating the attachment.
Partial connectivity and network isolation
Use multiple transit router route tables to isolate VPC1 and VPC2 while allowing both to communicate with VPC3. Isolate VPCs and enable access to shared services.