Creating a VPC Peering Connection with Another VPC in Your Account
Scenarios
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 the same account.
This following describes how to create a VPC peering connection between VPC-A and VPC-B in account A to enable communications between ECS-A01 and RDS-B01.
Procedure:
Step 1: Create a VPC Peering Connection
Step 2: Add Routes for the VPC Peering Connection
Step 3: Verify Network Connectivity
Notes and Constraints
- Only one VPC peering connection can be created between two VPCs at the same time.
- A VPC peering connection can only connect VPCs in the same region.
- If the local and peer VPCs have overlapping CIDR blocks, the VPC peering connection may not take effect.
Prerequisites
You have two VPCs from the same account in the same region. If you want to create one, see Creating a VPC.
Step 1: Create a VPC Peering Connection
- Log in to the management console.
- Click in the upper left corner and choose Network > Virtual Private Cloud.
The Virtual Private Cloud page is displayed.
- In the navigation pane on the left, choose Virtual Private Cloud > VPC Peering Connections.
The VPC peering connection list is displayed.
- In the upper right corner of the page, click Create VPC Peering Connection.
The Create VPC Peering Connection dialog box is displayed.
- Configure the parameters as prompted.
For details, see Table 1.
Table 1 Parameters for creating a VPC peering connection 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
- Options: My account and Another account
- Select My account.
My account
Peer Project
The system fills in the corresponding project by default because My account is set to Account.
For example, if VPC-A and VPC-B are in account A and region A, the system fills in the correspond project of account A in region A by default.
ab-cdef-1
Peer VPC
This parameter is mandatory if Account is set to My account.
VPC at the other end of the VPC peering connection. You can select one from the drop-down list.
VPC-B
Peer VPC CIDR Block
CIDR block of the selected peer VPC
If the local and peer VPCs have overlapping CIDR blocks, the VPC peering connection may not take effect. For details, see VPC Peering Connection Usage Examples.
172.17.0.0/16
Description
Optional
Enter the description of the VPC peering connection in the text box as required.
peering-AB connects VPC-A and VPC-B.
- Click OK.
A dialog box for adding routes is displayed.
- Click Add Route or Add Later.
- If you click Add Route, the Local Routes page is displayed. Then, go to Step 2: Add Routes for the VPC Peering Connection.
- If you click Add Later, the VPC peering connection list is displayed.
Step 2: Add Routes for the VPC Peering Connection
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.
- Add routes to the route table of the local VPC:
- On the Local Routes tab of the VPC peering connection, click the Route Tables hyperlink.
The Summary tab of the default route table for the local VPC is displayed.
- Click Add Route.
Table 2 describes the route parameters.
Table 2 Parameter description Parameter
Description
Example Value
Destination
The peer VPC CIDR block, subnet CIDR block, or ECS IP address. For details, see VPC Peering Connection Usage Examples.
VPC-B CIDR block: 172.17.0.0/16
Next Hop Type
The next hop type. Select VPC peering connection.
VPC peering connection
Next Hop
The next hop address. Select the name of the current VPC peering connection.
peering-AB
Description
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 >).
-
- Click OK.
You can view the route in the route list.
- On the Local Routes tab of the VPC peering connection, click the Route Tables hyperlink.
- Add routes to the route table of the peer VPC:
- On the Peer Routes tab of the VPC peering connection, click the Route Tables hyperlink.
The Summary tab of the default route table for the peer VPC is displayed.
- Click Add Route.
Table 3 describes the route parameters.
Table 3 Parameter description Parameter
Description
Example Value
Destination
The local VPC CIDR block, subnet CIDR block, or ECS IP address. For details, see VPC Peering Connection Usage Examples.
VPC-A CIDR block: 172.16.0.0/16
Next Hop Type
The next hop type. Select VPC peering connection.
VPC peering connection
Next Hop
The next hop address. Select the name of the current VPC peering connection.
peering-AB
Description
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 >).
-
- Click OK.
You can view the route in the route list.
- On the Peer Routes tab of the VPC peering connection, click the Route Tables hyperlink.
Step 3: Verify Network Connectivity
- Log in to ECS-A01 in the local VPC.
- Check whether ECS-A01 can communicate with RDS-B01.
Example command:
ping 172.17.0.21
If information similar to the following is displayed, ECS-A01 and RDS-B01 can communicate with each other, and the VPC peering connection between VPC-A and VPC-B is successfully created.[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 ---
- In this example, ECS-A01 and RDS-B01 are in the same security group. If the instances in different security groups, you need to add inbound rules to allow access from the peer security group. For details, see Enabling ECSs In Different Security Groups to Communicate Through an Internal Network.
- If VPCs connected by a VPC peering connection cannot communicate with each other, refer to Why Did Communication Fail Between VPCs That Were Connected by a VPC Peering Connection?.
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