Get a fixed dns for an ec2 instance

4

I want to use an ec2 instance just to do work on some personal programming and text processing projects in the cloud (from an ssh terminal) rather than on a desktop. I don't always need access to the instance, so I want to stop the instance whenever I don't need to work. However, when I restart the instance, the public dns has changed and I have to recopy the dns to my ssh command to gain access to the instance.

Is there a free way to make the public dns for such an ec2 instance fixed?

jonderry

Posted 2011-07-19T04:46:51.013

Reputation: 837

Answers

1

I doubt you can change the way Amazon works, but you could have more than one DNS name. Sign up for a free dynamic DNS account and create a DNS A record (host record). Then download, and install the stub app that updates your new hostname's IP address.

http://www.dyndns.com/services/dns/dyndns/ (sign-up for account)

http://www.dyndns.com/support/clients/ (client to load to update your DDNS)

KCotreau

Posted 2011-07-19T04:46:51.013

Reputation: 24 985

P.S. I have used their DDNS for my personal mail server for about 5 years, and it has never failed me. As soon as my IP changes, it is updated immediately, although I use my firewall to do the updating, not the stub app. – KCotreau – 2011-07-19T05:09:10.120

Are you suggesting running dyndns from the instance? Is it possible to update the dns record from the instance automatically when it's started (sorry if this is a dumb question. I'm an ec2 n00b.) – jonderry – 2011-07-19T05:18:17.877

That is exactly what I am saying. You do plan on saving the instance, right? With certain things installed on it all the time (including the DDNS app)? It seems to me like this would work. – KCotreau – 2011-07-19T05:19:38.793

For the record, I am also not very versed in ec2, but I do know DNS, and networking, so if you can save the instance (and I know you can somehow, whether you have to buy storage or whatever), it will work. – KCotreau – 2011-07-19T05:21:32.427

OK, I'll see if I can get this to work tomorrow, and yes, I save the instance. Everything is stored in EBS when the instance is stopped. The only question is whether I can run dyndns or something similar automatically I guess. – jonderry – 2011-07-19T06:12:43.673

That was what I thought regarding EBS (although I did not remember the name of the service). There is no doubt you will be able to do it. If you have problems, post back and I will try to help you further. – KCotreau – 2011-07-19T06:24:22.733

It seems that DynDNS is not free anymore, any other suggestions ? – Stef Heyenrath – 2012-01-21T16:21:02.340

1

I've been looking into a similar setup, using a dynamic DNS service to save myself from having to copy out the IP address of the instance every time I start it. I've come across a script for afraid.org (a free [as in beer] dynamic DNS service), which can be run on startup to have the DNS updated with the instances new IP address:

http://helmingstay.blogspot.com/p/afraidorg-script-for-amazon-ec2.html

To be honest, I haven't tried this script yet because it's a tiny bit intimidating considering I haven't even launched an instance yet, but if anyone successfully implements this method I'd love to hear about it. I'd also love to hear about how difficult it is to save the instance in between starting up and shutting down! (I know there's plenty of reading on this matter, but the SE community just explains things so much better!) Thanks in advance and hope this helps.

Cory W.

Posted 2011-07-19T04:46:51.013

Reputation: 83

could you share some details? do you run it from cron, how often? Or from /etc/rc.local at startup? What is the behavior when the instance is stopped and started later, with a new IP, how much time the DNS update takes? Thanks! – eudoxos – 2014-07-29T09:04:46.413

Just a quick update: I've now set up an instance for development (running ubuntu), and have successfully implemented/tested this script. Works like a charm so far; just need to see how it handles over time, but I don't foresee any issues. – Cory W. – 2013-02-13T17:33:15.007