I'm running an ubuntu AMI on EC2. Is it possible to assign/request a new public IP address for a running EC2 instance without terminating it and starting it again? Note that I'm not interested in using the Elastic IP feature here, I just want to use the regular random public IP addresses assigned by EC2.
相关问题
- Why doesn't php sleep work in the windows-subs
- JQ: Select when attribute value exists in a bash a
- Installing Pydev for Eclipse throws error
- Error building gcc 4.8.3 from source: libstdc++.so
- what's the role of libopenssl-ruby?
相关文章
- 为什么nfs在不同版本的Linux下安装的文件都不一样
- I cannot locate production log files on Elastic Be
- PostgreSQL field data type for IPv4 addresses
- Incompatible JavaHl library loaded
- Python - Node.js (V8) runtime is not available on
- Ubuntu graphviz 'sfdp' not working
- AWS - Configuring access to EC2 instance from Bean
- Gearman , php extension problem : Class 'Gearm
You cannot have the public IP assigned to an instance once it is created. Doesn't matter whether it is stopped or running.
Your only option is Elastic IP.
And the public IP can only be assigned to an instance at the time of its creation. Once it is created, your are out of luck.
Update
As Alex B points out in the comments, AWS EC2 instance now have per-second billing, with a minimum billing period of 1 minute. That's a huge, and welcome improvement. It means that starting and stopping an instance should refresh the IP without racking up extra costs.
The one important thing to keep in mind is that per-second billing only applies to Amazon Linux and Ubuntu instances. Other OSs are billed hourly as before. In those cases, the original method explained below is likely the best option.
Stopping and starting an instance is one way to change your IP, but it isn't the fastest or even the cheapest, however it does meet your criteria of avoiding Elastic IPs.
Stopping and starting an instance, from a billing perspective is the same as terminating/relaunching an instance.
This means that, if you start an instance, stop it half an hour later, then start it again and run it for half an hour then stop it again, for that one hour, you're actually going to be billed for two hours of usage.
Elastic IPs are very likely a better solution in that scenario, but the added cost of Elastic IPs is something most people want to avoid. We don't actually want a fixed IP. We just want a new one. Paying for unique IPs per instance doesn't make sense for this. The interesting thing is, we don't need an EIP for each instance in order to release/renew the instance's external IP. We just need one for the entire VPC.
When you assign an EIP to an instance, the old IP is completely gone, released into the void. When you remove the EIP from the instance, the instance is then forced to request a new external IP from the pool.
Keeping a single Elastic IP attached to an instance in the Oregon region (us-west-2) is free, as long as it's attached to something. If it's not attached, it costs $0.05/hour to sit there.
The first 100 IP remaps each month are free. To us, that works out to 50 free IP refreshes (1 remap for release, 1 for renew). If you break that 100 remap limit, the price jumps quickly, to $0.10/remap (or $0.20/IP refresh), so try to keep track. http://aws.amazon.com/ec2/pricing/
TL;DR
The free EIP powered solution? A single EIP for your entire VPC, assigned to a single instance. When you want to release/renew, transfer that IP to the instance in need of a new IP, then transfer it back to the original instance. You can now quickly change an instance's IP up to 50 times a month at no extra cost.
The IP shuffle ladies and gentlemen :)
Double Remap
Elastic IP double- remap will change public IP.
Voila public IP changed with only sub-second use of Elastic IP.
Disadvantages
You can do Elastic IP remap only 100 times/month without charge ($0.1/remap afterwards)
Reboot does not change your IP
If you reboot your instance from within the EC2 Ubuntu machine, e.g. typing
then your instance will keep the same internal and public IP.
Stopping the instance does change your IP
If you use your AWS EC2 management console and stop your machine (don't terminate it!), you give up the assigned IP addresses.
You will request a new address if you start the instance again.
How to quickly check your IP
You can check for your public and private IPs using CURL or Perl GET, install
Now type for internal:
Or for public:
Read more.
The only other option that you might have is to stop and start the instance and it is possible that the public IP would be changed. I am not asking you to terminate the instance. Just stop the instance and then re-start it. It will assign (most likely) a new public IP to your instance.
For those who have down voted without knowing things, please find the link below that tells what I have saying. Read This