Help Center/ Direct Connect/ Best Practices/ Connecting an On-Premises Data Center to Multiple VPCs in the Same Region Using Direct Connect and VPC Peering
Updated on 2024-10-11 GMT+08:00

Connecting an On-Premises Data Center to Multiple VPCs in the Same Region Using Direct Connect and VPC Peering

Scenarios

Connect your on-premises network to the cloud and use VPC Peering to connect the VPCs in the same region so that your on-premises network can access all these VPCs.

The CIDR block of each VPC must be unique.

Typical Topology

Procedure

  1. Configure Direct Connect to connect your on-premises data center to VPC A.

    1. Create a connection.
    2. Create a virtual gateway.

      When creating the virtual gateway, select VPC A and add the CIDR block of VPC B to the local subnet.

    3. Create a virtual interface.

  2. Create a VPC peering connection between VPC A and VPC B.

    1. Log in to the management console.
    2. On the console homepage, click in the upper left corner and select the desired region and project.
    3. Click to display Service List and choose Networking > Virtual Private Cloud.
    4. In the navigation pane on the left, click VPC Peering Connections.
    5. Click Create VPC Peering Connection.
    6. Configure the parameters based on Table 1.
      Figure 1 Creating a VPC peering connection
      Table 1 Parameters required for creating a VPC peering connection

      Parameter

      Description

      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 (_).

      Local VPC

      Specifies the local VPC. Select VPC B from the drop-down list.

      Local VPC CIDR Block

      Specifies the CIDR block of the local VPC.

      Account

      Specifies whether the VPC to peer with is from your account or another user's account.

      • My account: The VPC peering connection will connect two VPCs in your account.
      • Another account: The VPC peering connection will connect your VPC to another VPC in another account.

      Peer Project

      Specifies the project name. The name of the current project is used by default.

      You can log in to the management console, hover the cursor over account name in the upper right corner, and choose My Credentials. On the My Credentials page, view the project name and project ID.

      Peer VPC

      Specifies the peer VPC. Select VPC A from the drop-down list.

      Peer VPC CIDR Block

      Specifies the CIDR block of 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.

      Description

      Provides supplementary information about the VPC peering connection.

    7. Click OK.

  1. Add routes for the VPC peering connection.

    1. Under Networking, click Virtual Private Cloud.
    2. In the navigation pane on the left, click VPC Peering Connections.
    3. Locate the VPC peering connection in the connection list.

    4. Click the name of the VPC peering connection to switch to the page showing details about the connection.
    5. Click the Local Routes tab.
    6. On the Local Routes tab page of the VPC peering connection, click here as prompted.

      The Summary tab of the default route table for the local VPC is displayed.

      Table 2 lists the parameters.

    7. Click Add Route.
      Table 2 Parameters required for creating a VPC peering connection

      Parameter

      Description

      Destination Type

      Specifies the public IP address.

      Destination

      Specifies the CIDR block of the peer VPC, a subnet, or the private IP address of an ECS in the peer VPC.

      For details, see VPC Peering Connection Examples.

      Next Hop Type

      Specifies the next hop type. Select VPC peering connection.

      Next Hop

      Specifies the next hop address. Select the created VPC peering connection.

      Description

      (Optional) Provides supplementary information about the route.

      Enter up to 255 characters. Angle brackets (< or >) are not allowed.

    8. Click OK.

      You can view the route in the route list.

    9. Click the Peer Routes tab.
    10. On the Peer Routes tab page of the VPC peering connection, click here as prompted.

      The Summary tab of the default route table for the peer VPC is displayed.

      Table 2 lists the parameters.

      Table 3 Parameters required for creating a VPC peering connection

      Parameter

      Description

      Destination Type

      Specifies the public IP address.

      Destination

      Specifies the CIDR block of the local VPC, a subnet CIDR block, or the private IP address of an ECS in the local VPC.

      For details, see VPC Peering Connection Examples.

      Next Hop Type

      Specifies the next hop type. Select VPC peering connection.

      Next Hop

      Specifies the next hop address. Select the created VPC peering connection.

      Description

      (Optional) Provides supplementary information about the route.

      Enter up to 255 characters. Angle brackets (< or >) are not allowed.

    11. Click OK.

      You can view the route in the route list.