Skip to content

Instantly share code, notes, and snippets.

@0x3333
Created September 19, 2019 16:31
Show Gist options
  • Save 0x3333/129bbfa2958bfac165061abe170021e5 to your computer and use it in GitHub Desktop.
Save 0x3333/129bbfa2958bfac165061abe170021e5 to your computer and use it in GitHub Desktop.
Updated FreeDNS script to use dig to check the IP in the Master name server instead of local name server.
#!/bin/sh
#FreeDNS updater script
UPDATEURL="https://freedns.afraid.org/dynamic/update.php?_YOUR_KEY_HERE_"
DOMAIN="_YOUR_DOMAIN_HERE_"
registered=$(nslookup $DOMAIN|tail -n2|grep A|sed s/[^0-9.]//g)
current=$(dig +noall +answer @ns1.afraid.org $DOMAIN|sed 's/.*\t\([0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\).*$/\1/g')
[ "$current" != "$registered" ] && {
wget -q -O /dev/null $UPDATEURL
echo "DNS updated to $current on $(date).";
}
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment