Skip to content

Instantly share code, notes, and snippets.

@copperwall
Created July 31, 2015 08:40
Show Gist options
  • Save copperwall/4887fc6430cb09f251c5 to your computer and use it in GitHub Desktop.
Save copperwall/4887fc6430cb09f251c5 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
SHA="Enter hash given by freedns.afraid.org"
BASE_URL="http://freedns.afraid.org/api/?action=getdyndns&v=2&sha=$SHA"
MY_DOMAIN="enter the domain this machine should have point to it"
MY_IP=`dig -4 @resolver1.opendns.com -t a myip.opendns.com +short`
RES=`curl -s $BASE_URL`
for LINE in $RES; do
DOMAIN_INFO=(`echo $LINE | tr "|" "\n"`)
DOMAIN=${DOMAIN_INFO[0]}
IP_ADDRESS=${DOMAIN_INFO[1]}
UPDATE_URL=${DOMAIN_INFO[2]}
if [ "$DOMAIN" == "$MY_DOMAIN" ]; then
if [ "$MY_IP" != "$IP_ADDRESS" ]; then
curl -sk $UPDATE_URL
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment