everydns dynamic ip updater
I setup a free EveryDNS account today. I wanted to do a dynamic ip address, for a subdomain off my main domain.
I setup an ns record in my main domain, to give authority over the subdomain to the everydns nameservers.
I didn't like the perl script that everydns provides to update the mapping. I wanted a simple shell script that I could cron.
So, I wrote this.
#!/bin/bash
DOMAIN="your.domain.net"
USER="username"
PASS="password"
VER="0.1"
IP=$(wget -q http://whatismyip.com -O - | grep -m1 -oE "([0-9]{1,3}\.?){4}")
if [ -r "/tmp/oldip.txt" ]; then
OLDIP=`cat /tmp/oldip.txt`
if [ "$OLDIP" = "$IP" ]; then exit 0; fi
fi
echo $IP > /tmp/oldip.txt
wget -q --http-user="${USER}" --http-password="${PASS}" "http://dyn.everydns.net/index.php?ver=${VER}&ip=${IP}&domain=${DOMAIN}" -O -
I set that cron to run once an hour.
0 * * * * /path/to/dydns.sh >>/dev/null 2>&1
Works great!