Dynamic DNS with Amazon EC2 Linux and EveryDNS

So I finally sat down and did the math and found out Amazon EC2 was quite a bit cheaper than what I’d been paying for hosting as long as I was willing to prepay for at least a year.  However, with EC2 you are getting a dynamic ip’s so what to do? Well I’ve been using EveryDNS for years for my dns hosting and despite it’s recent acquisition by Dyn, Inc it’s still works the same. The scripts that are described below can be downloaded here, what follows is a brief walkthrough.

  1. Download EveryDns update script from http://www.everydns.com/dynamic.php  and place it in something like /usr/local/bin.
  2. Create a convenience script in /usr/local/bin that will get your external ip and have it contain the following lines and call it external-ip.sh . This is using Amazon’s suggested curl command to find out your EC2 instance Ip address.
    1. external-ip
  3. Then create a script for the actual dynamic DNS update in /usr/local/bin/ and call it updatedns-sh. This is using the set command to grab the output of external ip and storing it in the variable $1, and then passing that value to the update command. NOTE: this will update the dns record of ALL your domains with everydns set to dynamic. If you need to use specific domain names there is a –d flag for the eDNS client.update
  4. create a cron job on your linux distro of choice but the cron job line should look like the following.
    1. cron

For those wishing to comment I’ve cross posted to my blogger account.

http://ryansvihla.blogspot.com/2010/06/dynamic-dns-with-amazon-ec2-linux-and.html

Related Articles:

    Post Footer automatically generated by Add Post Footer Plugin for wordpress.

    About Ryan Svihla

    I consider myself a full stack polyglot, and I have been writing a lot of JS and Ruby as of late. Currently, I'm a solutions architect at DataStax
    This entry was posted in EC2. Bookmark the permalink. Follow any comments here with the RSS feed for this post.