Simple script to update DtDNS

Please post any helpful and useful tips to maximize your fellow ReadyNAS users' experience.

Simple script to update DtDNS

Postby gjh » Mon Apr 30, 2012 3:49 pm

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

Code: Select all
#!/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!).
gjh
ReadyNAS Newbie
 
Posts: 3
Joined: Sat Apr 28, 2012 2:11 pm
ReadyNAS: Duo

Re: Simple script to update DtDNS

Postby gjh » Mon Apr 30, 2012 3:54 pm

Oops, also forgot, need to install traceroute, nslookup and nc first:

Code: Select all
apt-get update
apt-get install traceroute netcat dnsutils
gjh
ReadyNAS Newbie
 
Posts: 3
Joined: Sat Apr 28, 2012 2:11 pm
ReadyNAS: Duo


Return to User Submitted Tips



Who is online

Users browsing this forum: AhrefsBot [Bot] and 2 guests