Tue 12 Apr 2011
Roll your own DynDNS with DreamHost’s APIs
Posted by Brad Lassey under Uncategorized
Comments Off
As I tweeted last week, DynDNS killed my account again but this time I was in California for 2 weeks, leaving me without access to my home network. That was less than convenient. So, on my to-do list for when I got home was trying to figure out a more robust solution. Turns out its pretty simple to do with DreamHost’s APIs and a cron job. Here’s my script:
KEY="YOUR_DREAMHOST_API_KEY"
HOST="your_server.you.com"
current_dns=`curl "https://api.dreamhost.com/?key=$KEY&cmd=dns-list_records" 2>/dev/null | grep "$HOST" | grep -Eo '([0-9]{1,3}\.){3}[0-9]{1,3}'`
current=`curl "http://lassey.us/whatsmyip.php"`
if test $current = $current_dns; then
echo "their equal"
else
echo `curl "https://api.dreamhost.com/?key=$KEY&cmd=dns-remove_record&record=$HOST&type=A&value=$current_dns"`
echo `curl "https://api.dreamhost.com/?key=$KEY&cmd=dns-add_record&record=$HOST&type=A&value=$current"`
fi
And the content of http://lassey.us/whatsmyip.php is:
<!--?php echo getenv("REMOTE_ADDR"); ?-->
Hopefully that helps out anyone else that’s facing the same frustration.
No Responses to “ Roll your own DynDNS with DreamHost’s APIs ”
Sorry, comments for this entry are closed at this time.