VPC Peering Connection Usage Examples
A VPC peering connection is a networking connection between two VPCs in the same region and enables them to communicate. Table 1 lists different scenarios of using VPC peering connections.
Location |
CIDR Block |
Description |
Usage Example |
---|---|---|---|
VPCs in the same region |
|
You can create VPC peering connections to connect entire CIDR blocks of VPCs. Then, all resources in the VPCs can communicate with each other. |
|
VPCs in the same region |
|
You can create VPC peering connections to connect specific subnets or ECSs from different VPCs.
|
|
VPCs in the same region |
|
VPC peering connections are not usable. |
Peering Two or More VPCs
- Two VPCs peered together: Figure 1 shows the networking diagram of a VPC peering connection that connects VPC-A and VPC-B.
Table 2 Peering relationships (IPv4) Peering Relationship
Peering Connection Name
Local VPC
Peer VPC
VPC-A is peered with VPC-B.
Peering-AB
VPC-A
VPC-B
Table 3 VPC route tables (IPv4) Route Table
Destination
Next Hop
Route Type
Description
rtb-VPC-A
10.0.0.0/16
Peering-AB
Custom
Add a route with the CIDR block of VPC-B as the destination and Peering-AB as the next hop.
rtb-VPC-B
172.16.0.0/16
Peering-AB
Custom
Add a route with the CIDR block of VPC-A as the destination and Peering-AB as the next hop.
- Multiple VPCs peered together: Figure 2 shows the networking diagram of VPC peering connections that connect VPC-A, VPC-B, and VPC-C.
Table 4 Peering relationships (IPv4) Peering Relationship
Peering Connection Name
Local VPC
Peer VPC
VPC-A is peered with VPC-B.
Peering-AB
VPC-A
VPC-B
VPC-A is peered with VPC-C.
Peering-AC
VPC-A
VPC-C
VPC-B is peered with VPC-C.
Peering-BC
VPC-B
VPC-C
Table 5 VPC route tables (IPv4) Route Table
Destination
Next Hop
Route Type
Description
rtb-VPC-A
10.0.0.0/16
Peering-AB
Custom
Add a route with the CIDR block of VPC-B as the destination and Peering-AB as the next hop.
192.168.0.0/16
Peering-AC
Custom
Add a route with the CIDR block of VPC-C as the destination and Peering-AC as the next hop.
rtb-VPC-B
172.16.0.0/16
Peering-AB
Custom
Add a route with the CIDR block of VPC-A as the destination and Peering-AB as the next hop.
192.168.0.0/16
Peering-BC
Custom
Add a route with the CIDR block of VPC-C as the destination and Peering-BC as the next hop.
rtb-VPC-C
172.16.0.0/16
Peering-AC
Custom
Add a route with the CIDR block of VPC-A as the destination and Peering-AC as the next hop.
10.0.0.0/16
Peering-BC
Custom
Add a route with the CIDR block of VPC-B as the destination and Peering-BC as the next hop.
Peering One Central VPC with Multiple VPCs
Figure 3 shows the networking diagram of VPC peering connections that connect VPC-B, VPC-C, VPC-D, VPC-E, VPC-F, VPC-G, and central VPC-A.
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
VPC-A is peered with VPC-B. |
Peering-AB |
VPC-A |
VPC-B |
VPC-A is peered with VPC-C. |
Peering-AC |
VPC-A |
VPC-C |
VPC-A is peered with VPC-D. |
Peering-AD |
VPC-A |
VPC-D |
VPC-A is peered with VPC-E. |
Peering-AE |
VPC-A |
VPC-E |
VPC-A is peered with VPC-F. |
Peering-AF |
VPC-A |
VPC-F |
VPC-A is peered with VPC-G. |
Peering-AG |
VPC-A |
VPC-G |
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A |
10.0.0.0/16 |
Peering-AB |
Custom |
Add a route with the CIDR block of VPC-B as the destination and Peering-AB as the next hop. |
192.168.0.0/16 |
Peering-AC |
Custom |
Add a route with the CIDR block of VPC-C as the destination and Peering-AC as the next hop. |
|
10.2.0.0/16 |
Peering-AD |
Custom |
Add a route with the CIDR block of VPC-D as the destination and Peering-AD as the next hop. |
|
10.3.0.0/16 |
Peering-AE |
Custom |
Add a route with the CIDR block of VPC-E as the destination and Peering-AE as the next hop. |
|
172.17.0.0/16 |
Peering-AF |
Custom |
Add a route with the CIDR block of VPC-F as the destination and Peering-AF as the next hop. |
|
10.4.0.0/16 |
Peering-AG |
Custom |
Add a route with the CIDR block of VPC-G as the destination and Peering-AG as the next hop. |
|
rtb-VPC-B |
172.16.0.0/16 |
Peering-AB |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AB as the next hop. |
rtb-VPC-C |
172.16.0.0/16 |
Peering-AC |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AC as the next hop. |
rtb-VPC-D |
172.16.0.0/16 |
Peering-AD |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AD as the next hop. |
rtb-VPC-E |
172.16.0.0/16 |
Peering-AE |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AE as the next hop. |
rtb-VPC-F |
172.16.0.0/16 |
Peering-AF |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AF as the next hop. |
rtb-VPC-G |
172.16.0.0/16 |
Peering-AG |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AG as the next hop. |
Peering Two VPCs with Overlapping CIDR Blocks
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
VPC-A is peered with VPC-B. |
Peering-AB |
VPC-A |
VPC-B |
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A |
10.0.2.0/24 |
Peering-AB |
Custom |
Add a route with the CIDR block of Subnet-B02 as the destination and Peering-AB as the next hop. |
rtb-VPC-B |
10.0.1.0/24 |
Peering-AB |
Custom |
Add a route with the CIDR block of Subnet-A02 as the destination and Peering-AB as the next hop. |
Peering ECSs in a Central VPC with ECSs in Two Other VPCs
- Use VPC peering connection Peering-AB to connect ECSs in Subnet-B01 and Subnet-A01.
- Use VPC peering connection Peering-AC to connect ECSs in Subnet-C01 and Subnet-A01.
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
ECS-A01-1 in VPC-A is peered with ECS-B01 in VPC-B. |
Peering-AB |
VPC-A |
VPC-B |
ECS-A01-2 in VPC-A is peered with ECS-C01 in VPC-C. |
Peering-AC |
VPC-A |
VPC-C |
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A |
10.0.0.139/32 |
Peering-AB |
Custom |
Add a route with the private IP address of ECS-B01 as the destination and Peering-AB as the next hop. |
10.0.0.71/32 |
Peering-AC |
Custom |
Add a route with the private IP address of ECS-C01 as the destination and Peering-AC as the next hop. |
|
rtb-VPC-B |
172.16.0.111/32 |
Peering-AB |
Custom |
Add a route with the private IP address of ECS-A01-1 as the destination and Peering-AB as the next hop. |
rtb-VPC-C |
172.16.0.218/32 |
Peering-AC |
Custom |
Add a route with the private IP address of ECS-A01-2 as the destination and Peering-AC as the next hop. |
Invalid VPC Peering Connections
If VPCs with the same CIDR block also include subnets that overlap, VPC peering connections are not usable. VPC-A and VPC-B have the same CIDR block and their subnets have the same CIDR block. If a VPC peering connection is created between VPC-A and VPC-B, traffic cannot be routed between them because there are routes with the same destination.
![](https://support.huaweicloud.com/eu/usermanual-vpc/en-us_image_0000001254335981.png)
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
10.0.1.0/24 |
Local |
System |
||
10.0.0.0/16 (VPC-B) |
Peering-AB |
Custom |
Add a route with the CIDR block of VPC-B as the destination and Peering-AB as the next hop. |
|
rtb-VPC-B |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
10.0.1.0/24 |
Local |
System |
||
10.0.0.0/16 (VPC-A) |
Peering-AB |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AB as the next hop. |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.