As I'm about to lose my free DynDNS account, along with everyone else, it was time to find an alternative. DynDNS has served me well for a great many years in solving the problem of remotely connecting back to my house. Now they plan to revoke all free accounts, I needed to find a suitable replacement.
What is Dynamic DNS?
Dynamic DNS, or DDNS, is a way of updating a name server to change the records stored there. In this particular example, I want to update the IP address of a hostname. With most residential Internet packages you get a dynamic IP. This poses a problem when you regularly need to connect to services back home because when your IP changes, you don't know what the new one is! By having a DDNS service running on a machine behind your router, you can update a DNS record on regular intervals with your current IP. That way, when you're away from home and your IP address changes, your hostname is updated and you can still connect back home.
What happened to DynDNS?
DynDNS used to offer a free service where you could get your own hostname. You would run the updater service on a machine on your home network, or a router loaded with DD-WRT, and it would update your hostname at regular intervals meaning you could always connect home. DynDNS decided to stop offering free accounts, explaining why on their blog, and this has left many customers needing to find an alternative. Convinced that I could find a free alternative, or maybe even build my own, I set out to do just that.
After seeing a tweet from Matthew Prince, CEO of CloudFlare, inviting users leaving DynDNS to try out CloudFlare DDNS, I was intrigued. I've used CloudFlare's services before and they handle the DNS resolution for every domain name that I own.
CloudFlare DDNS is free. Discarded Dyn users welcome! RT @arstechnica: Dyn discontinues free DynDNS service http://t.co/zwIYZkuyRq — Matthew Prince (@eastdakota) April 8, 2014
As CloudFlare are consistently amongst the fastest DNS providers, they seemed like a good bet for a replacement to DynDNS. Whilst CloudFlare don't have an actual DDNS product, you can update your DNS records using their API, and with this, you can build your own.
Rolling my own...
Using the CloudFlare API documentation, I was able to write a small PHP script that I can call to update my chosen DNS record. Called on a regular basis using cron, this gives me a lightweight solution to my DDNS problem. I'm calling a PHP file that I'm hosting myself so that I can get the IP address of my home router. There are alternative ways to tackle this, but the biggest hurdle is probably obtaining your own IP address. You could achieve the same task by calling the CloudFlare API directly from a machine within your network, but you'd still have to depend on an external service to provide your IP address to you.
You can find my solution here on GitHub and I'm open to feedback and suggestions for improvements! It's not designed to be mega fancy, it's just functional enough to get the job done.
Short URL: https://scotthel.me/cfddns