You can use the DNAT function to map a public IP to a private IP. By adding a DNAT entry, the Internet traffic through the public IP is forwarded to the mapped private IP.
Log on to the VPC console.
In the left-side navigation pane, click NAT Gateway.
Click the ID of the target NAT gateway to enter the page of gateway details.
In the left-side navigation pane, click DNAT Table and then click Create DNAT Entry.
Configure the DNAT entry according to the following information.
Configuration Description Public IP
Select a public IP to forward the Internet traffic.
Note: You cannot use the IP that is already being used in an SNAT entry.
The private IP that you want to map. You can specify the private IP in the following ways:
- Manually Input: Enter the private IP that you want to map. It must be within the private IP range of the VPC.
- Auto Fill: Select an ECS instance in the VPC from the list. The private IP of the selected ECS instance is automatically entered in the field.
For this tutorial, select Auto Fill.
DNAT supports IP mapping and port mapping. Select a mapping method:
All Ports: Select this option to configure IP mapping. Using this method, the ECS instance with the specified private IP can receive any Internet requests using any protocol on any port. This is the same as binding an EIP to it.
You do not need to configure the public port, private port, and IP protocol when configuring IP mapping.
Specific Port: Select this option to configure port mapping. Using this method, the NAT gateway will forward the received data from
[ExternalIp:ExternalPort]using the specified protocol to
[InternalIp:InternalPort],and send the response in the same.
You must specify the public port, private port, and IP protocol when configuring port mapping.
For this tutorial, select Specific Port, set the public port and private port to 80, and use the TCP protocol.
The status of the added DNAT entry is Configuring. Click Refresh to refresh the status. When the status is Available, the DNAT entry has been successfully added.