If you need features such as Internet access, static public IP addresses, high availability, and load balancing, or you need to enhance the security of your instance, you can create an EIP and associate it with an Elastic Compute Service (ECS) instance in a virtual private cloud (VPC) that has no public IP addresses. This way, the instance can enable these features.
Associate one or more EIPs with an instance
Prerequisites
To associate an EIP with an instance, make sure that the instance meets the following requirements:
The ECS instance is located in a VPC.
The ECS instance is located in the same region as the EIP.
The ECS instance is in the Running or Stopped state.
No public IP addresses are associated with the primary network interface controller (NIC) of the ECS instance.
Procedure
Associate one EIP with an ECS instance
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the Instances page, find the instance with which you want to associate an EIP and choose .
In the Associate EIP dialog box, select an EIP from the EIP drop-down list.
If no EIPs are present in the EIP drop-down list, perform one of the following operations:
Check whether the EIP that you want to use is created. If the EIP is not created, click Create EIP on the right side of the EIP drop-down list to create the EIP. For more information, see Apply for an EIP.
Check whether the EIP that you want to use is associated with other cloud resources. If the EIP is associated with other cloud resources, disassociate the EIP from the resources. For more information, see Disassociate an EIP from a cloud resource.
Click OK.
After the EIP is associated with the instance, the EIP is displayed in the IP Address column corresponding to the instance on the Instances page. Example: 192.168.XX.XX (EIP).
Associate multiple EIPs with an ECS instance
If multiple applications are hosted on the same ECS instance and you want each application to have an independent public IP address, you can associate multiple EIPs with a secondary elastic network interface (ENI) of the instance in NAT mode. For more information, see Associate multiple EIPs with an ECS instance in NAT mode.
Disassociate an EIP from an ECS instance
If you no longer need to access an ECS instance over the Internet or you need to change an EIP of the instance, we recommend that you disassociate the EIP from the instance to avoid resource waste.
You are not able to access the ECS instance over the Internet after you disassociate an EIP from the instance. Before you disassociate an EIP, make sure that Internet access is no longer required or you can access the instance over alternative network connections.
Log on to the ECS console.
In the left-side navigation pane, choose .
In the top navigation bar, select the region and resource group to which the resource belongs.
On the Instances page, find the instance from which you want to disassociate an EIP and choose .
In the Disassociate EIP message, confirm the message.
Click OK.
NoteAfter the EIP is disassociated from the instance, the EIP is not displayed in the IP Address column corresponding to the instance on the Instances page.
After an EIP is disassociated from an instance, you are still charged for the EIP. If you no longer need the EIP, you can manually release it. For more information, see Release a pay-as-you-go EIP.
References
After you associate an EIP with an ECS instance, you can view the following topics for more information about the billing method, bandwidth usage, and traffic consumption of EIPs.
After you disassociate an EIP from an ECS instance, the public IP address that is associated with the EIP is no longer available. You can perform the following operations to ensure that your applications or services can run normally.