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. Before you get started, you must apply for an EIP.

  1. Log on to the Elastic IP Address console .
  2. On the Elastic IP Addresses page, click Create EIP.
  3. On the Elastic IP page, 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 instance to be associated with the EIP belong to the same region.

    Line Type Select a line type for the EIP. In this example, BGP is selected.
    Network Type Select a network type for the EIP.

    You can select only Internet.

    Data Transfer Select a metering method for the EIP. In this example, Pay-By-Bandwidth is selected.
    Maximum Bandwidth Specify a maximum bandwidth value for the EIP. In this example, the value is set to 1 Mbit/s.
    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 (-). The name must start with a letter.

    Billing Cycle Select a billing cycle for the EIP.

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

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

Associate the EIP with an ECS instance

You can associate the EIP with an ECS instance that is deployed in a virtual private cloud (VPC). After the ECS instance is associated with an EIP, the ECS instance can communicate with the Internet.

  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 want to manage, and click Bind 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.
    Mode Select the mode in which you want to associate the EIP.
    You can select only NAT Mode. In NAT mode:
    • The private IP address and public IP address of the ECS instance with which the EIP is associated are available for use.
    • The EIP is not displayed in the operating system. To query the EIP of the ECS instance, call the DescribeInstances operation. For more information, see DescribeInstances.
    • The EIP does 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).
    Select an instance to associate. 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.
    • The ECS instance and the EIP are created in the same region.
    • The ECS instance is not assigned a static public IP address or associated with an EIP.
      Note Each ECS instance can be associated only with one EIP.

Test network 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 network connectivity