Dynamic DNS on the Cheap
Setting yourself up so that you can access your home network using a domain name rather than an IP address is one of those little luxuries you’ll come to wonder how you ever managed without, once you have it.
I’ve been doing this for a while now in various different forms, but I like my current setup the best. You may not. I report, you decide.
Firstly note that I said “cheap”, not “free”. But RegisterFly currently sells .info domains for US$2.99, which is hard to beat. If you find one cheaper elsewhere, good luck to you.
Once the domain is set up with RegisterFly, you need to get them to turn on dynamic updates. This is done from the “manage domains” page. Once you do this you will be given a password, in the form of a sequence of hex digits.
One of the nice things about RegisterFly’s service is that updates are done by HTTP. You get to update your IP address by an HTTP GET request to dynamic.registerfly.com. All you have to do is arrange for this request at the appropriate times. For some people this will be whenever you renew the DHCP lease with your ISP. My ISP gives me a (reasonably) constant IP address, so daily updates are fine.
So I have a FreeBSD box which is running most of the time, which is set up to make this HTTP request using the curl tool. On other unix-alikes this could be done using a cron entry, but I chose to incorporate it into the daily maintenance script that FreeBSD uses. Here is my (edited) /etc/daily.local
file:
#!/bin/sh # # My stuff to do daily # # Update our Dynamic DNS entry. This reflects the external address, which could change # any time as far as we know/care. So update it daily just to be sure. /usr/local/bin/curl -s 'http://dynamic.registerfly.com/?domain=<mydomain>&password=<mypassword>&host=@' \ | grep -o '<strong>.*</strong>'
A few things to note:
- You don’t need to specify the external IP address to use, RegisterFly will work it out based on the source of the HTTP connection. This is really nice, because it means I can run this script anywhere behind my router without extra what-is-my-external-IP magic.
- The
@
in the host parameter means “this domain”, in kinda the same way that.
means “this directory in the filesystem. - curl’s output is piped into grep so that I can extract the success/failure text without all the HTML guff. The output of this command is appended to the daily email that FreeBSD sends me.
So there you have it. I guess I’ll migrate it to my new router at some point, but for now I’m happy.
Update: registerfly changed their server, they now use <strong>
tags instead of <b>
tags. Script above updated to reflect this.
9 Comments