Help Center> Cloud Connect> Best Practices> Working with DNAT to Access a Private Network from the Internet Outside China

Working with DNAT to Access a Private Network from the Internet Outside China

Scenarios

  • This practice provides detailed operations for allowing access to a private network from the Internet outside China.
  • A DNAT rule is required so that ECSs in the VPCs in China can provide services accessible from the Internet.

Figure 1 shows the networking topology.

Figure 1 Networking

In this practice, consider the VPC in CN East-Shanghai1 as the on-premises network.

The network outside China is 0.0.0.0/0.

Your account must have the permission for cross-border network communication. If you do not have the permission, you can authorize the other user 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. Configure Cloud Connect.

    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 a custom CIDR block.

      For details, see Adding a Custom CIDR block.

      Custom CIDR block for CN-Hong Kong: 0.0.0.0/0

      You need to add the default route 0.0.0.0/0 from the cloud connection to the NAT gateway.

    4. Buy a bandwidth package.

      By default, the system allocates 10 kbit/s of bandwidth for testing network connectivity across regions. You need to buy a bandwidth package to ensure normal network communications across regions.

      For details, see Buying a Bandwidth Package.

    5. Assign an inter-region bandwidth.

      For details, see Assigning 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.

    Purchase an EIP in CN-Hong Kong, purchase a 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.

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

Verification

After the configuration is complete, test the network connectivity and access the corresponding port.

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