The dynamic DNS setup that I wrote about previously didn’t work out very well. After several weeks of running smoothly, the VPS provider I was using had an issue with a DDoS attack on one of its clients which forced them to move datacenters. Obviously this caused some unexpected downtime and my only DNS server for timmontague.com was unavailable. Luckily, I was able to change the name server back to the servers provided by Gandi.net, my registrar, within a few hours so hopefully I didn’t bounce too many emails. In hindsight, it’s probably not the best idea to place your sole name server on a VPS that costs less than $2 a month.
I decided to go with another route, Amazon’s Route 53. They offer servers across the world and their SLA states that they expect 100% availability. More importantly, they have an API that allows adding, deleting and updating records.
It was extremely easy to get set up. I already had an Amazon AWS account, so I simply logged in, created a new hosted zone, and added my existing DNS records using the web interface. I found a utility that makes it incredibly easy to administer the DNS records from the command line called cli53.
One obstacle I encountered was finding my external IP address without relying on a service that may be sporadically unavailable. With a little searching, I was able to find a command that connects to the Airport Extreme that I’m using as a router via SNMP and extracts the external IP address.
I updated my DDNS update script to the following:
#!/bin/bash
DIR="/home/tim/ddns"
TTL="300"
HOSTS="@
www
home
sync"
# use -f to force ip change
if [[ $# -gt 0 && -n "`echo $1 | grep -- -f`" ]]; then
FORCE=true
else
FORCE=false
fi
cd $DIR
LASTIP=`cat lastip.txt`
# get WAN IP address from airport extreme via snmp interface
WAN=`snmpwalk -c public -v 2c 192.168.2.1 ipAdEntIfIndex \
| sed 's/.*ipAdEntIfIndex.\([0-9]*.[0-9]*.[0-9]*.[0-9]*\).*/\1/' \
| grep -v -E "^((127)|(192)|(169)|(10))\."`
if [[ "$LASTIP" != "$WAN" || $FORCE == true ]]; then
echo "IP changed from $LASTIP to $WAN"
echo $WAN > lastip.txt
else
exit
fi
for h in $HOSTS
do
echo $h
cli53 rrcreate --replace --ttl $TTL timmontague.com $h A $WAN
done
With the extremely low traffic of this site, the monthly AWS fees should be about $1. Not too bad at all.