Skip to content

Instantly share code, notes, and snippets.

@jedmund
Forked from OrcaXS/ddns-start.sh
Last active January 17, 2019 05:58
Show Gist options
  • Save jedmund/e537f1f0388cb19d13e83d6f49eb4804 to your computer and use it in GitHub Desktop.
Save jedmund/e537f1f0388cb19d13e83d6f49eb4804 to your computer and use it in GitHub Desktop.
Google Dynamic DNS update script for Tomato firmware
#!/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