Help Center> Direct Connect> Best Practices> Accessing Multiple VPCs Using VPC Peering

Accessing Multiple VPCs Using VPC Peering

Scenarios

After your environment has been connected to HUAWEI CLOUD, you can use VPC Peering to access other VPCs in the same region.

In this practice, the two VPCs are in the CN North-Beijing4 region.

The subnets of the VPCs 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 you create the virtual gateway, select VPC A for VPC.

    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. Hover on to display Service List and choose Networking > Virtual Private Cloud.
    4. In the navigation pane on the left, click VPC Peering.
    5. On the VPC Peering page, click Create VPC Peering Connection.
    6. Configure the parameters based on Table 1.
      Figure 1 Creating a VPC peering connection
      Table 1 Parameter description

      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 B

      Local VPC CIDR Block

      Specifies the CIDR block for the local VPC.

      192.168.2.0/24

      Account

      Specifies the account to which the VPC to peer with.

      • My account: The VPC peering connection will connect two VPCs in your account, in the same region.
      • Another account: The VPC peering connection will connect your VPC to a VPC in another account, in the same region.

      My account

      Peer Project

      Specifies the project name. The project 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.

      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 of your own.

      VPC A

      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.10.0/24

      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.
    3. Locate the VPC peering connection in the connection list.
      Figure 2 VPC peering 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. In the Local Routes area, click Add Local Route. In the displayed dialog box, add a local route.
      Table 2 lists the parameters.
      Figure 3 Add Local Route
      Table 2 Parameter description

      Parameter

      Description

      Example Value

      Destination

      Specifies the destination address. Set it to the peer VPC or subnet CIDR block.

      Add the CIDR block of VPC A and the local subnet used by the on-premises data center.

      192.168.10.0/24

      192.168.1.0/24

      Next Hop

      Specifies the next instance along the path to the destination.

      By default, the VPC peering connection ID is used as the next hop and cannot be changed.

      -

      In some regions, you need to click Route Tables to add the local route to the VPC route table.

      The operations may vary depending on the region.

    7. Click OK to switch to the page showing the VPC peering connection details.
    8. Click the Peer Routes tab.
    9. In the Peer Routes area, click Add Peer Route and add a route.
      Table 3 lists the parameters.
      Figure 4 Add Peer Route
      Table 3 Parameters for adding a peer route

      Parameter

      Description

      Example Value

      Destination

      Specifies the destination address. Set it to the CIDR block of the local VPC or its subnet.

      CIDR block of VPC B: 192.168.2.0/24

      192.168.2.0/24

      Next Hop

      Specifies the next instance along the path to the destination.

      By default, the VPC peering connection ID is used as the next hop and cannot be changed.

      -

      In some regions, you need to click Route Tables to add the peer route to the VPC route table.

      The operations may vary depending on the region.

    10. Click OK.