This topic describes how to create an elastic IP address (EIP) and associate the EIP with an Elastic Compute Service (ECS) instance. This way, the ECS instance can access the Internet.

Prerequisites

An ECS instance is created. For more information, see Create an instance by using the wizard.
Note If your ECS instance is assigned a public IP address, you cannot associate an EIP with the ECS instance. You can convert the public IP address to an EIP, which is more flexible. For more information, see Convert the static public IP address of an ECS instance in a VPC to an EIP.

Procedure

Procedure

Apply for an EIP

An EIP is a public IP address that you can purchase and use as an independent resource. To get started, you must create an EIP.

  1. Log on to the Elastic IP Address console.
  2. On the Elastic IP Addresses page, click Create EIP.
  3. On the page that appears, set the following parameters, click Buy Now, and then complete the payment.
    Parameter Description
    Billing Method Select a billing method for the EIP. In this example, Pay-As-You-Go is selected.
    Region Select the region where you want to create the EIP.

    Make sure that the EIP and the ECS to be associated with the EIP are located in the same region.

    ISP Select a line type for the EIP. BGP (Multi-ISP) is selected in this example.
    Network Mode Select a network type for the EIP.

    You can select only Public.

    Network traffic Select a metering method for the EIP. By bandwidth is selected in this example.
    Max bandwidth Specify a maximum bandwidth value for the EIP. The value is set to 1 Mbit/s in this example.
    Name Enter a name for the EIP.

    The name must be 2 to 128 characters in length, and can contain digits, periods (.), underscores (_), and hyphens (-). It must start with a letter.

    Billing Cycle Select a billing cycle for the EIP.

    For pay-by-bandwidth EIPs, select Day. For pay-by-data-transfer EIPs, select Hour.

    Quantity Specify the number of EIPs that you want to purchase.

Associate an EIP with an ECS instance

You can associate the EIP with an ECS instance that is deployed in a virtual private cloud (VPC). ECS instances can communicate with the Internet after they are associated with EIPs.

  1. Log on to the Elastic IP Address console.
  2. In the top navigation bar, select the region where the EIP is deployed.
  3. On the Elastic IP Addresses page, find the EIP that you want to manage, and click Bind Resource in the Actions column.
  4. In the Bind Elastic IP Address to Resources dialog box, set the following parameters and click OK.
    Parameter Description
    Instance Type Select ECS Instance.
    Binding mode Select the mode in which you want to associate the EIP.
    You can select only Normal. In Normal mode:
    • The EIP is associated with the ECS instance in NAT mode. Both the private IP address and public IP address of the ECS instance are available.
    • The EIP is not displayed in the operating system. To query the public IP address of the ECS instance, call the DescribeInstances operation. For more information, see DescribeInstances.
    • The EIP does not support NAT application layer gateway (ALG) protocols such as H.323, Session Initiation Protocol (SIP), Domain Name System (DNS), Real Time Streaming Protocol (RTSP), or Trivial File Transfer Protocol (TFTP).
    Select an instance to bind Select the ECS instance with which you want to associate the EIP.
    Make sure that the following requirements are met:
    • The ECS instance is deployed in a VPC.
    • The ECS instance is in the Running or Stopped state.
    • Each ECS instance can be associated with only one EIP.
    • The ECS instance and the EIP are created in the same region.
    • The ECS instance is not assigned a static public IP address. In addition, the ECS instance is not associated with another EIP.

Test the connectivity

After you associate the EIP with the ECS instance, you can check whether the ECS instance can access the Internet.

  1. Log on to the ECS instance with which the EIP is associated.
  2. Run the ping command to test the connectivity between the ECS instance and the Internet.
    The test result shows that the ECS instance can access the Internet. Test the connectivity