Help Center> NAT Gateway> Best Practices> Using NAT Gateway and Direct Connect to Accelerate Internet Access

Using NAT Gateway and Direct Connect to Accelerate Internet Access

Scenarios

You need to connect your data center to HUAWEI CLOUD using Direct Connect and then configure SNAT rules of a NAT gateway to enable servers to access the Internet in a secure, reliable, and high-speed way, or configure DNAT rules to enable servers to provide services accessible from the Internet. Similar scenarios include Internet, games, e-commerce, and finance.

Solution Advantages

With Direct Connect, you can access a VPC on HUAWEI CLOUD with high-performance, low-latency, and secure networks. A Direct Connect connection supports a maximum of 10 Gbit/s bandwidth, meeting various bandwidth requirements.

With the SNAT and DNAT functions of the NAT gateway, multiple servers can share an EIP, effectively reducing costs. The NAT gateway specifications and bound EIPs can be adjusted at any time. The configuration is simple and will take effect immediately.

Typical Topology

Assume that the network of your IDC is 172.18.0.0/24, the region of the VPC is CN North-Beijng4, and the VPC subnet is 172.16.0.0/24.

Implementation methods:

  1. Use Direct Connect to connect your IDC to your VPC.
  2. Create a NAT gateway in the VPC to connect to the Internet.
    Figure 1 Network topology

Prerequisites

  • The default route of the IDC is available for configuring Direct Connect.
  • The network CIDR block of the IDC does not overlap with the subnet CIDR block of the VPC on the cloud. Otherwise, the communication between the IDC and the VPC will fail.

Configuration Procedure

  1. Create VPCs.

    For details, see Creating a VPC.

  2. Configure a Direct Connect connection.

    Create a Direct Connect connection between the IDC and the cloud (CN North-Beijing4 region). For details, see Process Description.
    When creating a Direct Connect connection, add the 0.0.0.0/0 CIDR block as the local subnet on the cloud when configuring the route.
    • Static: Add the default route with 0.0.0.0/0 as the destination in the on-premises data center and set the next hop to the connection.
    • BGP: The on-premises network can learn the default route using BGP.

  3. Buy an EIP and configure a NAT gateway.

    1. Buy an EIP in the CN North-Beijing4 region. For details, see Assigning an EIP.
    2. Buy a NAT gateway. For details, see Buying a NAT Gateway.
    3. Add an SNAT rule with the CIDR block set to that of the Direct Connect connection. For details, see Adding an SNAT Rule.

      Set CIDR Block to 172.18.0.0/24 and select an EIP.

      Figure 2 Add SNAT Rule
    4. Add a DNAT rule. For details, see Adding a DNAT Rule.

      Configure the protocol and port type. All ports is used as an example. Set Private IP Address to 172.18.0.100 and select an EIP.

      Figure 3 Add DNAT Rule

      SNAT and DNAT are used for different services. If an SNAT rule and a DNAT rule use the same EIP, there may be service conflicts. An SNAT rule cannot share an EIP with a DNAT rule with Port Type set to All ports.

Configuration Verification

After the configuration is complete, test the network connectivity.

Ping an external IP address, for example, 114.114.114.114, from a server in the IDC.