Bill Lovett

A Simple Way of Monitoring a Dynamic IP Address

Posted on November 13th, 2006

For the longest time, I've had a cron job running on my server at home that used ipcheck (apt-cache show ipcheck) to update DynDNS with the current IP address of my cable modem. Just in the off chance that said address would change at an inconvenient time, leaving me without a path back to home base.

That script and service did a fine job. Unfortunately, my cable modem's IP address rarely changes. And even if it did, I probably wouldn't be all that inconvenienced. Maybe a little. If the address did change, I'd really only need to know the new one. I'm definitely not in need of any fancy service monitoring. What's the simplest solution then?

If you have a website and access to its access logs, the answer might just be curl. By switching my cron job to something like this:

curl -I -A "hostname of my server" http://example.com < /dev/null
I'll end up with easily identifiable entries in my webserver logs. Using HEAD requests (-I) keeps the request and response lean, and I can grep based on that and/or the hostname of my server. As an added bonus, I also end up with a basic availability heartbeat. If there's nothing in the log files after a certain point in time, something has more than likely gone wrong.

I should have gone this route all along. DynDNS is a better choice when dealing with IP addresses directly would be otherwise inconvenient. But I'm not exactly in that boat.

Back to the index of all blog entries