How to Associate and Disassociate an Elastic IP to an EC2 Instance

How to Associate and Disassociate an Elastic IP to an EC2 Instance

AWS EC2 is a scalable, reliable and low-priced offering from Amazon for the user’s virtual computation or hosting needs. Elastic IP addresses are static IP addresses designed for elastic cloud computing. The traffic routed to the Elastic IP is translated via the 1:1 Network Address Translation (NAT) and forwarded to the Private IP address of an instance. Unlike a standard EC2 Public IP address, Elastic IP addresses are allocated to accounts and can be remapped to other instances when desired. The user can control this address until choosing to explicitly release it. Elastic IP addresses help the user to achieve high availability as it allows programmatic remapping to any other instance in the same region on the current instance or availability zone failure.

The present guide demonstrates how to associate or disassociate an Elastic IP to an instance.

1. Go to the AWS Console and select the EC2 Service. It will list the AWS dashboard. It lists the current running instances, snapshots and elastic IPs. Click on the “Running Instance? link or the “Instances? link in the left navigation menu.

2. The EC2 Instances dashboard displays all the instances of that region. When the instance is launched, AWS assigns a public IP to the instance. It is an Internet routable IP address assigned by the system for all instances, which routes traffic to the internal IP. The instance is accessible through the public DNS of the instance over the internet.

3. Go to Elastic IP dashboard by clicking on the “Elastic IP? in step#1. It lists all the Elastic IPs of that region. Select an elastic IP to be assigned to the instance and click on the “Associate Address? button.


[Newvem continuously tracks and analyzes complete resources utilization patterns, and provides a down-to-the-hour picture of your AWS consumption and usage behavior, as well as future capacity estimates. Learn more about Newvem's featuers]


4. It asks for the instance which will be associated with this IP. Select the instance from the list and click on “Yes, Associate?.

5. It will associate the elastic IP to that instance. Go to Instance dashboard and select the instance. The IP of the instance is updated to the elastic IP.

6. To disassociate the instance, select the instance and click on “Disassociate IP Address? from the Actions menu.

7. AWS will ask for a confirmation before disassociating the address. Click on “Yes, Disassociate?.

8. The elastic IP address associated with the instance will be disassociated. The above mentioned IP can be reassigned to any other instance. If the IP address is unassigned, it will cost the user. Release the IP address if the user does not require it, as explained in How to allocate or release an Elastic IP on AWS. Removing the Elastic IP from an instance temporarily leaves the instance without a Public IP address. A background process in the cloud will re-assign a new Public IP to the instance after a short period of time. The instance will remain reachable from within the cloud on its private IP address during the above mentioned process.

The figure given below demonstrates the instance with the new public IP after the elastic IP has been disassociated.

9. To run the above mentioned steps through the command line interface, first setup AWS EC2 CLI to launch an instance with the command line option, as explained in How to install AWS CLI to Windows.

10. Run the following command to allocate an elastic IP: 

ec2-allocate-address --region us-west-2

To  list all the elastic IP addresses of that region:

ec2-describe-addresses --region us-west-2

11. Run the following command to list all the instances of that region:

ec2-describe-instances  --region us-west-2

12. To associate an elastic IP with the instance:

ec2-associate-address -i <instance ID> <elastic IP Address> --region <region name>

To describe the properties of the instance including the public DNS:

ec2-describe-instances <instance ID> --region <region>

To disassociate the elastic IP from the instance:

ec2-disassociate-address <elastic IP> --region <region>

As explained in step#8, when the elastic IP is disassociated, temporary instance will not have the public IP address. A background process will assign the elastic address to the instance in some time.


[Newvem analytics tracks you AWS cloud utilization:

Get Started with Newvem for free or learn more about Newvem's features]


Keywords: Amazon AWS elastic cloud services, AWS Console, AWS Cloud Utilization, Amazon S3, EC2 CLI, Amazon Web Services, AWS EC2, Elastic IP, EC2 Instances

You must be to post a comment.

* As a bonus, you'll receive our weekly newsletter!

Hitchhiker's Guide to The Cloud

Newvem's eBook for Cloud Operations