There was a time when I was creating an EC2, I accidentally created it with an IPv4 where I do not want to actually. But I have already set everything up in the server and do not want to go through the trouble of image the EC2 and provision a new EC2 out of it. After some googling and I did found an alternative way solving this problem and that is what post is about. The steps are simple.
Steps:
- Create a new NIC and attach to the EC2
- Allocate a new EIP and attach to the EC2
- Remove the EIP. That’s it!
Do remember to release the EIP OR YOU WILL BE CHARGED!
When you remove the EIP from EC2, the originally assigned IPv4 is removed along the way. I do not know/understand how it works in the background. I just know it works.
I won’t post the whole process but just some important steps, let’s get started!
Create a new NIC.
Remember to select the subnet where your EC2 resides while creating the NIC.
Attach the new NIC to the EC2.
Create new EIP.
Create a new EIP and associate it with the EC2.
Now we can see that the EC2 has 2 private IPs and the public IP and EIP are the same.
Let’s remove the EIP.
Check the EC2 again and we will see that public IP and EIP are all gone!
Lastly, delete the extra NIC and release EIP. Once again, please do remember to release the EIP or you will be charged for it!