You can use the DNAT function to map a public IP to a private IP of an ECS instance in the VPC network. Then, the ECS instance with the specified public IP can provide public services.
- Log on to the VPC console.
- In the left-side navigation pane, click NAT Gateways.
- Select the region of the NAT Gateway.
- Click the ID of the target NAT Gateway.
- 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.Note The IP that is already being used in an SNAT entry cannot be selected.
Select the private IP of the ECS instance to access the Internet. 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.
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 the ECS instance.
Specific Port: Select this option to configure port mapping. Using this method, NAT Gateway forwards the request from the specified protocol and port to the target ECs instance on the specified port.
You must specify the public port, private port, and IP protocol when the port mapping is selected.