Reputation: 4479
I have several instances on a vpc that communicate with each other through their private ips. Each instance was launched sometime ago and assigned a random public IP which is not used for anything. Since anything that is public presents a vulnerability and they are not used at all, I would like to removed them.
Is it possible to Remove public Ip Addresses without terminating the instance?
Upvotes: 47
Views: 84610
Reputation: 333
Amazon now brings this option that you can remove the auto-assigned public ipv4 from AWS EC2 NIC console. Please do the following steps to remove the public IPV4.
Upvotes: 5
Reputation: 249
Below worked
create temp-priv-ni same subnet private interface use default security group
eni-xx-temp-priv-ni
allocate new public elastic ip
associate new public elastic ip to instance
attach eni-xx-temp-priv-ni to same instance
check instance has two private ips and new public elastic ip and past public eip is gone
then
disassociate public eip
go to instance network interfaces and detach eni-xx-temp-priv-ni
server will be now with same private ip and its public ip gone
the new public ip and new private ips can be deleted
Upvotes: 0
Reputation: 1833
Steps worked for me:
Upvotes: 5
Reputation: 1466
Yes you can remove a public IP address from an instance.
This solution applies when your instance was launched in a subnet with the "auto-assign public IP" setting enabled. This makes AWS add a public IP address that seems hard to remove.
Notes:
There is a voted-down solution here that seems to work at first, but the public IP comes back (as a different address) when you start the instance up again.
Solution: (detailed steps below)
You need to first add another Network Interface, (so there are two or more N.Is), then you can release the public address by adding and removing an elastic IP.
Here is a detailed step-by-step guide:
Now do the reverse of step 4, disassociate the EIP you have just added. At this point, right-click on the instance and select "Networking", "Manage IP addresses", you will see there are no public IPs on you instance any more. at this point. You must refresh the instances view otherwise you will not see this.
The public IP is now gone for good. Even if you stop and start the instance, it will not return.
Tidy up: delete the elastic IP you created earlier. Don't delete the new extra Network Interface. This has to stay in place. If you remove the new / second NI then the public IP will come back the next time you stop and start the instance.
I know this sounds a bit strange, but it is in the AWS docs here and I've tested it and it works.
The relevant part from the AWS documentation on that page, is this: "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."
Upvotes: 45
Reputation: 11
It is a very old thread but the easiest way of removing a public ip associated via VPC settings is:
Upvotes: -3
Reputation: 14523
Nope that is not possible without terminating the instance. If it was Elastic Ip then it would have worked.
The only option is Take AMI of the instance, terminate the instance and launch the AMI in the VPC without enabling Public Ip address for that instance.
Once you terminate the instance with that private IP you can assign that private ip again to a new Instance you created from the Image. (As long as it's in the same VPC and subnet) This way you don't need to update the private IPs off all the "instances on a vpc that communicate with each other through their private ips"
Upvotes: 26