Introduction
In this article, I will demonstrate how to use Amazon Web Services Elastic IPs in EC2 instance.
Currently, when an EC2 instance is stopped and started again, it loses its IP address and a new one gets assigned to it. An Elastic IP will help to solve this problem.
Prerequisites
- Basic understanding of AWS and Cloud technologies.
- An active AWS account.
What is Elastic IP
An Elastic IP address is a static IPv4 address designed for dynamic cloud computing. An Elastic IP address is associated with your AWS account. With an Elastic IP address, you can mask the failure of an instance or software by rapidly remapping the address to another instance in your account.
An Elastic IP address is a public IPv4 address, which is reachable from the Internet. If your instance does not have a public IPv4 address, you can associate an Elastic IP address with your instance to enable the communication with the Internet. For example, to connect to your instance from your local computer.
AWS currently does not support Elastic IP addresses for IPv6.
Creating an Elastic IP
Log in to your AWS console. In AWS Services, go to Compute, followed by clicking on EC2.
Now, on the left side menu, in the Network & Security section, click on Elastic IPs.
The elastic IP page opens. Now, click Allocate new address.
The page given below then opens. Now, click again on Allocate to proceed.
It will then create an IP address for you.
Assigning an Elastic IP to your EC2 instance
- First, create an EC2 instance to which we can assign this elastic IP.
- Now, go back to Elastic IPs page. Select the required Elastic IP and click on the actions dropdown, followed by clicking Associate address.
- The page given below opens, which allows you to associate an Elastic IP with either an EC2 instance or a network instance.
- It lets you select an instance in resource type and in the instance textbox, select the required EC2 instance.
- If your Elastic IP is associated with another instance and you want to associate it with this instance, then you need to tick Allow Elastic IP to be reassociated, if already attached.
- Finally, click Associate to attach IP to the instance.
Delete an Elastic IP
- Go to the Elastic IP page, select Elastic IP and click release addresses.
Elastic IP cost
There is currently no charge for using elastic IPs with your ECs instance as long as the instance is running. More pricing information is available at https://aws.amazon.com/ec2/pricing/on-demand/ , https://aws.amazon.com/premiumsupport/knowledge-center/elastic-ip-charges/ .
REFERENCES
http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html
http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-eips.html