Help Center> NAT Gateway> Best Practices> Using Private NAT Gateway and Direct Connect to Enable Communication Between a VPC and an On-premises Data Center

Using Private NAT Gateway and Direct Connect to Enable Communication Between a VPC and an On-premises Data Center

Scenarios

The following diagram shows that ECSs in a VPC communicate with an on-premises IDC using Direct Connect and a private NAT gateway.

The following configuration is used as an example.

Solution Advantages

In the hybrid cloud scenario, you need to specify a private IP address for compute instances in a VPC to communicate with the on-premises network that meets security compliance requirements.

Typical Topology

Assume that the CIDR block of the IDC is 10.0.0.0/24 and the subnet of the transit VPC in the region CN North-Beijing4 is 10.1.0.0/24.

Implementation methods:

  1. Connect the transit VPC to the IDC using Direct Connect (VPC Peering is used in the test environment where Direct Connect is unavailable).
  2. Create a private NAT gateway to connect the service VPC to the transit VPC.
    Figure 1 Network topology

Prerequisites

  • The network CIDR block of the IDC does not overlap with the subnet CIDR block of the transit VPC on the cloud. Otherwise, the communication between the IDC and the transit VPC will fail.
  • You have determined the private CIDR block in the transit VPC for performing NAT for resources in the service VPC.

Procedure

  1. Create a service VPC and a transit VPC.

    For details, see Creating a VPC.

  2. Create a Direct Connect connection.

    Create a Direct Connect connection between the IDC and the cloud (CN North-Beijing4 region). For details, see Direct Connect User Guide.

  3. Create and configure a private NAT gateway.

    1. Create a private NAT gateway in the CN North-Beijing4 region and select the service VPC.
      Figure 2 Buy Private NAT Gateway
    2. Create an external subnet in the transit VPC.
      Figure 3 Create External Subnet
    3. Click the created external subnet and assign an IP address from it.
      Figure 4 Assign External Subnet IP Address
    4. In the private NAT gateway list, click the created NAT gateway name, and add an SNAT rule. Set Subnet to the subnet in which the address mapping needs to be performed in the service VPC, and set External Subnet and External Subnet IP Address to those created in the previous step.
      Figure 5 Add SNAT Rule
    5. Add a route pointing to the private NAT gateway for the service VPC and set the destination to the private CIDR block of the IDC.
      Figure 6 Adding a route
    6. Add an inbound security group rule to allow traffic to the destination.
      Figure 7 Adding an inbound security group rule

Verification

After the configuration is complete, test the network connectivity.

Log in to the ECS in the service VPC and ping the private IP address of the IDC.