Using a VPC Peering Connection to Connect Subnets in Two VPCs
Scenario |
Scenario Description |
IP Address Version |
Example |
---|---|---|---|
Two VPCs peered to two subnets in a central VPC |
You have a central VPC that requires access to the multiple other VPCs. The other VPCs need to be isolated from each other.
|
IPv4 |
|
IPv6/IPv4 |
|||
One central VPC peered to specific subnets in two VPCs |
You have a central VPC that requires access to two other VPCs. The other VPCs need to be isolated from each other.
|
IPv4 |
One Central VPC Peered to Specific Subnets in Two VPCs (IPv4) |
One central VPC peered to overlapping subnets from two VPCs |
This scenario is similar to the preceding one. If two VPCs with overlapping subnets need to peer with the central VPC, traffic may fail to be forwarded to the required destination. To prevent this, plan the network according to this example. |
IPv4 |
One Central VPC Peered to Overlapping Subnets from Two VPCs (IPv4) |
Two VPCs Peered to Two Subnets in a Central VPC (IPv4)
VPC Name |
VPC CIDR Block |
Subnet Name |
Subnet CIDR Block |
VPC Route Table |
ECS Name |
Security Group |
Private IP Address |
---|---|---|---|---|---|---|---|
VPC-A |
172.16.0.0/16 |
Subnet-A01 |
172.16.0.0/24 |
rtb-VPC-A01 |
ECS-A01 |
sg-web: general-purpose web server |
172.16.0.111 |
Subnet-A02 |
172.16.1.0/24 |
rtb-VPC-A02 |
ECS-A02 |
172.16.1.91 |
|||
VPC-B |
10.0.0.0/16 |
Subnet-B01 |
10.0.0.0/24 |
rtb-VPC-B |
ECS-B01 |
10.0.0.139 |
|
VPC-C |
10.0.0.0/16 |
Subnet-C01 |
10.0.0.0/24 |
rtb-VPC-C |
ECS-C01 |
10.0.0.71 |
VPC-A has two route tables. Route table rtb-VPC-A01 is associated with Subnet-A01, and route table rtb-VPC-A02 is associated with Subnet-A02. The two subnets can communicate with each other.
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
Subnet-A01 of VPC-A is peered to VPC-B. |
Peering-AB |
VPC-A |
VPC-B |
Subnet-A02 of VPC-A is peered to VPC-C. |
Peering-AC |
VPC-A |
VPC-C |
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A01 |
172.16.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
172.16.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-A02 |
172.16.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
172.16.1.0/24 |
Local |
System |
||
10.0.0.0/16 (VPC-C) |
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 |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
172.16.0.0/24 (Subnet-A01) |
Peering-AB |
Custom |
Add a route with the CIDR block of Subnet-A01 as the destination and Peering-AB as the next hop. |
|
rtb-VPC-C |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
172.16.1.0/24 (Subnet-A02) |
Peering-AC |
Custom |
Add a route with the CIDR block of Subnet-A02 as the destination and Peering-AC as the next hop. |
Two VPCs Peered to Two Subnets in a Central VPC (IPv6/IPv4)
VPC Name |
VPC CIDR Block |
Subnet Name |
Subnet CIDR Block |
VPC Route Table |
ECS Name |
Security Group |
Private IP Address |
---|---|---|---|---|---|---|---|
VPC-A |
172.16.0.0/16 |
Subnet-A01 |
|
rtb-VPC-A01 |
ECS-A01 |
sg-web: general-purpose web server |
|
Subnet-A02 |
172.16.1.0/24 |
rtb-VPC-A02 |
ECS-A02 |
172.16.1.91 |
|||
VPC-B |
10.0.0.0/16 |
Subnet-B01 |
|
rtb-VPC-B |
ECS-B01 |
|
|
VPC-C |
10.0.0.0/16 |
Subnet-C01 |
10.0.0.0/24 |
rtb-VPC-C |
ECS-C01 |
10.0.0.71 |
VPC-A has two route tables. Route table rtb-VPC-A01 is associated with Subnet-A01, and route table rtb-VPC-A02 is associated with Subnet-A02. The two subnets can communicate with each other.
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
Subnet-A01 of VPC-A is peered to VPC-B. (IPv6) |
Peering-AB |
VPC-A |
VPC-B |
Subnet-A02 of VPC-A is peered to VPC-C. (IPv4) |
Peering-AC |
VPC-A |
VPC-C |
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A01 |
172.16.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
2407:c080:802:c34::/64 |
Local |
System |
||
172.16.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 for IPv4 communication. |
|
2407:c080:802:c35::/64 (Subnet-B01) |
Peering-AB |
Custom |
Add a route with the IPv6 CIDR block of Subnet-B01 as the destination and Peering-AB as the next hop for IPv6 communication. |
|
rtb-VPC-A02 |
172.16.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
2407:c080:802:c34::/64 |
Local |
System |
||
172.16.1.0/24 |
Local |
System |
||
10.0.0.0/16 (VPC-C) |
Peering-AC |
Custom |
Add a route with the CIDR block of VPC-C as the destination and Peering-AC as the next hop for IPv4 communication. |
|
rtb-VPC-B |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
2407:c080:802:c35::/64 |
Local |
System |
||
172.16.0.0/24 (Subnet-A01) |
Peering-AB |
Custom |
Add a route with the CIDR block of Subnet-A01 as the destination and Peering-AB as the next hop for IPv4 communication. |
|
2407:c080:802:c34::/64 (Subnet-A01) |
Peering-AB |
Custom |
Add a route with the IPv6 CIDR block of Subnet-A01 as the destination and Peering-AB as the next hop for IPv6 communication. |
|
rtb-VPC-C |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
172.16.1.0/24 (Subnet-A02) |
Peering-AC |
Custom |
Add a route with the CIDR block of Subnet-A02 as the destination and Peering-AC as the next hop for IPv4 communication. |
One Central VPC Peered to Specific Subnets in Two VPCs (IPv4)
VPC Name |
VPC CIDR Block |
Subnet Name |
Subnet CIDR Block |
VPC Route Table |
ECS Name |
Security Group |
Private IP Address |
---|---|---|---|---|---|---|---|
VPC-A |
172.16.0.0/16 |
Subnet-A01 |
172.16.0.0/24 |
rtb-VPC-A |
ECS-A01 |
sg-web: general-purpose web server |
172.16.0.111 |
VPC-B |
10.0.0.0/16 |
Subnet-B01 |
10.0.0.0/24 |
rtb-VPC-B |
ECS-B01 |
10.0.0.139 |
|
Subnet-B02 |
10.0.1.0/24 |
rtb-VPC-B |
ECS-B02 |
10.0.1.167 |
|||
VPC-C |
10.0.0.0/16 |
Subnet-C01 |
10.0.0.0/24 |
rtb-VPC-C |
ECS-C01 |
10.0.0.71 |
|
Subnet-C02 |
10.0.1.0/24 |
rtb-VPC-C |
ECS-C02 |
10.0.1.116 |
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
VPC-A is peered to Subnet-B01 of VPC-B. |
Peering-AB |
VPC-A |
VPC-B |
VPC-A is peered to Subnet-C02 of VPC-C. |
Peering-AC |
VPC-A |
VPC-C |
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A |
172.16.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
10.0.0.0/24 (Subnet-B01) |
Peering-AB |
Custom |
Add a route with the CIDR block of Subnet-B01 as the destination and Peering-AB as the next hop. |
|
10.0.1.0/24 (Subnet-C02) |
Peering-AC |
Custom |
Add a route with the CIDR block of Subnet-C02 as the destination and Peering-AC 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 |
||
172.16.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. |
|
rtb-VPC-C |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
10.0.1.0/24 |
Local |
System |
||
172.16.0.0/16 (VPC-A) |
Peering-AC |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AC as the next hop. |
One Central VPC Peered to Overlapping Subnets from Two VPCs (IPv4)
If you want to create VPC peering connections between a VPC and multiple overlapping subnets from different VPCs, ensure that the destinations of the routes added for the peering connections do not conflict and traffic can be correctly forwarded.
VPC Name |
VPC CIDR Block |
Subnet Name |
Subnet CIDR Block |
VPC Route Table |
ECS Name |
Security Group |
Private IP Address |
---|---|---|---|---|---|---|---|
VPC-A |
172.16.0.0/16 |
Subnet-A01 |
172.16.0.0/24 |
rtb-VPC-A |
ECS-A01 |
sg-web: general-purpose web server |
172.16.0.111 |
VPC-B |
10.0.0.0/16 |
Subnet-B01 |
10.0.0.0/24 |
rtb-VPC-B |
ECS-B01 |
10.0.0.139 |
|
Subnet-B02 |
10.0.1.0/24 |
rtb-VPC-B |
ECS-B02 |
10.0.1.167 |
|||
VPC-C |
10.0.0.0/16 |
Subnet-C01 |
10.0.0.0/24 |
rtb-VPC-C |
ECS-C01 |
10.0.0.71 |
|
Subnet-C02 |
10.0.1.0/24 |
rtb-VPC-C |
ECS-C02 |
10.0.1.167 |
Peering Relationship |
Peering Connection Name |
Local VPC |
Peer VPC |
---|---|---|---|
VPC-A is peered to Subnet-B02 of VPC-B. |
Peering-AB |
VPC-A |
VPC-B |
VPC-A is peered to Subnet-C02 of VPC-C. |
Peering-AC |
VPC-A |
VPC-C |
- ECS-B02 in Subnet-B02 of VPC-B sends request traffic to VPC-A through the route with Peering-AB as the next hop in the rtb-VPC-B route table.
- VPC-A receives the request traffic from ECS-B02 and expects to send the response traffic to ECS-B02. The rtb-VPC-A route table has the route with 10.0.1.167/32 as the destination, but its next hop is Peering-AC. The response traffic is incorrectly sent to VPC-C.
- ECS-C02 in Subnet-C02 of VPC-C has the same private IP address (10.0.1.167/32) as ECS-B02. The response traffic is incorrectly sent to ECS-C02, and ECS-B02 cannot receive the response traffic.
Route Table |
Destination |
Next Hop |
Route Type |
Description |
---|---|---|---|---|
rtb-VPC-A |
172.16.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
10.0.1.0/24 (Subnet-C02) |
Peering-AC |
Custom |
Add a route with the CIDR block of Subnet-C02 as the destination and Peering-AC 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 |
||
172.16.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. |
|
rtb-VPC-C |
10.0.0.0/24 |
Local |
System |
Local routes are automatically added for communications within a VPC. |
10.0.1.0/24 |
Local |
System |
||
172.16.0.0/16 (VPC-A) |
Peering-AC |
Custom |
Add a route with the CIDR block of VPC-A as the destination and Peering-AC as the next hop. |
- Suggestion 1: In the rtb-VPC-A route table, add a route with Peering-AB as the next hop and the private IP address of ECS-B02 (10.0.1.167/32) as the destination. The route with 10.0.1.167/32 as the destination is preferentially matched based on the longest prefix match rule to ensure that VPC-A sends the response traffic to ECS-B02. For more configurations, see Using a VPC Peering Connection to Connect ECSs in Two VPCs.
Table 14 VPC route table details Route Table
Destination
Next Hop
Route Type
Description
rtb-VPC-A
172.16.0.0/24
Local
System
Local routes are automatically added for communications within a VPC.
10.0.1.167/32 (ECS-B02)
Peering-AB
Custom
Add a route with the private IP address of ECS-B02 as the destination and Peering-AB as the next hop.
10.0.1.0/24 (Subnet-C02)
Peering-AC
Custom
Add a route with the CIDR block of Subnet-C02 as the destination and Peering-AC as the next hop.
- Suggestion 2: In the rtb-VPC-A route table, change the destination of the route with Peering-AC as the next hop from Subnet-C02 to Subnet-C01. Add a route with Peering-AB as the next hop and Subnet-B02 as the destination to ensure that VPC-A can send the response traffic to Subnet-B02 in VPC-B.
Table 15 VPC route table details Route Table
Destination
Next Hop
Route Type
Description
rtb-VPC-A
172.16.0.0/24
Local
System
Local routes are automatically added for communications within a VPC.
10.0.1.0/24 (Subnet-B02)
Peering-AB
Custom
Add a route with the CIDR block of Subnet-B02 as the destination and Peering-AB as the next hop.
10.0.0.0/24 (Subnet-C01)
Peering-AC
Custom
Add a route with the CIDR block of Subnet-C01 as the destination and Peering-AC 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.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot