HOWTO Host a domain with dhcp address

From LinuxNewbie

I will be posting a multipart howto that covers how to get a domain on the internet that points to your dynamic dhcp assigned address. It will also work with static IPs.

You are welcome to feedback with your interests. I am also interested in registrars that sell domains for $10US +/- $2. (no more than $12)

GoBoi says,
What about GoDaddy.com? That's who I use, and I dig 'em!


I will try to give coverage to:

  • Registering a domain
  • DNS Entries
  • Some information about web hosting, mail serving, and how vhosts for bnc's work



First, go to godaddy.com and register a domain for about $9US.

Go to zoneedit.com and register. They will host 5 domains DNS service.
Add your new domain to your account. They will tell you that you need to change the Primary and Secondary DNS on your domain. Write the names (ns1.zoneedit.com as an example) and the IP addresses down.

Go back to godaddy.com and edit your domain. Change the DNS servers for your domain to the information zoneedit gave you.

You now have a domain, and DNS. Now just the dynamic update part...
There are Windows clients that will update ZoneEdit or you can do it with a shell script in linux. You will have to find a Windows client; try undernetwindowsnewbie.org or something (I am kidding, I have never tried that website).

A script is to follow shortly...
I guess I should note you can use any registrar. Some are definately better than others.

Below is a script to update zoneedit. Do something like:

su
cd
pico zoneedit_update.sh

and paste the code below in to the file, then save.

Put your zoneedit username and password in the user and pass spots, and put each name you want to update in the section that has fqdn.
You may note there are several fqdn in a row. When I wrote this I had one IP and several domains and subdomains and wanted them all updated. You can put "domain.com www.domain.com leetcoder.com" seperated by spaces and it will do them all for you.
Code:

#!/bin/bash
# zoneedit_update.sh
# Modified 03100301

# ZoneEdit username, password, and FQDN
ZEUSER='user'
ZEPASS='pass'
# Script will update multiple domains
# seperate with a space
ZEDOMAINS='fqdn fqdn fqdn'

# persistant script at bottom
# This is designed for whatismyip.com in combination with zoneedit.com

# 8 Aug 03
# Fixed error in persist script
# changed logging to file /var/log/zoneedit.log
#   rather than logging to screen

#######################################
# Don't edit below if you don't know what you are doing
#######################################

touch /var/log/zoneedit.log
ADDYINFO=`wget -O - -q http://whatismyip.com|grep "Your ip is"`

for DOMAINSTR in $ZEDOMAINS
do
# echo $TCPPORT
  echo >>/var/log/zoneedit.log
  echo "Updating FQDN: $DOMAINSTR" \
>>/var/log/zoneedit.log
wget -O - -q --http-user=$ZEUSER --http-passwd=$ZEPASS \
"http://dynamic.zoneedit.com/auth/dynamic.html?host=$DOMAINSTR" \
>>/var/log/zoneedit.log
done

echo >>/var/log/zoneedit.log
echo "Started: $ADDYINFO" \
>>/var/log/zoneedit.log
{ while [ "1" ]
do
  NEWADDYINFO=`wget -O - -q http://whatismyip.com|grep "Your ip is"`
  if [ "$ADDYINFO" != "$NEWADDYINFO" ] && [ "$NEWADDYINFO" != "" ]
  then
    ADDYINFO=$NEWADDYINFO
    for DOMAINSTR in $ZEDOMAINS
    do
      echo >>/var/log/zoneedit.log
      echo "Updating FQDN: $DOMAINSTR" \
>>/var/log/zoneedit.log
      wget -O - -q --http-user=$ZEUSER --http-passwd=$ZEPASS \
"http://dynamic.zoneedit.com/auth/dynamic.html?host=$DOMAINSTR" \
>>/var/log/zoneedit.log
    done
  fi
# sleep for how many seconds? 600=5 mins, 1200=10 mins
  sleep 1200
done }&
echo PID: $!


check () {
#!/bin/bash
# the script below can be used with cron to be sure script continues to run
# It is has only been placed in the function for simplicity of presentation.

# ze_persist.sh
# text to match with grep for the process
MATCHTEXT=zoneedit_update
# Where the update script is located
ZESCRIPT=/root/zoneedit_update.sh

# So you can add it to a cron so it will restart if it stops for some
# reason (restart, crash, kill, etc)
# Assuming the filename is $ZESCRIPT

if ! ps -A | grep "$MATCHTEXT" >/dev/null
then
  echo >>/var/log/zoneedit.log
  echo "ZoneEdit Update script is not running, starting..." \
>>/var/log/zoneedit.log
  $ZESCRIPT &
else
  echo >>/var/log/zoneedit.log
  echo "ZoneEdit Update script is already running." \
>>/var/log/zoneedit.log
  exit
fi
}