Thursday, May 22, 2008

inadyn, opendns, and Ubuntu

I have been using DNS services from OpenDNS.org for a little while now, and I am very happy with some of the features that they provide such as URL shortcuts and finely grained internet filtering. However, in order to use the features, I have to keep my dynamic IP address up to date with their DNS-O-Matic service. Their list of clients includes inadyn, which is available through Ubuntu but doesn't include DNS-O-Matics ssl extensions and so I compiled my own version and installed it.

Here are the steps I followed:

  1. Download modified inadyn source code from OpenDNS -- wget http://www.opendns.com/support/ddns_files/inadyn.source.v1.99.zip
  2. Unzip the source code -- unzip inadyn.source.v1.99.zip
  3. sudo apt-get build-dep inadyn
  4. sudo apt-get install libcurl4-openssl-dev
  5. cd inadyn.source.v1.99
  6. make
  7. sudo cp -p bin/linux/inadyn /usr/local/sbin/.
  8. Create a script named inadyn in /etc/init.d so that it will launch automatically on startup.
    #! /bin/sh

    ### BEGIN INIT INFO
    # Provides: inadyn
    # Required-Start: $network
    # Required-Stop: $syslog
    # Should-Start: $named $syslog
    # Should-Stop: $syslog $network
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Dynamic IP Adress updater
    # Description: inadyn is a program that updates services such as
    # dyndns.org and dnsomatic.com when the host's external
    # external IP address changes.
    ### END INIT INFO

    set -e

    # /etc/init.d/inadyn: start and stop the inadyn daemon

    DAEMON=/usr/local/sbin/inadyn
    INADYN_ENABLE=true
    INADYN_OPTS=''
    INADYN_CONFIG_FILE=/etc/inadyn.conf

    test -x $DAEMON || exit 0

    . /lib/lsb/init-functions
    . /etc/default/rcS

    export PATH="${PATH:+$PATH:}/usr/sbin:/sbin:/usr/local/sbin"

    case "$1" in
    start)
    if "$INADYN_ENABLE"; then
    log_daemon_msg "Starting inadyn daemon" "inadyn"
    if [ ! -s "$INADYN_CONFIG_FILE" ]; then
    log_failure_msg "missing or empty config file $INADYN_CONFIG_FILE"
    log_end_msg 1
    exit 1
    fi
    if start-stop-daemon --start --quiet \
    --pidfile /var/run/inadyn.pid --make-pidfile\
    --exec $DAEMON
    then
    rc=0
    else
    rc=1
    fi
    if [ $rc -eq 0 ]; then
    log_end_msg 0
    else
    log_end_msg 1
    fi
    else
    if [ -s "$INADYN_CONFIG_FILE" ]; then
    [ "$VERBOSE" != no ] && log_warning_msg "inadyn daemon not enabled in /etc/init.d/inadyn, not starting..."
    fi
    fi
    ;;
    stop)
    log_daemon_msg "Stopping inadyn daemon" "inadyn"
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON
    log_end_msg $?
    ;;
    restart)
    set +e
    if $INADYN_ENABLE; then
    log_daemon_msg "Restarting inadyn daemon" "inadyn"
    start-stop-daemon --stop --quiet --oknodo --exec $DAEMON || true
    sleep 1
    if start-stop-daemon --start --quiet \
    --pidfile /var/run/inadyn.pid --make-pidfile \
    --exec $DAEMON
    then
    rc=0
    else
    rc=1
    fi
    if [ $rc -eq 0 ]; then
    log_end_msg 0
    else
    log_end_msg 1
    fi
    else
    [ "$VERBOSE" != no ] && log_warning_msg "inadyn daemon not enabled in /etc/default/inadyn, not starting..."
    fi
    ;;

    *)
    echo "Usage: /etc/init.d/inadyn {start|stop|restart}"
    exit 1
    esac

    exit 0
  9. sudo update-rc.d -f inadyn defaults
  10. Create an inadyn.conf file in /etc
    background
    syslog

    update_period_sec 600 # Check for a new IP every 600 seconds
    secure

    # Enter your DynDNS username and password here
    username <USERNAME GOES HERE>
    password <PASSWORD GOES HERE>

    # What kind of host is being updated? Choices are dyndns@dyndns.org, statdns@dyndns.org, custom@dyndns.org
    dyndns_server_name updates.dnsomatic.com
    dyndns_server_url /nic/update?
    alias <DNS-O-Matic SERVICE 1 GOES HERE>
    alias <DNS-O-Matic SERVICE 2 GOES HERE>

  11. /etc/init.d/inadyn start

  12. all done inadyn is now installed and will keep DNS-o-Matic apprised of you IP address.

3 comments:

Anonymous said...

Just a note - you say to copy inadyn to /usr/local/bin/ but then the init.d script looks for inadyn in /usr/local/sbin, and so doesn't work unless you change it.

Thanks for the guide though, useful :-)

Anonymous said...

THANKS! This was just what I was looking for. You saved me a bunch of time!

Victor said...

Thank you :)! Greets from poland.

 

Blogger Template by Blogcrowds