Thursday, March 06, 2008

How To Set Up Dynamic DNS for your Amazon EC2 Instance

Here's a step by step to setting up dynamic dns for you EC2 instance. This is required because EC2 does not have static IPs (yet).

  1. First of all, you need a dynamic dns account. You can get one at www.dyndns.com or my personal favorite, www.zoneedit.com.
  2. After you sign up, be sure to add your domains to their system.
  3. Download dyndns client 
    1. run: wget http://cdn.dyndns.com/ddclient.tar.gz
    2. The download includes Installation Instructions in the README, but the step by step is below
  4. tar -zxvf ddclient.tar.gz
  5. cd ddclient-X.Y
  6. cp ddclient /usr/sbin/
  7. mkdir /etc/ddclient
  8. nano -w /etc/ddclient/ddclient.conf
    1. Then fill in config file:

FOR ZONEEDIT

# Basic configuration file for ddclient
#
# /etc/ddclient.conf
daemon=600
pid=/var/run/ddclient.pid
use=web, web=checkip.dyndns.org/, web-skip='IP Address'
login=[USERNAME
password=[PASSWORD]
protocol=zoneedit1
server=www.zoneedit.com
wildcard=YES
[YOUR DOMAIN(S), COMMA DELIMITED LIST]

FOR DYNDNS

# Basic configuration file for ddclient
#
# /etc/ddclient.conf
daemon=600
pid=/var/run/ddclient.pid
use=web, web=checkip.dyndns.com/, web-skip='IP Address'
login=[USERNAME
password=[PASSWORD]protocol=dyndns2
server=members.dyndns.org
wildcard=YES
[YOUR DOMAIN(S), COMMA DELIMITED LIST]
custom=yes, example.com

More info on configuration

Continuing on:

  1. cp sample-etc_rc.d_init.d_ddclient /etc/rc.d/init.d/ddclient
  2. /sbin/chkconfig --add ddclient
    1. This makes it startup automatically next time you reboot
  3. /etc/rc.d/init.d/ddclient start
    1. This is to start it the first time by hand
    2. DON'T RUN THIS until your server is fully setup if you are moving servers because people will start hitting this server after you run this

That's it, not too difficult and gives you a real domain name to point at your EC2 instance.