Wednesday, May 26, 2010

ddclient using Dyndns.org -- dynamic IP address

Dyndns.org DDNS offers a completely free service that allows one to update a custom dyndns host name with your home dynamic IP address like what you receive on the comcast or verizon networks. This will allow you to give out a host name like "calomel.gotdns.org" to friends, family or colleagues pointing to your dynamic IP your use for home. Now you won't have to remember the IP of your machine and you do not care if it changes as you always have the dyndns host name to point to.


Getting Started

To get started you must first sign up for the free "Dynamic DNS" host name offered by Dyndns.org. The link on the right "Get started" will lead you to the registration page. it should take you no more than five minutes to register. Remember you do not have to pay anything and no one gets any credit or recognition for your visit. Once registered you need to choose a host name you want to use. They have many base domains to choose from. For our example we will be using "calomel.gotdns.org". Remember to note your username and password you registered with.

Once signed up you need to decide how your ip is going to get updated and pushed to Dyndns.

    Option 1: If you have Linksys or Netgear router then you can check in the documentation included with the device for "Dynamic DNS" update compatibilities. The dyndns server is really easy to setup in one of these devices and should take you less than an hour to read the docs and put in the information like username, password, and host name you registered to Dyndns with.

    Option 2: If you have a Linux or BSD based firewall then you could use a package called "ddclient" and configure one file called ddclient.conf . Once the package is installed you need only fill out the ddclient.conf file and start the service. The ddclient daemon will read the IP of the interface you specified and send it to the dyndns.org servers.



The config file called ddclient.conf

If you have decided to use ddclient then take a look at the following config file.

    daemon=3600 will check to see if your ip has changed once every hour or 3600 seconds.

    syslog=yes logs all messages to syslog

    mail=root and mail-failure=root will mail all changes and errors to root.

    proxy=proxy.server.com:8080 If you use a proxy server like Squid to get out of you network then uncomment the proxy line and set it to the IP and port of the proxy server.

    ssl=yes SSL updates are available to you if you use ddclient version 3.7.0 or above. This means that your username, password and host information will no longer be in clear text when you send updates to the DynDNS server. (Recommended)

    use=if, if=fxp0 Set the "if=" directive to the interface you want ddclient to look at when it pools the IP address. Our IP is on the the "fxp0" interface.

    Enter the USERNAME and PASSWD you registered with DynDns.org.

    wildcard=no The wildcard directive is there if you want to allow all hosts that point to *.calomel.gotdns.org to point to your machine. For example, you might want anyone who types in a random abc123.calomel.gotdns.org to goto your IP. For our example we do not want that type of traffic.

    server=members.dyndns.org and protocol=dyndns2 The server and protocol are static and you do not have to update them. They are the defaults supplied and preferred by the DynDns servers.

    mx=calomel.gotdns.org The "mx" line is there if you want mail that is destined for your new dynamic host name to goto your machine. if you are going to setup a mail server or a spamd daemon on port 25 or the SMTP port then you may want to enable the mx argument. If you leave it in, even if you do not have anything listening on the mail port 25 it will not hurt anything.

    The few last lines are the host name you will be registering as:

        * Option 1 (free): If you want to use the free service and are using a preregistered domain like "gotdns.org" from DynDns then use Option 1. This will allow you to enter in your sub domain you pre-registered.
        * Option 2 (Pay): If you choose to register your own domain name with DynDNS then use Option 2, a custom DNS update. This example will update the domain as well as the mail.* and www.* records.



Below in the scrollable text window is a fully working ddclient.conf file. You are welcome to copy/paste it.


############################################
#### Calomel.org  ddclient.conf   BEGIN
############################################

 daemon=3600                 # check every x seconds
 syslog=yes                  # log update msgs to syslog
 mail=root                   # mail all msgs to root
 mail-failure=root           # mail failed update msgs to root
 pid=/var/run/ddclient.pid   # record PID in file.
#proxy=proxy.server.com:8080 # local proxy server (do not use with ssl)
#ssl=yes                     # ddclient 3.7.0 and above support ssl updates
 use=if, if=fxp0             # via interfaces

 login=USERNAME              # default login
 password=PASSWD             # default password
 wildcard=no                 # add wildcard CNAME? (anything_string_matches.your_host.org)

 ## Option 1: free dyndns.org dynamic addresses
  server=members.dyndns.org, \
  protocol=dyndns2           \
  mx=calomel.gotdns.org      \
  calomel.gotdns.org

 ## Option 2: Pay for CUSTOM dyndns.org dynamic addresses
 # server=members.dyndns.org,     \
 # protocol=dyndns2,              \
 # custom=yes, your_host.org, mail.your_host.org, www.your_host.org

############################################
#### Calomel.org  ddclient.conf   END
############################################



Start the daemon

Once you have the ddclient.conf in place you can start the ddclient daemon. To start the daemon you can simply type "ddclient". You also want to make sure ddclient starts at boot up so you can use the following line and place it in /etc/rc.local .

      # ddclient
      if [ -x /usr/local/sbin/ddclient ]; then
         echo -n ' ddclient'; /usr/local/sbin/ddclient
      fi

1 comment:

Unknown said...

Nice post. I do want to mention that we removed the ability to update your wildcard or MX record through the update client. If you send those commands in the string it won't break anything, those commands will just be ignored.

We did this due to the thousands of people who had their update clients behaving incorrectly and broke their settings. You can still make all of those changes in your account, however.