NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.

Forum Discussion

gjh's avatar
gjh
Aspirant
Apr 30, 2012

Simple script to update DtDNS

Works for me on my ReadyNAS Duo...add the following to your crontab, run every 5-10 minutes is fine:

#!/bin/bash

export PATH=/opt/rfw/bin:/opt/rfw/sbin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11

DtDNSHost="example.dtdns.net"
DtDNSPassword="example"

firsthopIP="$(traceroute -m 2 1.1.1.1 | grep "^ 2" | awk '{print $3}' | sed 's/[()]//g')"
currentPrivateIP="$(ifconfig | grep -A1 eth0 | grep inet | awk '{print $2}' | cut -d':' -f2)"
currentIP="$(/bin/ping -R -c 1 $firsthopIP | egrep -v "($firsthopIP|$currentPrivateIP)" | awk '/\t[0-9]/ {print $1}')"
oldIP="$(nslookup $DtDNSHost | grep -A1 $DtDNSHost | grep ^A | cut -d' ' -f2)"

if [ "$currentIP" != "$oldIP" ]
then
if [ -n "$(echo $currentIP | awk '/[1-9]+\.[0-9]+\.[0-9]+\.[0-9]+/ { print $1 }')" ]
then
echo -e "GET /api/autodns.cfm?id=$DtDNSHost&pw=%DtDNSPassword&ip=$currentIP
HTTP/1.1\nHost: www.dtdns.com\nUser-Agent: bash\n\n" | nc www.dtdns.com 80
fi
fi


Obviously, you also need to sign up here https://www.dtdns.com/ (its free!).

1 Reply

Replies have been turned off for this discussion
  • Oops, also forgot, need to install traceroute, nslookup and nc first:


    apt-get update
    apt-get install traceroute netcat dnsutils

NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology! 

Join Us!

ProSupport for Business

Comprehensive support plans for maximum network uptime and business peace of mind.

 

Learn More