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 communicate with the Internet.
Prerequisites
An ECS instance is created. For more information, see Create an instance on the Custom Launch tab.
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
Step 1: Apply for an EIP
An EIP is a public IP address that you can purchase and use as an independent resource. Before you use an EIP, you must apply for an EIP.
- Log on to the Elastic IP Address console .
On the Elastic IP Addresses page, click Create EIP.
On the buy page, set the following parameters for the EIP, 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 (Multi-ISP) is selected.
Network Type
Select a network type for the EIP.
You can select only Internet.
Security Protection
Select an edition of Anti-DDoS based on your business requirements. Default is selected in this example.
IP Address Pool
Select an IP address pool. Default is selected in this example.
Data Transfer
Select the metering method of the EIP. In the example, Pay-By-Bandwidth is selected.
Maximum Bandwidth
Specify a maximum bandwidth value for the EIP. In this example, 1 Mbit/s is used.
Name
Enter a name for the EIP.
Resource Group
Select the resource group to which the EIP belongs.
Billing Cycle
Select a billing cycle for the EIP.
You can select only Day for a pay-by-bandwidth EIP.
Quantity
Specify the number of EIPs that you want to purchase.
Step 2: 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 EIP is associated with an ECS instance, the ECS instance can communicate with the Internet.
- Log on to the Elastic IP Address console .
In the top navigation bar, select the region where the EIP is created.
On the Elastic IP Addresses page, find the EIP that you created and click Associate with Resource in the Actions column.
In the Associate EIP with Resource dialog box, set the following parameters and click OK.
Parameter
Description
Instance Type
Select ECS Instance.
Select an instance to associate.
Select the ECS instance to be associated with the EIP.
The ECS instance that you select must meet 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.
NoteEach ECS instance can be associated with only one EIP.
Step 3: Test the network connectivity
After you associate the EIP with the ECS instance, you can check whether the ECS instance can communicate with the Internet.
Log on to the ECS instance associated with the EIP.
For more information about how to log on to an ECS instance, see Connection method overview.
Run the following command to test whether the ECS instance can communicate with the Internet.
ping <a public domain name>
The test result shows that the ECS instance can communicate with Internet.
References
AllocateEipAddress: applies for an EIP.
AssociateEipAddress: associates an EIP with an instance in the same region.
ReleaseEipAddress: releases an EIP.