Open Source

Tech Tip: Keep entries updated offers a free dynamic DNS service, and a number of clients exist for Windows, Linux, and Mac OS X. One of the more stable Linux clients is ez-ipupdate, a great tool that takes the IP address of your system and sends the data to to update the DNS record for your particular host name (as chosen when you sign up).

Unfortunately, ez-ipupdate falls short when you're executing it from a host that doesn't have the IP address you wish to set. For example, let's say you have a LAN behind an external firewall appliance and want to set your host name to the IP address held by the firewall.

Because most firewalls use network address translation (NAT), you can work around this if you have a Web site where you can put a simple PHP script. Place the following PHP script on a remote server, outside of the LAN; we'll call it getaddress.php.

<?php print($_SERVER['REMOTE_ADDR'] . "\n"); ?>

On your internal Linux machine, create a script that you'll run hourly via cron. This script should contain the following:


current_ip=`curl -sf http://externalhost/getaddress.php`
if [ "x$?" != "x0" ]; then
  exit $?

old_ip=`grep address $config|sed s/address\=//g`

if [ "$current_ip" != "$old_ip" ]; then
  perl -pi -e "s/$old_ip/$current_ip/g" $config

This script executes /etc/ez-ipupdate, which is the configuration file and the runtime script for ez-ipupdate if the IP address returned by the PHP script differs from the address currently in the /etc/ez-ipupdate config file. Running this every hour will update your entry if your dynamic IP address changes.

Editor's Picks

Free Newsletters, In your Inbox