Dynamic DNS services are great. They allow you to keep track of your dynamic IP on your home broadband connection without the need to constantly check it at whatismyip.com or similar websites, and the erradicate the risk of you not knowing the IP address when its changed after you’ve left the house.
That said, some, well… lots of home broadband providers give you crummy routers that do not have the ability to notify Dynamic DNS services of IP changes. The cheapest router that’s optimised for your ISP’s network is usually what you end up with and that usually means less features.My home router actually does have the Dynamic DNS feature, but I’ve found a number of the providers of Dynamic DNS accounts let your accounts expire if you don’t log into them for a period – this is irritating because you tend not to need to log into them, it’s just that they’re never going to be able to upsell more products to you if you don’t. For that reason I sought an alternative.
If you’ve not got a static IP, and you either don’t have the Dynamic DNS feature on your router or you don’t want to have to maintain an account with DynDNS or another Dynamic DNS service provider, what’s a chap to do to keep track of his IP if he runs a VPN or a web server from home? Well, that’s what I’ve set out to solve with PHP IP Notifier.
The above script is a simple standalone PHP script that can run off any computer with PHP available via the CLI on your network which connects to the internet. It simply grabs the output of ip6.me and checks the value against a file containing what it found your IP address to be last time it checked. If there’s been a change it writes the new IP address to the file and pops you an email for good measure to notify you of the change.
No more leaving the house to find your IP address has changed and you can’t log onto your VPN, and you can set the period at which it checks to your taste (I’ve got it set to run every 15 minutes).
To give you an idea – I’m running a simple Apache2/MySQL/PHP web server on my home network for internal development, and it runs on a Raspberry Pi that’s always connected. This script sits on the Raspberry Pi and runs as a Cron job every 15 minutes, so I can always connect to my home network when I’m out and about without needing to maintain a DynDNS account.
To get my script going on your home network, just choose the machine you want to run it off, run
$ git clone http://github.com/CharlieHawker/php-ip-notifier.git
and configure as per the contents of the README.md file and you should be all set.