Can I remove the public IP on my instance without terminating it?

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"


Steps worked for me:

  1. Disable auto assign public IP setting on vpc subnet.
  2. Stop the ec2 instance.
  3. Open Network Interface Manage IP address settings and assign a secondary private IP.
  4. Open Elastic IPs and associate an elastic IP to the ec2 with secondary private IP.
  5. Start the Ec2 Instace.
  6. Open Network Interface Manage IP address settings and unassign the secondary IP.
  7. Done, now you can release the previously associated elastic IP.

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:

  • If you change the subnet auto-assign setting and stop and start the instance, this does not work, it has no effect. The public IP remains.
  • If you got your public IP by associating an elastic IP then it's a different case and easy to fix; all you need to do is right-click on the instance or on the Elastic IP, and choose "Networking", "Disassociate Elastic IP Address")

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:

  1. Create a new network interface.
  2. Attach the new network interface to your instance. Now there will be two or more network interfaces attached to your instance. This is important. There MUST be two or more for this to work.
  3. Create a new Elastic IP (in the EC2 console).
  4. Right-click on the new EIP and associate it to the instance whose public IP you want to remove. The original public IP will be replaced by the new one.
  5. 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.

  6. 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."