Updating OpenDNS from your Tomato Router

Here is a script that will update OpenDNS to have your Tomato Router (or similars) IP address, so that filtering works.

I have it running as the WAN script, for when the WAN (Fibre connection) comes up.

Before the the script will run, you need to login to http://dnsomatic.com
with your username and password and
goto Account / Your Services / Expand All and click on [update account info]

Administration / Scripts / WAN up


UNAME=OpenDNSuserName        # username
PWORD=OpenDNSpassWord        # password (plaintext, sorry!)
HNAME=all.dnsomatic.com            # you can set this to all.dnsomatic.com or you can specify the LABEL of the network/host to update
ERROR=5                    # times to retry
MYIP=`dig myip.opendns.com +short`
if [ "${HNAME}" = "all.dnsomatic.com" ]; then NETNAME=ALL; else NETNAME=${HNAME}; fi

rm -f $TMPFILE

    echo Updating HOST [${NETNAME}] with IP ${MYIP}
    wget --quiet --output-document $TMPFILE --user-agent="tomatoUSB - WAN Script - 0.1" http://${UNAME}:${PWORD}@updates.dnsomatic.com/nic/update?hostname=${HNAME}&myip=${MYIP}&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG
    WGETRES=$?; echo "WGET=${WGETRES}"
    cat $TMPFILE | grep -c "good $MYIP"
    echo RES2 $RES2
    if [ "$RES2"  = "1" ]
        echo update successful ${MYIP}
    logger OpenDNS updated successfully ${MYIP}
    while [ $ERROR -gt 0 ]; do
        echo waiting 10 seconds
        sleep 10s
    echo Failed trying to update
    logger OpenDNS update failed


exit 0

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.