OpenWRT meets OpenDNS

To make whole home network use OpenDNS I need to change only 3 files on my OpenWRT router.

First step – resolv.conf

Create /etc/resolv.conf.opendns with OpenDNS servers addresses, eg:

nameserver 208.67.222.222
nameserver 208.67.220.220

Make sure /etc/resolv.conf defines 127.0.0.1 as a name server.

Second step – dnsmasq

In /etc/config/dhcp set resolvfile variable:

option resolvfile '/etc/resolv.conf.opendns'

Restart dnsmasq with:

# /etc/init.d/dnsmasq restart

Third step – /etc/hotplug.d/iface

This step is only needed if you have a dynamic IP address and you want to use advanced OpenDNS features (like content filters or statistics).

Create file /etc/hotplug.d/iface/40-opendns with command similar to this:

#!/bin/sh

case "${ACTION:-ifup}" in
        ifup)
                logger -t opendns `curl -k -u username:password https://updates.opendns.com/nic/update?hotsname=NetworkName`
        ;;
esac

Note that you need curl built with (libopen)ssl.

Test hotplug script with:

# ifdown wan
# ifup wan

Then check log with:

# logread | tail

If script work you will see a message like:

Jan  4 01:13:27 hurricane user.notice opendns: good 83.10.94.104

Finally go to OpenDNS. If everything is fine you should find green “You’re using OpenDNS!” in the right corner. In “Dashboard > Networks” you should find entry for NetworkName with your current IP and message “(your current IP)”.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.