OpenDNS with ddclient to maintain Dynamic DNS



OpenDNS markets itself as the fastest growing internet security and DNS service. OpenDNS is the leading provider of security and infrastructure services that make the Internet safer through integrated Web content filtering, anti-phishing and DNS. OpenDNS services enable consumers and network administrators to secure their networks from online threats, reduce costs and enforce Internet-use policies. 


For OpenDNS to work the service needs to know which IP address your network resides on. If like me your internet service provider assigns you a dynamic IP address then you have to setup a dynamic updating service that keeps OpenDNS updated with your current IP address. This posts walks through the steps I used to set up ddclient (a linux dynamic dns updating tool) with OpenDNS. Read on...

Ideally ddclient needs to be running on a machine which is run 24/7 so that OpenDNS is always aware of your networks current IP.


Install ddclient
Under Ubuntu 10.04 I used the following command to install ddclient and its dependencies:
sudo apt-get install ddclient


Configure ddclient
Edit the configuration file for ddclient using the command below:
sudo gedit /etc/ddclient.conf


Add the lines:
# Configuration file for ddclient generated by debconf
#
# /etc/ddclient.conf
ssl=yes # use ssl-support
pid=/var/run/ddclient.pid
use=web, web=myip.dnsomatic.com
server=updates.opendns.com
protocol=dyndns2
login=yourOpenDNSusername
password='yourOpenDNSpassword'
yourOpenDNSnetworkname #this is as per the OpenDNS account setting on the web interface
Set the config file permissions
ddclient requires the config file to be readable only by the file owner (root by default):
sudo chmod 600 /etc/ddclient.conf 


Set up the ddclient daemon
To get ddclient to run as a service, you need to make some additional changes to get the service daemon up and running:
sudo gedit /etc/default/ddclient 


Add the lines:
# Configuration for ddclient scripts
# generated from debconf on Sat Jul 16 14:16:54 BST 2011
#
# /etc/default/ddclient
# Set to "true" if ddclient should be run every time a new ppp connection is
# established. This might be useful, if you are using dial-on-demand.
run_ipup="false"
# Set to "true" if ddclient should run in daemon mode
# If tis is changed to true, run_ipup must be set to false.
run_daemon="true"
# Set the time interval between the updates of the dynamic DNS name in seconds.
# This option only takes effect if the ddclient runs in daemon mode.
daemon_interval="300"
Set the ddclient daemon to run at boot
To run the daemon at boot time I edited the rc.local file, you should probably use System V init scripts instead but I was being lazy:
sudo gedit /etc/rc.local


Add the line:
sudo /etc/init.d/ddclient start
Run the ddclient to test it works
From a terminal run:
sudo /etc/init.d/ddclient start


Enable Dynamic IP Update on your OpenDNS account
1. Log in to OpenDNS
2. Select your network and click "Advanced Settings"
3. Check "Dynamic IP Update"
4. Click "Apply"


You're done! OpenDNS should now update whilst the ddclient daemon is working and your DNS services from OpenDNS should now follow your IP address.

2 comments:

  1. Hi, there! Nice post, the best one I could find.... thanks!

    ReplyDelete
  2. Great just what I needed for my pi - good job!

    ReplyDelete

Note: only a member of this blog may post a comment.