A PowerShell script to update various services when my home IP address changes
Why does this exist?
As with many residential ISPs I am unable to get a fixed IP address for my service, which can be frustrating if the IP address changes (eg as a result of a power outage).
In my particular scenario I needed to update a CloudFlare hosted DNS for the endpoint I use for my VPN, and also update the entry for my SmartDNSProxy service so the machines using that only had minimal interruption.
As I have a Windows machine that's always-on, it seemed like a good exercise to do with PowerShell, though easy enough to switch to bash if I want to move it to the Raspberry-PI that's used for some other things at home.
I know there are existing services like NoIp.com or other dynamic DNS services (as well as updater apps) but none of them delivered all the features I needed with the flexibility - hence rolling my own.
How to use
The script queries myexternalip.com to get your public IP address (I've found this to be a very reliable, consistant source), and if the IP address differs from the one that CloudFlare thinks your entry is referencing it updates both CloudFlare and SmartDNSProxy with the new one (and updates the log file).
I have a Windows Task Scheduler event set to run the script every 5 minutes which, for my purposes, is adequate.
- Improve error trapping
- Optimize code
- Add additional services as required
If you make use of this and like it and want to give something back... I wrote a book! :)
This project can be forked from Github. Please issue pull requests from feature branches.
See Licence file in repo, or refer to http://unlicense.org