Created
July 27, 2016 09:11
-
-
Save OrcaXS/27d00c5a6f7e4a9e34fa0e49e6a1e27e to your computer and use it in GitHub Desktop.
Google Dynamic DNS update script for Tomato firmware
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -u | |
#set -x | |
U=username | |
P=password | |
H=hostname | |
IP="$(ip -o addr show ppp0 | awk '/inet / {print $4}')" | |
DIGIP="$(dig +short $H)" | |
PROXY=http://127.0.0.1:8118 | |
# args: username password hostname | |
# Note: you might need to install curl from entware, since curl/libcurl from Tomato firmware might not support https. | |
google_dns_update() { | |
CMD=$(/opt/bin/curl -x $PROXY -s "https://$1:$2@domains.google.com/nic/update?hostname=$3&myip=$4") | |
logger "google-ddns-updated: $CMD" | |
echo "$CMD" | |
} | |
#sleep 30 | |
echo "Interface IP is ${IP}, Query from DNS is ${DIGIP}" | |
if [ "$DIGIP" != "$IP" ]; then | |
google_dns_update $U $P $H $IP | |
else | |
echo "IPs are same, ddns update is not necessary" | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment