All Products
Search
Document Center

Elastic IP Address:Associate an EIP with an ECS instance

更新時間:Jan 15, 2024

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

  • 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.

For more information about how to create an ECS instance, see Create an instance by using the wizard.

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

    Description

    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.

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 a 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.

References

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