Reading Amazon's documentation it appears that the default behavior for an EC2 instance to to release the current IP address and reassign a new one at some point in the processes depending on whether you are using Classic or VPC:

EC2-Classic: We release the public and private IPv4 addresses for the instance when you stop the instance, and assign new ones when you restart it.

EC2-VPC: The instance retains its private IPv4 addresses and any IPv6 addresses when stopped and restarted. We release the public IPv4 address and assign a new one when you restart it.

In my environment it would be nice if I could find a way to retain the IP address. Does anyone know of a way to do this with EC2 instances?

  • 2
    Specifically provision an elastic IP and attach it to the instance. – ceejayoz May 10 '17 at 18:56

Assign an Elastic IP to your instance. That IP is yours until you release it. Stop, start, terminate, reassign to a different instance, you can do whatever you like.

Elastic IPs are free, but cost a small amount if they're not attached to a running instance.

There's no way to retain the automatically assigned public IP through a stop / start cycle.

|improve this answer|||||
  • 1
    Here's the Elastic IP pricing. If you're trying to save up on hourly usage by shutting down the instance once in a while, but use the Elastic IP, it may not get much cheaper after all – aexl Sep 21 '18 at 19:16

You seem to quote the wrong part of AWS documentation. Take a look here (from your same link):

  • EC2-Classic: We disassociate any Elastic IP address that's associated with the instance. You're charged for Elastic IP addresses that aren't associated with an instance. When you restart the instance, you must associate the Elastic IP address with the instance; we don't do this automatically.
  • EC2-VPC: The instance retains its associated Elastic IP addresses. You're charged for any Elastic IP addresses associated with a stopped instance.

So, it seems that using an EC2-VPC instance with an Elastic IP address you can stop/reboot the instance and retain the assigned public IP address

|improve this answer|||||
  • My reading of the question suggests Abe wasn't using Elastic IP addresses. They were using the default assigned public IP. – Tim May 10 '17 at 20:03
  • Maybe, but without an Elastic IP it should not be possible to obtain what the OP asked – shodanshok May 10 '17 at 20:10
  • 2
    I know, that's why I suggested that in my answer :) – Tim May 10 '17 at 20:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.