If two VPCs from the same region cannot communicate with each other, you can use a VPC peering connection. This section describes how to create a VPC peering connection between two VPCs in different accounts.
This following describes how to create a VPC peering connection between VPC-A in account A and VPC-B in account B to enable communications between ECS-A01 and RDS-B01.
Procedure:
Step 1: Create a VPC Peering Connection
Step 2: Peer Account Accepts the VPC Peering Connection Request
Step 3: Add Routes for the VPC Peering Connection
Step 4: Verify Network Connectivity

You have two VPCs in the same region, but they are from different accounts. If you want to create one, see Creating a VPC with a Subnet.
in the upper left corner and select the desired region and project.
in the upper left corner and choose Network > Virtual Private Cloud.The Virtual Private Cloud page is displayed.
The VPC peering connection list is displayed.
The Create VPC Peering Connection dialog box is displayed.
For details, see Table 1.

Parameter |
Description |
Example Value |
|---|---|---|
VPC Peering Connection Name |
Mandatory Enter a name for the VPC peering connection. The name can contain a maximum of 64 characters, including letters, digits, hyphens (-), and underscores (_). |
peering-AB |
Local VPC |
Mandatory VPC at one end of the VPC peering connection. You can select one from the drop-down list. |
VPC-A |
Local VPC CIDR Block |
CIDR block of the selected local VPC |
172.16.0.0/16 |
Account |
Mandatory
|
Another account |
Peer Project ID |
This parameter is mandatory because Account is set to Another account. The project ID of the region that the peer VPC resides. For details about how to obtain the project ID, see Obtaining the Peer Project ID of a VPC Peering Connection. |
Project ID of VPC-B in region A: 067cf8aecf3XXX08322f13b |
Peer VPC ID |
This parameter is mandatory because Account is set to Another account. ID of the VPC at the other end of the VPC peering connection. For details about how to obtain the ID, see Obtaining a VPC ID. |
VPC-B ID: 17cd7278-XXX-530c952dcf35 |
Description |
Optional Enter the description of the VPC peering connection in the text box as required. The description can contain a maximum of 255 characters and cannot contain angle brackets (< or >). |
peering-AB connects VPC-A and VPC-B. |
After you create a VPC peering connection with a VPC in another account, you need to contact the peer account to accept the VPC peering connection request. In this example, account A notifies account B to accept the request. Account B needs to:
in the upper left corner and choose Network > Virtual Private Cloud.The Virtual Private Cloud page is displayed.
The VPC peering connection list is displayed.

After the status of the VPC peering connection changes to Accepted, the VPC peering connection is created.
To enable communications between VPCs connected by a VPC peering connection, you need to add forward and return routes to the route tables of the VPCs. For details, see VPC Peering Connection Usage Examples.
Both accounts need to add a route to the route table of their VPC. In this example, account A adds a route to the route table of VPC-A, and account B adds a route to the route table of VPC-B.
The page showing the VPC peering connection details is displayed.
The Add Route dialog box is displayed.

Table 2 describes the parameters.
Parameter |
Description |
Example Value |
|---|---|---|
VPC |
The default value is the VPC connected by the VPC peering connection in the current account. You do not need to select a VPC. |
VPC-A |
Route Table |
Select the route table of the VPC. The route will be added to this route table. Each VPC comes with a default route table to control the outbound traffic from the subnets in the VPC. In addition to the default route table, you can also create a custom route table and associate it with the subnets in the VPC. Then, the custom route table controls outbound traffic of the subnets.
|
rtb-VPC-A (Default route table) |
Destination |
An IP address or address range in the other VPC connected by the VPC peering connection. The value can be a VPC CIDR block, subnet CIDR block, or ECS IP address. For details about the route configuration example, see VPC Peering Connection Usage Examples. |
VPC-B CIDR block: 172.17.0.0/16 |
Next Hop |
The default value is the current VPC peering connection. You do not need to specify this parameter. |
peering-AB |
Description |
Supplementary information about the route. This parameter is optional. The description can contain a maximum of 255 characters and cannot contain angle brackets (< or >). |
Route from VPC-A to VPC-B |
You can view the routes in the route list.
The page showing the VPC peering connection details is displayed.
The Add Route dialog box is displayed.

Table 3 describes the parameters.
Parameter |
Description |
Example Value |
|---|---|---|
VPC |
The default value is the VPC connected by the VPC peering connection in the current account. You do not need to select a VPC. |
VPC-B |
Route Table |
Select the route table of the VPC. The route will be added to this route table. Each VPC comes with a default route table to control the outbound traffic from the subnets in the VPC. In addition to the default route table, you can also create a custom route table and associate it with the subnets in the VPC. Then, the custom route table controls outbound traffic of the subnets.
|
rtb-VPC-B (Default route table) |
Destination |
An IP address or address range in the other VPC connected by the VPC peering connection. The value can be a VPC CIDR block, subnet CIDR block, or ECS IP address. For details about the route configuration example, see VPC Peering Connection Usage Examples. |
VPC-A CIDR block: 172.16.0.0/16 |
Next Hop |
The default value is the current VPC peering connection. You do not need to specify this parameter. |
peering-AB |
Description |
Supplementary information about the route. This parameter is optional. The description can contain a maximum of 255 characters and cannot contain angle brackets (< or >). |
Route from VPC-B to VPC-A. |
You can view the route in the route list.
Run the following commands:
ping 172.17.0.21
[root@ecs-A02 ~]# ping 172.17.0.21 PING 172.17.0.21 (172.17.0.21) 56(84) bytes of data. 64 bytes from 172.17.0.21: icmp_seq=1 ttl=64 time=0.849 ms 64 bytes from 172.17.0.21: icmp_seq=2 ttl=64 time=0.455 ms 64 bytes from 172.17.0.21: icmp_seq=3 ttl=64 time=0.385 ms 64 bytes from 172.17.0.21: icmp_seq=4 ttl=64 time=0.372 ms ... --- 172.17.0.21 ping statistics ---