×
Community Blog How to Attach an Elastic IP on Your Alibaba Cloud ECS Instance

How to Attach an Elastic IP on Your Alibaba Cloud ECS Instance

This article describes how to attach an Elastic IP to your Alibaba Cloud ECS instance.

By Alain Francois

Major cloud providers mainly offer two types of IP addresses for your cloud instances or network, Public IP and Elastic IP (EIP). Elastic IPs are the most popular when you want your instance to be reachable with the same address all the time (even if the instance is restarted).

What Is an Elastic IP (EIP)?

An EIP is a NAT IP address located in the Internet gateway of Alibaba Cloud and mapped to the associated cloud resource through NAT. An EIP allows you to migrate IP addresses to Alibaba Cloud with insignificant changes to the system architecture. After an instance is released, its associated EIP is retained so that you can bind it later to another resource. An EIP can be associated with an Elastic Compute Service (ECS) instance, an internal-facing Server Load Balancer (SLB) instance, a secondary elastic network interface (ENI), a NAT gateway, or a high-availability virtual IP address (HAVIP) in the same region. The ECS instance and internal-facing SLB instance must be deployed in a virtual private cloud (VPC).

Requirements to Attach an EIP to an ECS Instance

Some requirements must be fulfilled to associate an Elastic IP to an ECS instance:

  • The ECS instance and EIP belong to the same region
  • The ECS instance is not associated with a public IP address or another EIP
  • 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

Purchase an Elastic IP

You need an Alibaba Cloud account to purchase an Elastic IP (EIP). If you don't have an account yet, you can get a coupon to create one during the March Mega Sale. Log in to the panel and go to the Elastic IP service:

1

Let‘s create an EIP:

2

You must purchase the EIP in the same region as your instance:

3

Confirm your order:

4

After purchasing your EIP, you can see your EIP:

5

After your EIP has been purchased, you can create an ECS instance.

Create an ECS

After purchasing the EIP, you need to create an ECS instance without a Public IP. It is required to bind an EIP to an ECS. Go to Elastic Compute Service (ECS):

6

On the left panel, scroll to Instances & Images and select Instances to create a new ECS instance:

7

Before you start, we recommend using a Linux ECS instance with root privileges and a minimum of 4GB RAM and 2vCPU cores for basic comfortable operations. We will create a Pay-As-You-Go instance with 2 vCPU and 4 GB memory:

8

You can select the operating system and define the disk size:

9

Select the VPC that will be used for your instance and the Security Group. Note: You must not assign a public IP:

10

Configure if you will access your ECS with a password or a public key:

11

In the next step, select the default resource group:

12

You will see a review of your ECS configuration and order. There is a remark saying we didn't assign a public IP:

13

Now, you can see your new instance:

Log into your console and install a web service to check if the Elastic IP is working. You can follow our guide on the installation of a LEMP server.

Finally, you can see your ECS with the private IP only:

14

Attach the EIP to the ECS Instance

As stated previously, you can attach an EIP to some resources. You can directly attach the IP to the instance via the ECS itself. Stay on the list of the ECS and click on the three dots to open the menu:

15

Go to the VPC service and EIP. This is the best way to see the other EIP association possibilities besides ECS:

16

You can see the different options offered for an EIP association. Select the ECS type. All the ECS instances detected will be listed so you can select the new ECS:

17

The EIP is assigned now:

18

Go to the ECS and see if the binding is effective:

19

The EIP is attached to the ECS instance. Open your browser and enter the EIP to access the Nginx default page http://8.211.37.122:

20

Related Articles

Public IP vs. Elastic IP: What Is the Best Choice?

When hosting your services on the cloud, you need your services to be reachable. However, depending on some requirements, you need to be careful about the type of IP you need to assign. Major cloud providers offer some types of IP addresses that you can assign to your cloud instances, such as the Public IP and the Elastic IP (EIP).

0 0 0
Share on

Alibaba Cloud Community

872 posts | 198 followers

You may also like

Comments

Alibaba Cloud Community

872 posts | 198 followers

Related Products