By using AWS re:Post, you agree to the Terms of Use
/EC2 instance doesn't get a new public IP after Elastic IP is disassociated/

EC2 instance doesn't get a new public IP after Elastic IP is disassociated

0

I recently had a need to attach an Elastic IP to an instance that previously had a Public IP - got tired of changing SSH keys whenever I rebooted as I was assigning the same private IP to the instance. However, the need for a static IP across reboots has now waned and I wanted to revert to the Public IP setting. However, after detaching the Elastic IP, the instance did not get another Public IP as stated in this document:

https://aws.amazon.com/premiumsupport/knowledge-center/ec2-recover-ip-address/

Instead, I had to resort to creating an AMI and launching a new instance with a Public IP. Is this now the only way to get a Public IP after an Elastic IP is detached?

ak2766
asked 4 days ago4 views
4 Answers
0

The reason why you can't get the public IP address when you detach the EIP you asked for the first time is also because the secondary ENI is attached.

And we will advise you on your additional questions.

I understand that you are attaching and detaching Elastic IP between nodes to achieve floating IP.

You can build a Network load Balancer for inbound and outbound to communicate by installing a NAT gateway in each AZ from the private subnet.

Or, if you just want to operate the AWS CLI while keeping the current configuration, how about using the VPC endpoint to operate the Elastic IP with private communication?

iwasa
answered 3 days ago
  • Thanks @iwasa. I'm new to load balancers on AWS so I'm going to have to go read about them before I proceed. Need to get a full understanding before I start migration of production workloads.

    I'll post back once my understanding is clear; will most likely accept this as the answer.

0

Hi, @ak2766

Detaching an Elastic IP address usually assigns it a public IP address.
Isn't it assigned even if stop → start?

In that case, you may have multiple ENIs attached to your EC2. In that case, the public IP address will not be automatically assigned when the Elastic IP address is detached.

https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts-public-addresses

If the public IP address of your instance in a VPC has been released, it will not receive a new one if there is more than one network interface attached to your instance.

You should detach the non-primary ENI once, stop EC2 and then start. You should be assigned a public IP address.

Then reattach the detached secondary ENI.

iwasa
answered 3 days ago
0

In general though If you require a persistent public IP address that can be associated to and from instances as you require, use an Elastic IP address instead of Public IP.

Tushar_J
answered 3 days ago
0

Thanks for all your answers and I see I'm in a bit of a quandary.

I'm in the process of setting up a highly available NFS cluster using BRDB across AZ's and hence need secondary interfaces as well as Elastic IP's. I was intending on making use of the OCF Heartbeat RA's - namely awseip and awsvip. The problem occurs when the floating IP is moved to another node. When that happens, the node can no longer reach the AWS API via AWSCLI since there's no longer an IP address that can reach the Internet. Currently, I'm forced to do it all in the same node AZ but that means if the AZ is down, then so too is that "highly (un)available" NFS cluster.

Out of the box thinking will be required here.

ak2766
answered 3 days ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions