Multiple Elastic IP for Amazon EC2 Instance

How to set up multiple Elastic IP for Amazon EC2 Instance

How to set up multiple Elastic IP for Amazon EC2 Instance


If you want to host multiple Web Applications in a single Amazon EC2 Instance with different public IP, then this tutorial will be helpful.

Topics covered:

1. Elastic IP Address overview.
2. Working with Elastic IP Addresses.

2.1. Acquire an Elastic IP address.

2.2 Associate an Elastic IP address with an instance or network interface

2.3. Describe one or more Elastic IP addresses

2.4. Tag an Elastic IP address

2.5. Disassociate an Elastic IP address

2.6. Release an Elastic IP address

In this tutorial we will create multiple elastic IP address for the Amazon EC2 Instance. Our goal is to host two or more Web Application in a single Amazon EC2 Instance with different public IP address. This step by step guide is a part of our series on How to set up multiple elastic ip for Amazon EC2 Instance.

Also refer the following tutorials before going through creating multiple elastic IP address.

Steps to set up multiple Elastic IP for Amazon EC2 Instance

1. Create custom VPC in Amazon AWS

2. Create custom Security Groups in Amazon AWS

3. Launch an Amazon AWS Instance with Custom VPC

What is Elastic IP Addresses?

An Elastic IP address is a static, public IPv4 address designed for dynamic cloud computing. You can associate an Elastic IP address with any instance or network interface for any VPC in your account. With an Elastic IP address, you can mask the failure of an instance by rapidly remapping the address to another instance in your VPC. Note that the advantage of associating the Elastic IP address with the network interface instead of directly with the instance is that you can move all the attributes of the network interface from one instance to another in a single step.


You first allocate an Elastic IP address for use in a VPC, and then associate it with an instance in your VPC (it can be assigned to only one instance at a time).

An Elastic IP address is a property of network interfaces. You can associate an Elastic IP address with an instance by updating the network interface attached to the instance.

If you associate an Elastic IP address with the eth0 network interface of your instance, its current public IPv4 address (if it had one) is released to the EC2-VPC public IP address pool. If you disassociate the Elastic IP address, the eth0 network interface is automatically assigned a new public IPv4 address within a few minutes. This doesn't apply if you've attached a second network interface to your instance.


There are differences between an Elastic IP address that you use in a VPC and one that you use in EC2-Classic. For more information, see Elastic IP Address Differences Between EC2-Classic and Amazon EC2-VPC in the Amazon EC2 User Guide for Linux Instances).

You can move an Elastic IP address from one instance to another. The instance can be in the same VPC or another VPC, but not in EC2-Classic.

Your Elastic IP addresses remain associated with your AWS account until you explicitly release them.

To ensure efficient use of Elastic IP addresses, we impose a small hourly charge when they aren't associated with a running instance, or when they are associated with a stopped instance or an unattached network interface. While your instance is running, you aren't charged for one Elastic IP address associated with the instance, but you are charged for any additional Elastic IP addresses associated with the instance. For more information, see Amazon EC2 Pricing.

You're limited to five Elastic IP addresses; to help conserve them, you can use a NAT device (see NAT).

An Elastic IP address is accessed through the Internet gateway of a VPC. If you have set up a VPN connection between your VPC and your network, the VPN traffic traverses a virtual private gateway, not an Internet gateway, and therefore cannot access the Elastic IP address.

You can move an Elastic IP address that you've allocated for use in the EC2-Classic platform to the VPC platform. For more information, see Migrating an Elastic IP Address from EC2-Classic to EC2-VPC in the Amazon EC2 User Guide.

You can tag an Elastic IP address that's allocated for use in a VPC; however, cost allocation tags are not supported. If you recover an Elastic IP address, tags are not recovered.

Working with Elastic IP Addresses

You can allocate an Elastic IP address and then associate it with an instance in a VPC.

To allocate an Elastic IP address for use in a VPC

1. Open the Amazon VPC console and navigate to Elastic IPs.

2. Choose Allocate new address.

3. Choose Allocate.

To view your Elastic IP addresses

1. Open the Amazon VPC console and navigat to Elastic IPs.

2 . To filter the displayed list, start typing part of the Elastic IP address or the ID of the instance to which it's assigned in the search box.

To associate an Elastic IP address with a running instance in a VPC

1. Open the Amazon VPC console and navigate to Elastic IPs.

2. Select an Elastic IP address that's allocated for use with a VPC (the Scope column has a value of vpc), choose Actions, and then choose Associate address.

3. Choose Instance or Network interface, and then select either the instance or network interface ID.

4. Select the private IP address with which to associate the Elastic IP address. Choose Associate.

Note

A network interface can have several attributes, including an Elastic IP address. You can create a network interface and attach and detach it from instances in your VPC. The advantage of making the Elastic IP address an attribute of the network interface instead of associating it directly with the instance is that you can move all the attributes of the network interface from one instance to another in a single step. For more information, see Elastic Network Interfaces.

After you associate the Elastic IP address with your instance, it receives a DNS hostname if DNS hostnames are enabled. For more information, see Using DNS with Your VPC.

You can apply tags to your Elastic IP address to help you identify it or categorize it according to your organization's needs.

To tag an Elastic IP address

1. Open the Amazon VPC console and navigation Elastic IPs.

2. Select the Elastic IP address and choose Tags.

3. Choose Add/Edit Tags, enter the tag keys and values as required, and choose Save.

To change which instance an Elastic IP address is associated with, disassociate it from the currently associated instance, and then associate it with the new instance in the VPC.

To disassociate an Elastic IP address

1. Open the Amazon VPC console and navigate to Elastic IPs.

2. Select the Elastic IP address, choose Actions, and then choose Disassociate address.

3. When prompted, choose Disassociate address.

If you no longer need an Elastic IP address, we recommend that you release it (the address must not be associated with an instance). You incur charges for any Elastic IP address that's allocated for use with a VPC but not associated with an instance.


To release an Elastic IP address

1. Open the Amazon VPC console and navigate to Elastic IPs.

2. Select the Elastic IP address, choose Actions, and then choose Release addresses.

3. When prompted, choose Release.

If you release your Elastic IP address, you might be able to recover it. You cannot recover the Elastic IP address if it has been allocated to another AWS account, or if it results in you exceeding your Elastic IP address limit.