3

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
9

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.

  • 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
1

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

  • 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
  • 1
    I know, that's why I suggested that in my answer :) – Tim May 10 '17 at 20:12
  • 1
    And I upvoted your answer :) – shodanshok May 10 '17 at 20:40

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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