By Joseph Obernberger
The domain name lovehorsepower.com was purchased from hostway for
about $7.00 per year. Hostway, unlike some registrars, allows you
to specify the name-servers used for the domain without specifying an
IP address. You do, however, still need to give at least two addresses. In
my case, I only have one machine, so the two addresses that I gave resolve
to the same IP address. Since I'm using dyndns I
used these two addresses:
cybrina.mine.nu and joeo.mine.nu which both resolve using dyndns name-servers
to the same IP. I completely removed the name-servers that hostway used
for lovehorsepower.com.
Hostway, in turn, updates the root servers to point to cybrina.mine.nu as the authoritative machine for lovehorsepower.com. I found the dig (domain information groper) a very valuable tool. Using a root server for the name server, dig now reports:
dig @a.gtld-servers.com lovehorsepower.com
; <<>> DiG 9.2.1 <<>> @a.gtld-servers.com lovehorsepower.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 34700
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 2, ADDITIONAL: 0
;; QUESTION SECTION:
;lovehorsepower.com. IN A
;; AUTHORITY SECTION:
lovehorsepower.com. 172800 IN NS cybrina.mine.nu.
lovehorsepower.com. 172800 IN NS joeo.mine.nu.
;; Query time: 79 msec
;; SERVER: 192.5.6.30#53(a.gtld-servers.com)
;; WHEN: Thu Jul 10 21:44:56 2003
;; MSG SIZE rcvd: 84
Notice the AUTHORITY SECTION reports that the name servers
(NS) for the lovehorsepower.com domain are cybrina.mine.nu and joeo.mine.nu. The
value 172800 is the number of seconds the root server will wait until
it asks again for who is authoritative for lovehorsepower.com. Notice
that there are no actual IP addresses given. This is what makes
the setup unusual. Since my server does not have a static IP address,
I can not specify an IP to the root server, or if I did, I would have
to update it when it changed. Having no IP address specified is
OK, however, since the names cybrina.mine.nu and joeo.mine.nu are resolvable
using dyndns's name-servers. If, I did in fact have a static IP
address, I would specify one to hostway, who, in turn, would give that
IP address back to the root servers.
For example, lets ask a root server about sun.com:
dig @a.gtld-servers.com sun.com
; <<>> DiG 9.2.1 <<>> @a.gtld-servers.com sun.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 49232
;; flags: qr rd; QUERY: 1, ANSWER: 0, AUTHORITY: 4, ADDITIONAL: 4
;; QUESTION SECTION:
;sun.com. IN A
;; AUTHORITY SECTION:
sun.com. 172800 IN NS ns8.sun.com.
sun.com. 172800 IN NS ns2.sun.com.
sun.com. 172800 IN NS ns7.sun.com.
sun.com. 172800 IN NS ns1.sun.com.
;; ADDITIONAL SECTION:
ns8.sun.com. 172800 IN A 192.18.43.12
ns2.sun.com. 172800 IN A 192.18.99.5
ns7.sun.com. 172800 IN A 192.18.42.12
ns1.sun.com. 172800 IN A 192.18.128.11
;; Query time: 41 msec
;; SERVER: 192.5.6.30#53(a.gtld-servers.com)
;; WHEN: Thu Jul 10 21:55:53 2003
;; MSG SIZE rcvd: 161
Notice the AUTHORITY SECTION gives 4 name-servers who are
authoritative for sun.com. Also notice the ADDITIONAL SECTION which
gives the actual IP address for the 4 name-servers. This must be
done this way since to discover the IP address of ns8.sun.com, one would
have to ask one of the name-servers authoritative for sun.com; one of
which is ns8.sun.com. This is the 'chicken in the egg' issue that
is resolved using so called glue records. In the sun.com
case, there are 4 glue records one for ns8.sun.com, ns2.sun.com, ns7.sun.com
and ns1.sun.com. These glue records should be specified in your
own zone file as well as to the registrar you are using for the domain
name.
To setup DNS on my server (cybrina), the following zone file is specified. The name of the zone file is the domain name.
cat /var/named/lovehorsepower.com
; Zone file for lovehorsepower.com
;
; The full zone file
;
$TTL 1800
@ IN SOA cybrina.mine.nu. joeo.cybrina.mine.nu. (
200363024 ; serial, todays date + todays serial #
900 ; refresh, seconds
900 ; retry, seconds
3600 ; expire, seconds
1800 ) ; minimum, seconds
;
NS cybrina.mine.nu.
NS joeo.mine.nu.
NS cybrina.lovehorsepower.com.
TXT "Love Horsepower Domain"
MX 10 mail.lovehorsepower.com. ; Primary Mail Exchanger
; GLUE RECORD
cybrina.lovehorsepower.com. 1M A 68.166.65.216
lovehorsepower.com. 1M A 68.166.65.216
localhost A 127.0.0.1
www 1M A 68.166.65.216
TXT "Web Server for lovehorsepower.com"
ftp 1M A 68.166.65.216
TXT "FTP Server for lovehorspower.com"
mail 1M A 68.166.65.216
TXT "Mail Server for lovehorsepower.com"
test 1M A 68.166.65.216
TXT "Testing"
ns 1M A 68.166.65.216
sig 1M A 68.166.65.216
The SOA section states that cybrina.mine.nu is authoritative
for lovehorsepower.com, and to email joeo@cybrina.mine.nu for
administration. The IP addresses in this zone file (68.166.65.216)
must be updated whenever the ISP assigns a new IP (in my case Earthlink). Since
the IP address is dynamic the TTL (time to live) for each address (such
as mail.lovehorsepower.com) is set to 1M (1 minute).
Now that one is authoritative for the domain, you can add whatever additional
names you would like. In the above zone file, there are www, ftp, mail,
test, sig, and cybrina.
Cybrina uses bind 9 (named) for the name server which comes packaged with Redhat
7.3. Since a dynamic IP address is used, whenever a new IP is assigned
to cybrina from the ISP (Earthlink), the zone file must be updated as well. DynDNS.org
provides a program called ddlcient which
is a perl script to update dynDNS's records whenever a new IP address is assigned
from the internet service provider. I modified the script to call a program
that rewrites the zone file for lovehorsepower.com whenever ddclient discovers
a new IP address and updates dynDNS's records. The code is very simple
and just takes an IP address as an argument and rewrites the zone file using
an updated serial number. It then runs 'rndc reload' which causes named
(bind 9) to reload the zone file.
The program also uses a very short script to strip out the serial number from
the zone file to make it easier to update. That script is:
cat /var/named/lovehorsepower.com | grep "serial, todays date" > /usr/sbin/serial.txt
The program source can be downloaded here along with the makefile and serial script. The modified ddclient (just inserted calls to adjust_dns) can be downloaded from here.
Virtual Webs with Apache
To configure the Apache web server to respond to different names (such as test.lovehorsepower.com) a virtual web can be set up very easily. This is handy so that you can have many different web 'sites' using the same IP address and the same server. For example, you could have www.lovehorsepower.com, and sig.lovehorsepower.com be completely different websites, but served by the same machine. A block of the httpd.conf file is shown:
# Main host
NameVirtualHost *
<VirtualHost *>
ServerName "cybrina.mine.nu"
DocumentRoot "/www/htdocs"
</VirtualHost>
<VirtualHost *>
ServerName "sig.lovehorsepower.com"
DocumentRoot "/www/htdocs/sig"
</VirtualHost>