Created
September 19, 2019 16:31
-
-
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.
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 | |
#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