Last active
May 1, 2019 01:32
-
-
Save dennybaa/a1b36d6e1da00f97597d to your computer and use it in GitHub Desktop.
Update dyndns freedns http://freedns.afraid.org/ #dyndns #script
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 | |
(which wget > /dev/null) || { echo "wget not found"; exit 1; } | |
(which nslookup > /dev/null) || { echo "nslookup not found"; exit 1; } | |
# FREEDNS_APIKEY (loginid|password -> SHA1) | |
DYNLIST=$(wget -qO- http://freedns.afraid.org/api/?action=getdyndns&sha=${FREEDNS_APIKEY}) | |
NAME="$1" | |
DYNLIST=$(wget -qO- "http://freedns.afraid.org/api/?action=getdyndns&sha=${FREEDNS_APIKEY}") | |
for record in $DYNLIST; do | |
dns_name=$(echo $record | cut -f1 -d\|) | |
if [ "$NAME" = "$dns_name" ]; then | |
record_addr=$(echo $record | cut -f2 -d\|) | |
# take extarnal ip, kinda ifconfig.me but faster | |
host_addr=$(wget -q -O - http://checkip.dyndns.org | sed 's/[^0-9.]//g') | |
if [ "$host_addr" != "$record_addr" ]; then | |
update_link=$(echo $record | cut -f3 -d\|) | |
wget -qO- "$update_link" | |
fi | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment