Help Center/ Cloud Connect/ Best Practices/ Enabling the Internet to Access Private Networks Using a Cloud Connection and DNAT
Updated on 2024-10-25 GMT+08:00

Enabling the Internet to Access Private Networks Using a Cloud Connection and DNAT

Scenarios

  • This practice provides detailed operations for the Internet outside the Chinese mainland to access private networks.
  • DNAT rules are required so that ECSs in the VPCs in the Chinese mainland can provide services accessible from the Internet.

For details about the regions where cloud connections are available, see Region Availability.

Figure 1 shows an example.

Figure 1 Enabling access from the Internet

In this practice, suppose that the VPC in CN East-Shanghai1 is the on-premises network.

The CIDR block of the Internet outside the Chinese mainland is 0.0.0.0/0.

Your account must have the permission for cross-border communication. If your account does not have the permission, you can ask the other user with the required permission to load the VPCs.

Procedure

  1. Create the following VPCs and ensure that the VPC CIDR blocks do not conflict with each other:

    • VPC in CN East-Shanghai1: 172.16.36.0/24
    • VPC in CN-Hong Kong: 192.168.120.0/24

    For details, see Creating a VPC.

  1. Create a cloud connection.

    1. Create a cloud connection.

      For details, see Creating a Cloud Connection.

    2. Load the VPCs.

      For details, see Loading a Network Instance.

    3. Add custom CIDR blocks.

      For details, see Adding Custom CIDR Blocks for a Cloud Connection.

      When you load the VPC in CN-Hong Kong, you need to add the custom CIDR block 0.0.0.0/0.

      You need to add the default route 0.0.0.0/0 to allow access from the NAT gateway.

    4. Buy a bandwidth package.

      By default, a cloud connection provides 10 kbit/s of bandwidth for testing cross-region network connectivity. You need to buy a bandwidth package to ensure normal communication across regions.

      For details, see Buying a Bandwidth Package.

    5. Assign an inter-region bandwidth.

      For details, see Assigning an Inter-Region Bandwidth.

  1. Buy an ECS in CN East-Shanghai1.

    For details, see Purchasing an ECS.

    Private IP address of the ECS in CN East-Shanghai1: 172.16.36.220

  2. Buy an EIP and configure a NAT gateway.

    In CN-Hong Kong, buy an EIP and a public NAT gateway, and add a DNAT rule. Select Direct Connect/Cloud Connect when you add the DNAT rule.

    For details, see Assigning an EIP and Binding It to an ECS and Adding a DNAT Rule.

    Set the private IP address to 172.16.36.220 when you add the DNAT rule.

    The DNAT rule enables the ECS to provide services accessible from the Internet.

Verification

Test network connectivity.

Ping the EIP bound to the DNAT rule and the port used by the EIP from any client on the Internet.