All Products
Search
Document Center

Virtual Private Cloud:Use VPC peering connection for private communication

Last Updated:Dec 11, 2024

A VPC peering connection is a network connection between two VPCs, supporting both IPv4 and IPv6. You can create an IPv4 or IPv6 connection between two VPCs within the same or across different accounts, and within the same or across different regions.

Scenario

A company has established VPC1 and VPC2 in the China (Beijing) and China (Shanghai) regions respectively.

To secure resource access, the company sets up a peering connection between VPC1 and VPC2. As inter-region traffic remains in the private network, it mitigates common security threats such as data leakage and DDoS attacks.

Note

Before you create a VPC peering connection across accounts, make sure that both the requester and accepter have a VPC in place.

image

Procedure

Step 1: Create a VPC peering connection

  1. Log on to the VPC console. In the top navigation bar, select the region where the requester VPC is located, which is China (Beijing) in this example. In the left-side navigation pane, click VPC Peering Connection.

  2. If you have not used VPC peering connection before, click Activate CDT on the VPC Peering Connection page, and then click OK in the dialog box.

    Note

    To create a VPC peering connection across accounts, ensure that the accepter has enabled the Cloud Data Transfer (CDT) feature.

  3. Go to the VPC Peering Connection page, click Create VPC Peering Connection, and set the parameters as follows:

    E20A1099-C438-410B-9DBD-C0CDCB223EDF.png

    Note
    • You can create four types of VPC peering connections: intra-region same-account, inter-region same-account, intra-region cross-account, and inter-region cross-account.

    • When the accepter account is Same-Account, the system automatically establishes the connection after the requester initiates the request. No action is required from the accepter.

    • When the accepter account is Cross-Account, the accepter needs to accept the peering request before the VPC peering connection can be created. The accepter may reject the request and terminate the VPC peering connection process. The steps that need to be taken by the accepter are as follows :

      1. Log on to the VPC console with the accepter account. In the left-side navigation pane, click VPC Peering Connection.

      2. Find the target VPC peering connection on the VPC Peering Connection page. Currently, the status of the connection is Accepting. image Decide whether to accept the request:

        • Accept: The status changes from Accepting to Updating.

          When the status changes to Activated, it indicates the connection is ready for use.

        • Reject: The status changes from Accepting to Rejected.

          A Rejected VPC peering connection cannot be used. You can Delete it from either the requester or the accepter end.

        • If the accepter takes no action on a cross-account VPC peering connection request, the connection status changes to Expired after 7 days.

Step 2: Configure routes

After a VPC peering connection has been created and Activated, you need to add route entries that point to the peer VPC on both ends to enable the connection.

  1. Find the VPC peering connection on the VPC Peering Connection page and click Configure Route in either the Requester VPC or Accepter VPC column.

  2. Configure the IPv4 or IPv6 route entries for both the requester and accepter VPCs. Below is an example of configuring an IPv4 route entry.

    A5670115-E729-4548-B2A1-1C74843A220E.png

    Parameter description

    Parameter

    Description

    VPC

    The requester VPC instance is automatically displayed.

    Route Table

    Select the route table associated with the VPC from the drop-down list.

    Destination CIDR Block

    • Configure an IPv4 route for the VPC peering connection

      Select IPv4 as the destination CIDR block type and enter the IPv4 CIDR block of the accepter VPC.

    • Configure an IPv6 route for the VPC peering connection

      Select IPv6 as the destination CIDR block type and enter the IPv6 CIDR block of the accepter VPC.

    Next Hop

    The peering connection is automatically displayed.

Note

For cross-account peering connections, log on to the VPC console with the accepter account. Enter the IPv4 or IPv6 CIDR block of the requester VPC to add a route for the accepter VPC.

Step 3: Verify connectivity

  1. Log on to the ECS1 instance and access the private IP address of the ECS2 instance.peer.pngpeer6.png

  2. Log on to the ECS2 instance and access the private IP address of the ECS1 instance.peer2.pngpeer62.png

  3. If you receive the return message shown in the preceding figures, it indicates VPC1 and VPC2 are connected. After verification, you can deploy and use business applications in the two connected VPCs for secure access.

Note

If you experience network connectivity issues, use the Network Intelligence Service (NIS) and reverse path analytics to diagnose configuration issues and verify the connectivity of bidirectional paths. Make sure the following configurations are set up correctly:

  • The IPv4/IPv6 route entries of VPCs at both ends of the peering connection have been configured correctly. The destination CIDR block is that of the peer VPC and the next hop is VPC peering connection.

  • The Inbound and outbound rules for the ECS security group have been set up to allow traffic from the peer IP address.

  • The inbound and outbound rules of the network ACLs associated with the vSwitches have been configured to allow traffic from the peer IP address.

Related steps

Delete a VPC peering connection

You can delete VPC peering connections that are no longer needed.

Important

After you delete a VPC peering connection, the private network access is terminated and cannot be restored. Ensure that your business is not affected before deleting the connection and proceed with caution.

  1. Go to the VPC Peering Connection page, find the VPC peering connection you want to remove, and click Delete in the Actions column.

  2. In the dialog box that appears, click Confirm.

    • Natural deletion: Before deleting the VPC peering connection, you must remove the route entries that point to it from the route table.

    • Forceful deletion: The system automatically deletes the route entries that point to the VPC peering connection.

      To forcefully delete the VPC peering connection, click I confirm that my services will not be affected and want to delete all the preceding VPC peering connections and routes.

Modify the bandwidth of an inter-region VPC peering connection

  1. Go to the VPC Peering Connection page, find the inter-region VPC peering connection for which you want to adjust the bandwidth, and click its instance ID.

  2. On the details page, find the Basic Information section and click Edit next to Bandwidth (Mbit/s).

  3. In the dialog box that appears, enter the new bandwidth value and click OK.

    The bandwidth value must be a positive integer and cannot exceed 1024.

Use PrivateLink to access OpenAPI service of VPC peering connection

Note

Use PrivateLink to access OpenAPI service of VPC peering connection in the following regions: China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Shenzhen), Hong Kong (China), Singapore, US (Silicon Valley), and US (Virginia).

  1. Log on to the endpoint console. Go to the Endpoints page and click Create Endpoint.

  2. On the Create Endpoint page, set up the endpoint based on the following table and click OK. Only parameters pertinent to this topic are presented in the table. For other parameters, see Create and manage endpoints. After creation, the VPC peering connection API can be accessed by using the endpoint domain name vpcpeer.vpc-proxy.aliyuncs.com.

    Parameter

    Description

    Endpoint Type

    Interface Endpoint is chosen in this example.

    Endpoint Service

    Select an endpoint service.

    Alibaba Cloud service is chosen in this example. Then, select the endpoint service named com.aliyuncs.privatelink.cn-[Region-ID].vpcpeer.

References