Up one level
How to host your own domain from a broadband connection with Dynamic IP (Dynamic DNS)
Spencer Stirling

Please see the following list of dynamic DNS providers. I haven't used ZoneEdit for years, but the following concepts are basically the same for all dynamic DNS providers.

Dynamic IP and ZoneEdit.com
First things first: I am assuming that you have a DSL or Cable Modem connection. If you are like 95% of the broadband world then your home network IP address is assigned dynamically, meaning that it changes periodically. This is not a problem if you just want to "get on" the internet, but this is a huge problem if you actually want to HOST your own domain (like spencerstirling.com) on a server in your house. Many people will probably opt to just pay somebody else to host their site - that's fine, but not nearly as fun.

Here's the problem with a dynamic PUBLIC IP address: when somebody types www.spencerstirling.com, the DNS name resolver doesn't know where to go (because the actual address keeps changing). This is where so-called "dynamic DNS" comes in handy. I use a free service available from www.zoneedit.com. Here's how it works: you can buy a domain name from several "official" domain registries, like "www.000domains.com" or "www.godaddy.com". These companies just provide the NAME, not a place to actually PUT your website. This is the job of your domain "host". If you are reading this document then I assume that you want the host to be - YOU (a server on your home network)!

The domain registry usually only provides the barebones of services. For example, maybe you already have a hosted website, but it has a terrible name like:

www.yahoo.com/users/imanidiot/complicatedurl/nobodywillrememberthis/blahblah.html

then your domain registry will often provide a service called URL forwarding. This just means that somebody can type in your easy new domain name (like www.spencerstirling.com) and they will be automatically forwarded to the terribly-named site above. For this to work you will already have to have your website hosted somewhere, you just don't like the name (so you're going to choose an easier name to point to it).

Another possibility is that your home network might have a static IP, in which case you can just set up your website on your home server and tell your domain registry to point www.spencerstirling.com to the address of your home server. That's REALLY easy. Unfortunately, most people don't want to pay the extra $$$ that it takes for a static IP (usually requires an upgrade of your DSL to a small business account).

In comes Zoneedit! You can configure your official domain registry to use the DNS servers provided by Zoneedit (a third party company). That means that whenever anybody asks where to find www.spencerstirling.com, your official registry will say "I don't know" and ask the servers over at Zoneedit. The beauty is that the servers over at Zoneedit can be updated with the latest information rather often - meaning that you can update your latest IP address whenever it changes. This is called "Dynamic DNS". In fact, *some* official domain registries also provide this service (but mine doesn't), so you may be able to avoid Zoneedit altogether!

The instructions available on www.zoneedit.com for "dynamic DNS" are pretty much self-explanatory. You will need to obtain an account with them. There they will assign you a couple of nameservers to use. In my case they told me to use

ns3.zoneedit.com
ns17.zoneedit.com

Hence I logged on to my domain registry (www.godaddy.com) and told it to use the DNS servers over at ZoneEdit (instead of using Godaddy's nameservers) whenever anybody asks where to find www.spencerstirling.com.

The ONLY issue left is that you need to know how to update the ZoneEdit nameservers with your latest IP address periodically. On their "dynamic DNS" howto they have a method using "lynx" - this is the one that I'm using. So I wrote the following script and put it in "/root/update_zoneedit/update_zoneedit" UPDATE April 2006: modified script slightly for better error checking (still sucks)


#!/bin/sh
# Make sure that you have "lynx" INSTALLED!!!
# This script tries to update your Zoneedit profile whenever
# your IP address changes

GATEWAYIPADDRESS="${HOME}/report_gateway_ip_zoneedit/ipaddress"
GATEWAYIPADDRESSOLD="${HOME}/report_gateway_ip_zoneedit/ipaddress.old"
TEMP="${HOME}/report_gateway_ip_zoneedit/temp"
GATEWAYPAGE="http://www.whatismyip.com"
KEYPHRASE="Your IP"
USERNAME="zoneeditusername"
PASSWORD="password"
MYDOMAIN1="foo.com"
MYDOMAIN2="foo2.com"
MYDOMAIN3="foo3.com"

# get the ip address of the gateway
lynx -dump $GATEWAYPAGE &> $TEMP
if [ $? -ne 0 ]
then
  echo "Cannot browse to $GATEWAYPAGE"
  exit
fi
cat $TEMP | grep "$KEYPHRASE" > $GATEWAYIPADDRESS

# make sure the browse was successful
if [ -f $GATEWAYIPADDRESS ]
then

# assume at first that IP address has not changed
IPCHANGED="no"

# check if there is an old address to compare to
if [ -f $GATEWAYIPADDRESSOLD ]
then

  # checks to see if they are different
  diff $GATEWAYIPADDRESS $GATEWAYIPADDRESSOLD | grep "$KEYPHRASE" > /dev/null
  if [ $? -eq 0 ]
  then
    # OK, we know they are different
    # set the change variable appropriately
    IPCHANGED="yes"
    rm $GATEWAYIPADDRESSOLD
    mv $GATEWAYIPADDRESS $GATEWAYIPADDRESSOLD
  fi
else

  # else just create the old $GATEWAYIPADDRESSOLD file
  mv $GATEWAYIPADDRESS $GATEWAYIPADDRESSOLD
  # set the change variable appropriately
  IPCHANGED="yes"
fi

# Now send the message if the ip address has indeed been changed
if [ $IPCHANGED = "yes" ]
then
  lynx -source -auth=${USERNAME}:${PASSWORD} http://dynamic.zoneedit.com/auth/dynamic.html?host=${MYDOMAIN1} 2> /dev/null
    # what to do in case of failure
    if [ $? -ne 0 ]
    then
      echo "Error browsing to Zoneedit"
      rm $GATEWAYIPADDRESSOLD
      exit
    fi
  lynx -source -auth=${USERNAME}:${PASSWORD} http://dynamic.zoneedit.com/auth/dynamic.html?host=${MYDOMAIN2} 2> /dev/null
    # what to do in case of failure
    if [ $? -ne 0 ]
    then
      echo "Error browsing to Zoneedit"
      rm $GATEWAYIPADDRESSOLD
      exit
    fi
  lynx -source -auth=${USERNAME}:${PASSWORD} http://dynamic.zoneedit.com/auth/dynamic.html?host=${MYDOMAIN3} 2> /dev/null
    # what to do in case of failure
    if [ $? -ne 0 ]
    then
      echo "Error browsing to Zoneedit"
      rm $GATEWAYIPADDRESSOLD
      exit
    fi

fi

# Problems reading/writing to the file
else
  echo "Cannot access $GATEWAYIPADDRESS"
fi

I put this in my "crontab" file to be run every hour. A few comments are in order here. This script checks the IP address hourly, but it only updates with ZoneEdit.com if the address has CHANGED!!! This is the least we can do to preserve a free service. My only other comment concerns the use of "http://www.whatismyip.com" hourly. This can be considered net abuse. Although this will work, we don't want to make unnecessary demands on free services. In fact I browse to a page on my router that gives the IP address. This keeps the traffic down.

This page has been visited   times since December 28, 2005