Importing and Exporting DNAT Rules Using Templates
Scenarios
After a public NAT gateway is created, you can add DNAT rules to allow servers in your VPC to provide services accessible from the Internet.
A DNAT rule is configured for one server. If there are multiple servers, you need to create multiple DNAT rules.
Prerequisites
A NAT gateway has been created.
Procedure
- Log in to the management console.
- Click
in the upper left corner and select the desired region and project. - Under Network, click NAT Gateway.
Switch to the public NAT gateway page.
- On the displayed page, click the name of the public NAT gateway for which you want to add the DNAT rule.
- On the public NAT gateway details page, click the DNAT Rules tab.
- On the displayed page, click Import Rule and then Download Template.
- Fill in DNAT rule parameters based on the table heading in the template. For details, see Table 1.
Table 1 Parameter descriptions Parameter
Description
Scenario
VPC: The servers in a VPC can share an EIP to provide services accessible from the Internet through the DNAT rule.
Direct Connect/Cloud Connect: On-premises servers that are connected to a VPC through Direct Connect or Cloud Connect can provide services accessible from the Internet through the DNAT rule.
Port Type
The port type. You can select All ports or Specific port.
- All ports: This 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 public NAT gateway only forwards requests with a 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, this parameter is All by default.
EIP
The EIP that will be used by the server to provide services accessible from the Internet.
Only EIPs that have not been bound or that have been bound to a DNAT rule in the current VPC are available for selection.
Outside Port
The EIP port. This parameter is available if you select Specific port for Port Type.
You can enter a single port number or a port range, for example, 80 or 80-100.
Private IP Address
- In a VPC scenario, set this parameter to the IP address of the server in a VPC. This IP address is used by the server to provide services accessible from the Internet through DNAT.
- In a Direct Connect scenario, set this parameter to IP address of the server in the local data center or the user's private IP address. This IP address is used by local servers that are connected to a VPC through Direct Connect or Cloud Connect to provide services accessible from the Internet through DNAT.
- Configure the port of Private IP Address if you select Specific port for Port Type.
Inside Port
- In a VPC scenario, set this parameter to the port of the server in a VPC.
- In a Direct Connect scenario, set this parameter to the port of the server in the local data center or the user's private port.
- This parameter is available if you select Specific port for Port Type.
The number of inside and outside ports must match.
- After filling in the template, click Import Rule, select the template, and click Import. Figure 1 Import Rule
- View details in the DNAT rule list. If Status is Running, the rules have been added.
- On the DNAT Rules tab page, click Export Rule to export the configured DNAT rule template.
Last Article: Deleting DNAT Rules in Batches
Next Article: Private NAT Gateway (OBT)
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.