Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Situation Awareness
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive

VPC Peering Connection Usage Examples

Updated on 2024-03-05 GMT+08:00

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.

Table 1 VPC peering connection usage examples

Location

CIDR Block

Description

Usage Example

VPCs in the same region

  • VPC CIDR blocks do not overlap.
  • Subnet CIDR blocks of VPCs do not overlap.

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

  • VPC CIDR blocks overlap.
  • Some subnet CIDR blocks overlap.

You can create VPC peering connections to connect specific subnets or ECSs from different VPCs.

  • To connect specific subnets from two VPCs, the subnet CIDR blocks cannot overlap.
  • To connect specific ECSs from two VPCs, each ECS must have a unique private IP address.

VPCs in the same region

  • VPC CIDR blocks overlap.
  • All subnet CIDR blocks overlap.

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.
    Figure 1 Networking diagram (IPv4)
    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.
    Figure 2 Networking diagram (IPv4)
    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.

Figure 3 Networking diagram (IPv4)
Table 6 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-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

Table 7 VPC route table details (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.

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

As shown in Figure 4, VPC-A and VPC-B have overlapping CIDR blocks, and their Subnet-A01 and Subnet-B01 also have overlapping CIDR blocks. In this case, a VPC peering connection can connect their Subnet-A02 and Subnet-B02 that do not overlap with each other.
Figure 4 Networking diagram (IPv4)
Table 8 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 9 VPC route table details (IPv4)

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

As shown in Figure 5, VPC-B and VPC-C have overlapping CIDR blocks, and their Subnet-B01 and Subnet-C01 have overlapping CIDR blocks. You can only create a VPC peering connection between ECSs.
  • 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.
Figure 5 Networking diagram (IPv4)
Table 10 Peering relationships (IPv4)

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

Table 11 VPC route table details (IPv4)

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.

In the rtb-VPC-A route table, the custom route for routing traffic from VPC-A to VPC-B and the local route have overlapping destinations. The local route has a higher priority and traffic will be forwarded within VPC-A and cannot reach VPC-B.
Figure 6 Networking diagram (IPv4)
Table 12 VPC route table details

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.

We use cookies to improve our site and your experience. By continuing to browse our site you accept our cookie policy. Find out more

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback