Skip to content

Instantly share code, notes, and snippets.

@sterling
Last active May 1, 2019 00:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sterling/08132bb4c80480c42e6f5a00256844ea to your computer and use it in GitHub Desktop.
Save sterling/08132bb4c80480c42e6f5a00256844ea to your computer and use it in GitHub Desktop.
ASUS Merlin Google DDNS script (/jffs/scripts/ddns-start)
#!/bin/sh
host=
user=
pass=
wanip=$1
resolvedip=$(nslookup $host | grep $host -A1 | awk '/^Address / {print $3}')
if [ "$wanip" == "$resolvedip" ]; then
logger "Google Domains DDNS: WAN IP ($wanip) unchanged, no update necessary"
/sbin/ddns_custom_updated 1
else
response=$(curl -s https://$user:$pass@domains.google.com/nic/update?hostname=$host&myip=$wanip)
if [ "$response" == "good $wanip" ]; then
logger "Google Domains DDNS: DNS updated to $wanip from $resolvedip"
/sbin/ddns_custom_updated 1
else
logger "Google Domains DDNS: Update error. $response"
/sbin/ddns_custom_updated 0
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment