How to unassign public ipv4 from ec2 instance?

0

Hi there,

I've faced the issue and not sure if it's some kind of AWS bug or an issue with my configs.

I've instance running "i-ххххххххххххххххх" which has a public Ipv4 but I'm not sure why since the assigned subnet "subnet-fffffffffffffffffff" that has an option "Auto-assign public IPv4 address" set as "No". EC2 instance - https://monosnap.com/file/cnJHmifqYSPErD6q3FyZ2qDPlWOaaL Subnet - https://monosnap.com/file/ac5h2WCOZ6bHr54FX21FVVVyAdLb60

Later on, I discovered that the community cloud formation template I was using contained this - https://monosnap.com/file/llLq5fTWnbpBxHzXV4DPoAXIEJkyt5 AssociatePublicIpAddress set as True.

So, my question now is: are there any options for how I can unassing public Ipv4 from instance?

I tried to stop the instance and see if there will be any option to unassing public IP but it's just not present here in this case - https://monosnap.com/file/c6efk9vHAAq3kdbaRKQGNWofUdpjSF But when I start the instance back - it immediately appears.

Please advise.

Gridics
asked 5 months ago1300 views
1 Answer
1
Accepted Answer

Hello.

I hope the answers below will be helpful.
https://repost.aws/questions/QUVmpO9BWGSuGwQh5tXk3f5w/how-to-remove-ipv4-public-ip-address-from-ec2-instances-before-february-2024-ipv6#ANIgCHiXgQSdSiHc1wgH-6fA

  1. Create an ENI and attach it to the instance.
  2. Allocate an Elastic IP address using the below doc[1]
  3. Associate the Elastic IP to the primary ENI that has the public IP of the instance[2].
  4. Refresh the browser page and observe the instance public IP has changed to the new Elastic IP address.
  5. Disassociate the Elastic IP address from the primary ENI by following the below doc[3]
  6. Refresh the browser page again, and observe the instance public IP has been removed.
  7. Release the Elastic IP[4] and detach the ENI attached by the step #1.

References:
[1] Elastic IP addresses - Allocate an Elastic IP address - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html#using-instance-addressing-eips-allocating
[2] Elastic IP addresses - Associate an Elastic IP address with an instance or network interface - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html#using-instance-addressing-eips-associating
[3] Elastic IP addresses - Disassociate an Elastic IP address - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html#using-instance-addressing-eips-associating-different
[4] Elastic IP addresses - Release an Elastic IP address - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html#using-instance-addressing-eips-releasing

profile picture
EXPERT
answered 5 months ago
profile picture
EXPERT
reviewed 3 months ago
profile picture
EXPERT
reviewed 5 months 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