Updated on 2022-01-25 GMT+08:00

Step 3: Add a DNAT Rule

Scenarios

After a NAT gateway is created, you can add DNAT rules to allow servers in your VPC to provide services accessible from the Internet.

You can configure a DNAT rule for each port of a server. If multiple servers need to provide services accessible from the Internet, you need to create multiple DNAT rules.

Prerequisites

A NAT gateway has been created.

Procedure

  1. Log in to the management console.
  2. Under Network, click NAT Gateway.
  3. On the displayed page, click the name of the NAT gateway for which you want to add the DNAT rule.
  4. On the NAT gateway details page, click the DNAT Rules tab.
  5. Click Add DNAT Rule.

  6. Set the parameters as prompted. For details, see Table 1.
    Table 1 Parameter description

    Parameter

    Description

    Scenario

    Select VPC when your servers in a VPC need to share one EIP to provide services accessible from the Internet.

    Port Type

    Specifies the port type, including All ports and Specific port.

    • All ports: indicates the IP mapping method. This method is equivalent to assigning an EIP to a server. Any requests on the EIP will be forwarded by the NAT gateway to your server based on IP address mapping.
    • Specific port: indicates the port mapping method. The NAT gateway forwards the requests with specific protocol and port on the EIP to the corresponding port of the target server.

    Protocol

    The protocol can be TCP or UDP. This parameter is available if you select Specific port for Port Type. If you select All ports, the value of this parameter will be All by default.

    EIP

    Specifies the EIP that will be used by the server to provide services accessible from the Internet.

    You can only select an EIP that has not been bound, has been bound to a DNAT rule with Port Type set to Specific port of the current NAT gateway, or has been bound to an SNAT rule of the current NAT gateway.

    Outside Port

    Specifies the port of the EIP. This parameter is available if you select Specific port for Port Type. The value ranges from 1 to 65535.

    The value can be a single port number or a port range, for example, 80 or 80-100.

    Private IP Address

    Specifies the private IP address of the server that provides services accessible from the Internet through the DNAT rule.

    Inside Port

    Specifies the port of the server that provides services accessible from the Internet through the DNAT rule. This parameter is available if you select Specific port for Port Type. The value ranges from 1 to 65535.

    The value can be a single port number or a port range, for example, 80 or 80-100.

    Description

    Provides supplementary information about the DNAT rule. The description can contain a maximum of 255 characters.

  7. Click OK.