Sunday, June 6, 2010

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  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 . 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


Eric said...

By the looks of it, the "set ``" isn't necessary; -u [u] -p [p] -ip ``

should suffice.

Splitting hairs though, I know.

schorsch said...

You can also get a static ip address with Amazon EC2 at no cost. See these links: