Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Re-assign private IP address in AWS?

Tags:

I have an AWS instance running behind an elastic IP. The instance also has a private IP address in my VPC. I will be re-assigning the elastic IP to another instance and am trying to re-assign the private IP as well. Note that the instance only has one private IP (no secondary).

Is this possible?

like image 371
Hadi Avatar asked Dec 10 '15 18:12

Hadi


People also ask

How do I change my private IP on AWS?

From the Networking tab, Expand Network interfaces, and then choose the Interface ID. Select the Network interface ID, Choose Actions, and then choose Manage IP Addresses. The primary private IPv4 IP address is already listed. Expand the network interface ID, and then choose Assign new IP address.

Can we change private IP of EC2 instance while running?

The private IP address of an Amazon EC2 instance will never change. It will not change while an instance is running. It will not change while an instance is stopped. You cannot change a private IP address.

Does EC2 private IP changes after reboot?

Actually, When you stop/start your instance, the IP address will change. If you reboot the instance, it will keep the same IP addresses. Unfortunately, it is not possible for us to reassign the address to your instance as that address would have been released back into the pool used by other EC2 instances.


2 Answers

If you have an existing instance with the private IP you want (EXAMPLE: 10.0.0.101). You should take an image (AMI) and then terminate that instance. Because it is in a VPC, just stopping it won't free the private IP.

Once you have a good image, terminate it. That would free up its Private IP Address. Thus you would have (10.0.0.101) available

Then assign a secondary private IP to your new instance that you want and specify the private IP to be the one you want it to be (10.0.0.101)


To assign a secondary private IP to an existing instance

Open the Amazon EC2 console at https://console.aws.amazon.com/ec2/.

In the navigation pane, choose Network Interfaces, and then select the network interface attached to the instance.

Choose Actions, and then select Manage Private IP Addresses.

In the Manage Private IP Addresses dialog box, do the following:

Choose Assign new IP.

Enter a specific IP address that's within the subnet range for the instance, or leave the field blank and we'll select an IP address for you.

(Optional) Select Allow reassignment to allow the secondary private IP address to be reassigned if it is already assigned to another network interface.

Choose Yes, Update, and then choose Close.

Note that alternatively, you can assign a secondary private IP address to an instance. Choose Instances in the navigation pane, select the instance, choose Actions, select Networking, and then select Manage Private IP Addresses. You can configure the same information in the dialog as you did in the steps above.

like image 36
greg_diesel Avatar answered Oct 02 '22 14:10

greg_diesel


Unless this is a 'secondary private ip address' (and you said it was not), then no, you can't:

You can assign additional private IP addresses, known as secondary private IP addresses, to instances that are running in a VPC. Unlike a primary private IP address, you can reassign a secondary private IP address from one network interface to another. For more information about primary and secondary IP addresses, see Multiple IP Addresses in the Amazon EC2 User Guide for Linux Instances.

http://docs.aws.amazon.com/AmazonVPC/latest/UserGuide/vpc-ip-addressing.html

like image 151
E.J. Brennan Avatar answered Oct 02 '22 14:10

E.J. Brennan