All Products
Search
Document Center

Elastic IP Address:Associate an EIP with an ECS instance

Last Updated:Jan 20, 2025

After an Elastic Compute Service (ECS) instance is associated with an elastic IP address (EIP), the ECS instance can communicate with the Internet. You can associate an EIP with an ECS instance in a virtual private cloud (VPC).

Background information

  • If an EIP is associated with an ECS instance in NAT mode, both the private IP address and public IP address of the ECS instance are available for use.

  • After an EIP is associated with an ECS instance, you cannot view the EIP on the operation system. You can call DescribeInstances to query the public IP address assigned to the ECS instance. For more information, see DescribeInstances.

  • EIPs do not support protocols that are managed by NAT application layer gateways (ALGs), such as H.323, Session Initiation Protocol (SIP), Domain Network System (DNS), and Real Time Streaming Protocol (RTSP).

Prerequisites

An ECS instance is created and the ECS instance meets the following requirements:

  • The ECS instance is deployed in a VPC.

  • The ECS instance is in the Running or Stopped state.

  • The ECS instance is in the same region as the EIP to be associated.

  • The ECS instance is not assigned a static public IP address and is not associated with an EIP.

Procedure

  1. Log on to the Elastic IP Address console .
  2. In the top navigation bar, select the region where the EIP is created.

  3. On the Elastic IP Addresses page, find the EIP that you created and click Associate with Resource in the Actions column.

  4. In the Associate EIP with Resource dialog box, set the following parameters and click OK.

    Parameter

    Example

    Instance Type

    Select ECS Instance.

    Resource Group

    Select the resource group to which the ECS instance belongs.

    Select an instance to associate

    Select the ECS instance to be associated with the EIP.

    Note

    Each ECS instance can be associated with only one EIP.

    To associate multiple EIPs with an ECS instance, associate a secondary elastic network interface (ENI) with the ECS instance and associate EIPs with the secondary ENI. For more information, see Associate an EIP with an ECS instance.

FAQ

Why am I unable to associate an EIP with an ECS instance?

Possible causes:

  • The EIP and ECS instance do not belong to the same region.

  • The ECS instance is assigned a public IP address or is associated with another EIP.

  • The ECS instance is deployed in a classic network instead of a VPC. You can associate an EIP with only an ECS instance that is deployed in a VPC.

  • The ECS instance is in a state that does not allow you to associate an EIP. You can associate an EIP with an ECS instance that is only in the Running or Stopped state.

To troubleshoot the issue, perform the following operations:

  1. Check the regions in which the EIP and the ECS instance are deployed. Make sure that they are deployed in the same region, for example, in the China (Hangzhou) region.

  2. Log on to the ECS console and check the status of the ECS instance. Make sure that the following requirements are met:ECS排查

    Number

    Description

    1

    The ECS instance is assigned only a private IP address.

    As shown in the following figure, if your ECS instance is assigned a public IP address or is associated with another EIP, you cannot associate the EIP with your ECS instance.

    ECS的IPIf you have other requirements, see the following topics:

    2

    The ECS instance is deployed in a VPC.

    If the ECS instance is deployed in a classic network, you can migrate the ECS instance to a VPC. For more information, see Migrate ECS instances from the classic network to a VPC.

    3

    The ECS instance is in the Running or Stopped state.

    For more information about how to manage the status of your ECS instance, see Instance lifecycle.

Why am I unable to view the EIP in the operating system of the ECS instance after I associate the EIP with the ECS instance?

EIPs are deployed on the Internet gateway of Alibaba Cloud and are mapped to the private network interface controllers (NICs) of the associated ECS instances through NAT. Therefore, you cannot view the EIP on the private NIC of the ECS instance.

You can expose an EIP by adding a secondary CIDR block to a VPC. For more information, see Expose an EIP on an NIC by adding a secondary CIDR block to a VPC.

How can I associate multiple EIPs with one ECS instance?

You can associate multiple EIPs with one ECS instance by using the following methods:

  • Associate an EIP with each secondary ENI. Then, attach the secondary ENIs to the ECS instance. The number of secondary ENIs that can be attached to an ECS instance varies with the specification of the ECS instance. For more information, see Overview of instance families.

  • Associate multiple EIPs with a secondary ENI in NAT mode. In this mode, each EIP is associated with a secondary private IP address of the secondary ENI. Then, associate the secondary ENI with the ECS instance. For more information, see Associate multiple EIPs with an ECS instance in NAT mode.

How do I change the EIP associated with an ECS instance?

To change the EIP that is associated with an ECS instance, disassociate the EIP from the instance and associate a different EIP with the instance.

  1. (Optional) Apply for a new EIP.

    For more information, see Apply for an EIP.

  2. Disassociate the current EIP from the ECS instance.

    For more information, see Disassociate an EIP from a cloud resource.

    Important
    • After you disassociate a pay-as-you-go EIP from a cloud resource, you are still charged an EIP configuration fee. To avoid unnecessary fees, release the EIP.

    • If you no longer require a subscription EIP after you disassociate the EIP from a cloud resource, you can unsubscribe from the EIP. For more information, see Rules for unsubscribing from resources.

  3. Associate the new EIP with the ECS instance.

    For more information, see Associate an EIP with an ECS instance.

Does an EIP automatically change?

No, an EIP does not automatically change.

If an EIP expires or the payment is overdue, the EIP may be released. You can apply for a specific EIP to retrieve a released EIP.

Note

If an ECS instance is assigned a public IP address, the public IP address is released in the following scenarios: the ECS instance is released, the bandwidth of the ECS instance is set to 0, or you stop the ECS instance and select Economical Mode. When you re-assign a public IP address to the ECS instance, a different IP address may be used.

If you want to assign a public IP address to another ECS instance or retain a public IP address after an ECS instance is released, we recommend that you use EIPs. Compared with public IP addresses, EIPs are more flexible. You can associate EIPs with and disassociate EIPs from ECS instances as needed. You can also convert public IP addresses to EIPs.

References

  • Disassociate an EIP from an instance: If an instance no longer needs to use an EIP to access the Internet or you need to replace an EIP, we recommend that you disassociate the EIP from the instance.

  • AssociateEipAddress: associates an EIP with an instance in the same region.