Created
January 7, 2015 06:40
-
-
Save thefinn93/821c7b56db001c6faa6c to your computer and use it in GitHub Desktop.
Dynamic DNS Updater for Hurricane Electric with full v6 support and shit
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/bash | |
HOSTNAME=... | |
USERNAME=$HOSTNAME # Hurricane Electric expects the username to be the hostname | |
PASSWORD=... | |
DEVICE=eth0 | |
SAVEFILE=/var/run/ddns-lastip | |
function update { | |
status=$(curl -u $USERNAME:$PASSWORD "http://dyn.dns.he.net/nic/update?hostname=$HOSTNAME&myip=$1&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG") | |
result=$(echo $status | awk '{print $1}') | |
if [ $result == "good" ]; then | |
echo "Successfully updated IP to $1" | |
echo $1 > $SAVEFILE | |
else | |
echo "Updating IP to $1 gave us: $status" | |
fi | |
} | |
myip=$(ip addr show eth0 | grep inet6 | awk '{print $2}' | cut -d'/' -f1 | head -n 1) | |
if [ "$(cat $SAVEFILE)" != "$myip" ]; then | |
update $myip | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment