×
☰ See All Chapters

How to allocate multiple IP address to AWS EC2 virtual machine

It can be useful to assign multiple IP addresses to an instance in your virtual machine to do the following:

  1. Host multiple websites on a single server by using multiple SSL certificates on a single server and associating each certificate with a specific IP address. 

  2. Operate network appliances, such as firewalls or load balancers, that have multiple IP addresses for each network interface. 

  3. Redirect internal traffic to a standby instance in case your instance fails, by reassigning the secondary IP address to the standby instance. 

To allocate additional IP address to EC2 instance you have to allocate additional network interface to virtual machine. Follow these steps to create an additional networking interface for your virtual machine:

Step 1: Open EC2 Network Interface management console

Open the EC2 service from Management Console and select Network Interfaces from the submenu.

 

multiple-ip-address-to-ec2-virtual-machine-0
 

The default network interface of your virtual machine is displayed in the list. Note the subnet ID of the network interface.

multiple-ip-address-to-ec2-virtual-machine-1
 

Step 2: Create Network Interface

Click on Create Network Interface.

multiple-ip-address-to-ec2-virtual-machine-2
 

Below screen is displayed to enter network interface details. Enter the description which is optional, select the subnet, when you focus on the Subnet input field it displays a drop down with list of available Subnet. Select the one you noted down in previous step.

multiple-ip-address-to-ec2-virtual-machine-3
 

Scroll to bottom, select the security group, click on Create network interface.

multiple-ip-address-to-ec2-virtual-machine-4
 

You can see the newly created network interface.

multiple-ip-address-to-ec2-virtual-machine-5
 

Step 3: Attach the new network interface to virtual machine

Select the newly created network interface, Open Actions menu and select Attach option.

multiple-ip-address-to-ec2-virtual-machine-6
 

Choose the only available Instance ID, and click Attach.

multiple-ip-address-to-ec2-virtual-machine-7
 

You should see success message as below:

multiple-ip-address-to-ec2-virtual-machine-8
 

Step 4: Attach the IP to newly attached network interface of virtual machine

Refer the previous chapter to allocate the IPR address from Elastic IP Addresses. In the previous chapter we associated the IP directly to Instance, but now there are two interfaces attached to virtual machine. Now we have to associate IP to network interface as shown below:

multiple-ip-address-to-ec2-virtual-machine-9
 

Select the newly created network interface click on Associate. Your virtual machine is now reachable under two different public IP addresses. Connect to your virtual machine using any one of the two IP address and run the command “ip addr show” which will display all the two IP address associated to machine.

multiple-ip-address-to-ec2-virtual-machine-10
 

All Chapters
Author