OpenDNS updater for linux/ubuntu

The OpenDNS service is great — it provides anti-phishing and the ability to filter out some of the less desirable detritus from the internets.

OpenDNS needs to be periodically notified about what your IP address is, and I don’t have a windows or macintosh box that’s always on. I do have an ubuntu box, though, but there weren’t any instructions on OpenDNS’ site to do this properly.

Cron does periodic jobs very well — but rather than using “crontab -e”, it’s much better to install a system-level cron job by adding a file to the /etc/cron.d directory. The file only needs to be readable — there’s no need to set the execute bit. You can choose the effective user that will run the command (in this case I ran as “nobody”), and a backup of your system that includes /etc will pick up your crontab entry.

Here’s the contents of /etc/cron.d/opendns:

47 * * * * nobody curl -u USERNAME:PASSWORD -s https://updates.opendns.com/nic/update | grep -vE "^good"

Replace USERNAME and PASSWORD with your opendns username and password.

The grep squelches success messages. No news is good news.

Related posts:

  1. Simple MySQL backup to gmail on Ubuntu/Debian
    Backing up your MySQL database (if it’s a reasonable size, like < 100s of MB) can be done with a cronjob that runs mysqldump, gzip, and mpack. First set up......
  2. HOWTO: Mount your USB hard drives at boot time on Ubuntu
    I’ve got a number of external USB hard drives connected to my ubuntu server that need to mount to a predictable directory. When you log into Gnome, the desktop environment......
  3. Verifying file integrity with debsums
    After upgrading my Ubuntu server, some security applications grumped about changed contents of some common binaries. Just to be safe, I wanted to verify them explicitly with debsums, but debsums......
  4. Installing Trac on Ubuntu
    Here’s the condensed version, using the installation guide for help: Install the software sudo apt-get install python-setuptools python-subversion sudo easy_install Trac Initialize the Trac project We’re going to run the......

  • Darrell Denlinger

    Could you add a few sentences about why you prefer cron.d to crontab -e?

  • http://matthew.mceachen.us matthew

    @Darrell: Sure. When I backup a unix box, I normally only worry about rsync’ing /etc, /home, and then doing a mysqldump. Because crontabs are stored in /var/spool/cron, it’s just one more thing to worry about backing up and restoring later.

    Automated installation scripts are also possible with cron.d, because the script knows it owns a whole file, rather than trying to do surgery on a file it has to share with other applications.

  • Toño

    Thank you very much for the script, matthew!