Over the years I’ve been pretty lucky with our ISPs - I’ve usually been able to get a fixed IP address so setting up a DNS entry for a subdomain to point back to ‘home’ has been fairly simple. I’ve been able to use that to VPN/tunnel back to the home network to access resources and fix the families machines from anywhere in the world. It also made using the SmartDNSProxy service really simple as it was a set and forget exercise.

Sadly with our new ISP (and long awaited move to NBN) fixed IP addresses are not offered for residential packages (and the cost of upgrading from residential to ‘business’ offered very little value) so I had to come up with a solution.

I could have gone with a service like NoIp.com or DynDns, both of which are supported by our router, but it added additional cost and either required me to move DNS hosting or use (and pay for) a DNS name that I didn’t control and while that supported my “phone home” scenarios, it didn’t help with the Smart DNS Proxy configuration every time the IP address changed. None of the existing IP updater utilities that I could find addressed the problem either.

Luckily, Cloudflare (my DNS provider) has an API that let’s me quickly update the IP address for a specific subdomain, so the DNS entry I use for ‘home’ could be updated, and SmartDNSProxy also have an API to programatically update the relevant details for their service.

As I have a Windows PC that’s always on (it’s the hub for our Media Center, and some of the home automation scripts) I decided to put together a quick PowerShell script that I could set TaskManager to run every five minutes and following a reboot (power outages being the most common cause of an IP address change) and would:

  • Obtain our current public IP address
  • Check the entry for my 'home' DNS entry at Cloudflare
  • If they differed, update CloudFlare, SmartDNSProxy (and any other services) and log the change (just for my curiosity)

So far it’s worked flawlessly (the CloudFlare API took a bit of figuring out, it’s very flexible but luckily well documented and has meaningful error messages!) so I’ve tidied it up a bit, removed my API keys and other identifying ‘stuff’ and shared it as a GitHub project for anyone who needs to do something similar.

Over time I may re-write the script for bash so I can run it on the Raspberry Pi that I have around for some other little projects but at the moment it’s not an always-on machine so no urgency … though if anyone needs it, let me know.

Links: