- 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!).
