Creating a VPC Peering Connection with Another VPC in Your Account
Scenarios
To create a VPC peering connection, first create a request to peer with another VPC. You can request a VPC peering connection with another VPC in your account, but the two VPCs must be in the same region. The system automatically accepts the request.
This section describes how to create a VPC peering connection between two VPCs (VPC-01 and VPC-02) that are in the same account.
Assume that the CIDR block of VPC-01 is 192.168.10.0/24 and that of VPC-02 is 192.168.2.0/24.
The following figure shows the routes of the VPC peering connection.
Procedure
If you create a VPC peering connection between two VPCs in your account, the system automatically accepts the connection by default. You need to add routes for the local and peer VPCs to enable communication between the two VPCs.
The entry to visit the route table module varies by region.
- If the route table module is not decoupled from the VPC module in your selected region, you have to visit the route table module by clicking the Route Tables tab on the VPC details page.
- If the route table module is decoupled from the VPC module in your selected region, you can visit the route table module directly after you click Route Tables on the navigation pane of the VPC console.
If you have to visit the route table module through the VPC details page in your region, see Adding Routes for a VPC Peering Connection (Route Table Module Can Be Accessed Through the VPC Details Page).
If you can visit the route table module directly from the navigation pane on the VPC console in your region, see Adding Routes for a VPC Peering Connection (Route Table Module Can Be Directly Accessed from the Navigation Pane).
Prerequisites
Two VPCs in the same region have been created.
Creating a VPC Peering Connection
- Log in to the management console.
- Click
in the upper left corner and select the desired region and project. - On the console homepage, under Network, click Virtual Private Cloud.
- In the navigation pane on the left, click VPC Peering.
- In the right pane displayed, click Create VPC Peering Connection.
- Configure parameters as prompted. You must select My account for Account. Table 1 lists the parameters to be configured. Figure 3 Create VPC Peering Connection
Table 1 Parameter descriptions Parameter
Description
Example Value
Name
Specifies the name of the VPC peering connection.
The name contains a maximum of 64 characters, which consist of letters, digits, hyphens (-), and underscores (_).
peering-001
Local VPC
Specifies the local VPC. You can select one from the drop-down list.
vpc_01
Local VPC CIDR Block
Specifies the CIDR block for the local VPC.
192.168.10.0/24
Account
Specifies the account to which the peer VPC belongs.
- My account: The VPC peering connection will be created between two VPCs, in the same region, in your account.
- Another account: The VPC peering connection will be created between your VPC and a VPC in another account, in the same region.
My account
Peer Project
Specifies the peer project name. The project name of the current project is used by default.
aaa
Peer VPC
Specifies the peer VPC. You can select one from the drop-down list if the VPC peering connection is created between two VPCs in your own account.
vpc_02
Peer VPC CIDR Block
Specifies the CIDR block for the peer VPC.
The local and peer VPCs cannot have matching or overlapping CIDR blocks. Otherwise, the routes added for the VPC peering connection may not take effect.
192.168.2.0/24
- Click OK.
Adding Routes for a VPC Peering Connection (Route Table Module Can Be Accessed Through the VPC Details Page)
If you request a VPC peering connection with another VPC in your own account, the system automatically accepts the request. To enable communication between the two VPCs, you need to add local and peer routes for the VPC peering connection.
- On the console homepage, under Network, click Virtual Private Cloud.
- In the navigation pane on the left, click VPC Peering.
- Locate the target VPC peering connection in the connection list.
- Click the name of the VPC peering connection to switch to the page showing details about the connection.
- In the displayed Local Routes area, click Add Local Route. In the displayed dialog box, add a local route. Table 2 lists the parameters to be configured. Figure 4 Add Local Route
Table 2 Route parameter description Parameter
Description
Example Value
Destination
Specifies the destination address. Set it to the peer VPC or subnet CIDR block.
192.168.2.0/24
Next Hop
Specifies the next hop. The default value is the VPC peering connection ID. Keep the default value.
d1a7863b-9d5e-4d27-8eaf-ab14d2a9148b
- Click OK to switch to the page showing the VPC peering connection details.
- On the displayed page, click the Peer Routes tab.
- In the displayed Peer Routes area, click Add Peer Route and add a route.
- Click OK to add the route.
After a VPC peering connection is created, the two VPCs can communicate with each other through private IP addresses. You can run the ping command to check whether the two VPCs can communicate with each other. Before running the ping command, ensure that the security group allows inbound ICMP traffic. For details, see Adding a Security Group Rule.
Adding Routes for a VPC Peering Connection (Route Table Module Can Be Directly Accessed from the Navigation Pane)
If you request a VPC peering connection with another VPC in your own account, the system automatically accepts the request. To enable communication between the two VPCs, you need to add local and peer routes on the Route Tables page for the VPC peering connection.
- On the console homepage, under Network, click Virtual Private Cloud.
- In the navigation pane on the left, choose Route Tables.
- Search for or create a route table for the local VPC and add the local route. Table 3 describes the route parameters. Figure 5 Add Local Route
Table 3 Parameter descriptions Parameter
Description
Example Value
Destination
Specifies the CIDR block of the peer VPC or peer subnet.
192.168.2.0/24
Next Hop Type
Specifies the next hop type. Select VPC peering connection.
VPC peering connection
Next Hop
Specifies the next hop address. Select the name of the current VPC peering connection.
peering-001
Description
Provides supplementary information about the route. This parameter is optional.
The route description can contain a maximum of 255 characters and cannot contain angle brackets (< or >).
N/A
- Search for or create a route table for the peer VPC and add the peer route.
After a VPC peering connection is created, the two VPCs can communicate with each other through private IP addresses. You can run the ping command to check whether the two VPCs can communicate with each other. Before running the ping command, ensure that the security group allows inbound ICMP traffic. For details, see Adding a Security Group Rule.
Last Article: VPC Peering Connection Configuration Plans
Next Article: Creating a VPC Peering Connection with a VPC in Another Account
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.