AWS Elastic IP

Filed Under: AWS
AWS Elastic IP

To understand the use of AWS Elastic IP, please read our post on Amazon EC2 to get an idea of an elastic compute cloud.

Amazon EC2 – Elastic Compute Cloud and Amazon VPC – Virtual Private Cloud both supports IP4 and IPv6 addressing protocols. When you create a VPC, you must specify the IPv4 CIDR block (a range of IP addresses). By default Amazon EC2 and VPC use the IPv4 addressing protocols, You can not override or change this behavior.

Let’s discuss the default behavior of IP addresses to understand the need for AWS Elastic IP:

Private IPv4 Address

Private IPv4 addresses are used to communicate between instances within the same VPC. You cannot connect to another VPC and so the Internet. A private IPv4 is not reachable over the internet.

When we launch an EC2 instance, AWS gives and assign a private IPv4 address for the instance. Each instance is also assigned a DNS that resolves the primary IPv4 address.

For more, please read our detailed post on Amazon VPC.

Public IPv4 Address

Using the public IP address of the instance, you can communicate to the internet. A public IPv4 address is an address which is reachable from the internet.

When we launch an instance in a default VPC, AWS allocate a public IPv4 address and DNS associated with the public IP address; for example, ec2-112-34-123-22.compute-2.amazonaws.com can be the DNS for your public IP address which resolves the public IPv4 address.

What is AWS Elastic IP Address?

AWS Elastic IP is a public IPv4 address that you can allocate to your instance. You can associate an elastic IP address to your instance and it will be associated until you will remove it manually.

AWS elastic IP address is static IP address and designed for dynamic compute cloud. As it is a public IPv4 address so it’s reachable to the internet as well. By associated this IP address to your instance, you can enable access to the instance from your local machine.

Why AWS Elastic IP Address?

The question is when AWS allocate a public IPv4 address for each instance by default then what is the need for an additional IPv4 address. Let’s discuss this:

A public IP address is assigned to your instance from Amazon’s pool of IPv4 addresses. Public IPv4 address is not associated with your AWS account. It goes back to Amazon’s pool once released or disassociated from the instance.

You cannot manually associate or disassociate the public IP address to your instance. AWS does it on behalf of you. There are certain events when your public IP address releases from your instance:

  • When your instance is stopped or terminated, the public IP address gets released. AWS assigns a new public IP address when it is restarted
  • Public IP address is released when you assign an Elastic IP address. When you disassociate the Elastic IP address, AWS assigns a public IPv4 address from its pool

There are more cases but these two are common and important for us to understand. The first case is important for the application running on EC2 and you are accessing through IP address.

Each time your instance restarts, stopped or terminated the public IP address will change. If you have configured the IP address in your hosting account then it makes difficult to change the IP address on each event.

An elastic IP address is a solution to this problem. AWS Elastic IP addresses are associated with your AWS account and it doesn’t change.

Allocate an Elastic IP Address

You can allocate an IPv4 address to your AWS account from Amazon’s pool of IPv4 addresses. Let’s use the AWS Management console to allocate an Elastic IP address:

  1. Sign in to the AWS management console https://aws.amazon.com/console/
  2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
  3. In left navigation, go to “NETWORK & SECURITY” and “Elastic IPs”.
    Elastic Ips Option

    Elastic Ips Option

  4. Choose Allocate new Address – See the below screenshot for your reference. Elastic IP address are region specific.
    Allocate New Address Panel

    Allocate New Address Panel

  5. For IPv4 address pool, choose Amazon pool
    Allocate New Address

    Allocate New Address

    You can choose “Owned by me” if you have an IP address in your own pool. We are going to choose the “Amazon Pool” as we do not have our own IPv4 pool.

  6. Choose Allocate, and close the confirmation screen – AWS will take few seconds to allocate the public IPv4 address from its pool as Elastic IP.

    Allocated Ip Address

    Allocated Ip Address

Tagging an Elastic IP Address

Tagging is used to identify your Elastic IP address. You can assign custom tags(a key, value) pair to categorize them. Categorization is completely depended on how you want to use them, for example, environment, purpose or owner.

  1. Sign in to the AWS management console https://aws.amazon.com/console/
  2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
  3. In left navigation, go to “NETWORK & SECURITY” and “Elastic IPs”.
  4. Go to the actions and choose “Add/Edit Tags”
  5. In the Add/Edit Tags dialog box, choose Create Tag, and then specify the key and value for the tag.

Associating AWS Static IP with EC2 instance

Now, you can associate the Elastic IP address to your running instance. AWS will release the public IPv4 address which is currently associated with EC2 instance and associate the Elastic IP address.

Please follow below steps:

  1. Sign in to the AWS management console https://aws.amazon.com/console/
  2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
  3. In left navigation, go to “NETWORK & SECURITY” and “Elastic IPs”.
  4. Select an Elastic IP address and choose Actions, Associate address
  5. You will see the below dialog:

    Associate Elastic Ip

    Associate Elastic Ip

    Choose the instance from the running instances. AWS will automatically select the private IP address for your instance.

    If your Elastic IP address is associated with any other instance then select to reassociate check box. Now click associate address.

AWS will take a few seconds/minutes to associate the Elastic IP address to your running instance. You would be able to see the Elastic IP address association in EC2 properties.

Disassociating from EC2 instance

You can disassociate an Elastic IP address which is currently assigned to an EC2 instance. You can do it by assigning to any other EC2 instance, in this case, you just need to follow the steps above.

If you just want to disassociate not reassociate then follow the below steps:

  1. Sign in to the AWS management console https://aws.amazon.com/console/
  2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
  3. In left navigation, go to “NETWORK & SECURITY” and “Elastic IPs”.
  4. Select an Elastic IP address and choose Actions, Diassociate address
  5. You will see a dialog, click on the “Disasscociate address” button

AWS will take few seconds to disassociate the Elastic address from your running EC2 instance.

Release Elastic IP Address

If you no longer need the Elastic IP address then you can release it from your account. Please make sure that you have disassociated the Elastic IP address from your EC2 instance.

Please follow the below steps:

  1. Sign in to the AWS management console https://aws.amazon.com/console/
  2. Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/
  3. In left navigation, go to “NETWORK & SECURITY” and “Elastic IPs”.
  4. Select the Elastic IP address, choose Actions, and then select Release addresses. Choose Release when prompted.

    Release Elastic Ip Address

    Release Elastic Ip Address

AWS will take a few seconds and your Elastic IP address will be released.

AWS does not support Elastic IP address with IPv6. The limit of Elastic IPv4 address per account is limited to 5 per region.

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages