-
-
Save jedmund/e537f1f0388cb19d13e83d6f49eb4804 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)" | |
# args: username password hostname | |
# Note: you might need to install curl from entware, since curl/libcurl from Tomato firmware might not support https. | |
iwantmyname_dns_update() { | |
CMD=$(/opt/bin/curl -s "https://$1:[email protected]/basicauth/ddns?hostname=$3&myip=$4") | |
logger "iwantmyname-ddns-updated: $CMD" | |
echo "$CMD" | |
} | |
#sleep 30 | |
echo "Interface IP is ${IP}, Query from DNS is ${DIGIP}" | |
if [ "$DIGIP" != "$IP" ]; then | |
iwantmyname_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