Skip to content

Instantly share code, notes, and snippets.

@thefinn93
Created January 7, 2015 06:40
Show Gist options
  • Save thefinn93/821c7b56db001c6faa6c to your computer and use it in GitHub Desktop.
Save thefinn93/821c7b56db001c6faa6c to your computer and use it in GitHub Desktop.
Dynamic DNS Updater for Hurricane Electric with full v6 support and shit
#!/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