Appendix e
Appendix e
Without the Domain Name System (DNS), your computer would need to have
a huge address book of names and addresses that included every
computer on the Internet. If you wanted to send e-mail to a user at
host.foo.com, the system would have to figure out that you wanted to
talk to the machine at address 1.2.3.4 and do its thing.
What a mess! Believe it or not, this was the way that it was until
1984. A large host table (HOSTS.TXT) was maintained in one server at
the Stanford Research Institute Network Information Center (the NIC).
With more and more networks going online, it b ecame almost impossible
to keep the host list up-to-date. Before the list would be downloaded
by all hosts, someone would have introduced a change that would
require downloading yet another new list!
Vestiges of this address book are still used by your system to look up
hosts in your local network- the /etc/hosts file.
The original DNS system was described in the 1983 Request for Comment
(RFC) documents 882 and 883. Both have been updated and superseded in
1987 by RFCs 1034 and 1035, and again in 1990 by RFCs 1101 and 1183,
which implement the current specification o f the DNS. In software,
DNS is implemented on UNIX systems as the Berkeley Internet Name
Domain (BIND) system. BIND is shipped in almost every UNIX box.
dig A domain information groper; a command line tool that can be used
to gather information from a DNS server. It has zillions of options.
dnsquery A program that uses the BIND resolver library calls to query
name servers.
host A program that does reverse DNS lookups. Instead of specifying a
hostname to find its IP address, you supply the IP, and host returns
the hostname.
named-xfer A tool for doing zone transfers. Usually this program is
called by other software. It can also be used to debug a zone transfer
problem. But more than likely you won't use it at all.
named The Internet domain name server daemon, and the focus of my
attention in this appendix.
named.reload A convenience program to restart the named daemon and
force the server to reload and update its database files, if
necessary. This program uses a hangup (SIGHUP) signal.
named.restart A convenience program to restart the named daemon and to
force the server to reload and update its database files, if
necessary. This program kills the name server by using a kill
(SIGKILL) signal and then starts a new server.
ndc A cool program that allows you to send various signals to the
named daemon. This command allows you to monitor the status of the
server as well as to force database reloads. It has many other
options.
What Is DNS?
host.subdomain.domain.topleveldomain
Fig. E.1. The U.S. Top-Level Domains. Domains are shown in ovals. A
machine is shown as a box
Within each state's subdomain there are locality names. These can be
cities, counties, or local names. The locality can be a CI for city or
CO for county:
K12 For public schools. Private schools add the PVT name,
schoolname.PVT.K12.state.US.
CC For community colleges: collegename.CC.state.US.
TEC For technical colleges: collegename.TEC.state.US.
LIB For libraries: library.LIB.state.US.
STATE For state government agencies: agency.STATE.state.US.
GEN For General Independent Entity. For anything that doesn't fit in
the other categories.
Fig. E.2. The U.S domain. Notice that other countries and standard U.S
top level domains share the same level.
Table E.1 lists all the top-level domains known at the time of this
writing. However, this may be outdated by now. This table is a
reflection on the dynamics of our world: New countries are formed, and
new countries join the Internet c ommunity.
Before you proceed, you will need to register your domain name with
the InterNIC if your domain falls into any of the ORG, NET, EDU, GOV,
and COM domains. If you want to register a U.S. domain, go to http://
www.isi.edu/in-notes/usdnr.
Choose the registration services link. Once on that page, choose the
Whois registration tool. This page gives you a Web interface to the
whois program. The whois program allows you to research domain name
information among other things. If you f ind a match, your name is in
use. Some things to keep in mind: domain names cannot be longer than
26 characters and can only contain letters, digits, and dashes.
Once you find a name that is not in use, you can go ahead and complete
the World Wide Web application form. You will need to have the address
for two name servers that supply information about your domain. The
machines you list in the application will be queried for information
about your domain, so you need to make sure that they are reachable or
if your network is not up, that someone runs DNS for you temporarily.
Usually your service provider can help with this. If the name servers
are not found dur ing the verification process, your application will
be delayed.
Once you complete the online form, a copy of the application will be
mailed to you. Please note that the application you filled online is
not processed. To process the request you need to e-mail the form back
to do mreg@internic.net.
Once your domain is approved, you are ready to set up your own domain
name server. Approvals can take anywhere from one day to three weeks
depending on load and other things.
To run a domain name server, you will need to install BIND. The source
for BIND can be found at http://www.isc.org/isc or from
ftp://ftp.vix.com/pub/bind/re lease/bind.tar.gz. For your
convenience, a copy has been included on the CD-ROM that accompanies
this book.
Once you obtain the source, you should follow the compilation
instructions in the package. The official release at the time I
grabbed my copy was 4.9.3. As usual, running outdated software creates
a source of security problems. If your system comes wit h an older
version of the software, you really should upgrade. The installation
steps are as follows:
1. FTP the source.
2. Unpack the source.
3. Change your directory to the BIND distribution directory.
4. Create a build directory by issuing a make DST=build links.
5. Cd to the build directory you just created.
6. Set the appropriate options, if any, in conf/options.h.
7. Configure the makefile for settings appropriate for your
machine/os. This is easily done by removing the # from all the
lines under the section that describes your operating system. If
you have special locations where you want the binaries inst alled,
set the DEST (for destination) variable to a path more palatable
to you.
______________________________________________________________
NOTE: To avoid confusion, keep the default paths and rename your
distribution copies of named and nslookup that came with your
system to named.dist and nslookup.dist, respectively. This way you
can keep your original binaries in case you run into trouble and
you need to revert to something known to work.
______________________________________________________________
If compilation fails, you may want to add ./bin to your path. You can
do this simply enough on a csh by issuing the following:
After make builds everything, you will want to verify which files are
going to be installed. Issue a make -n install to see where make wants
to install everything. This will list all the commands that are going
to be executed by the install target with out actually running them.
You should then backup or rename any remaining files that are going to
be replaced with an .orig extension.
If you are running SunOS 4.1.x, NetBSD-1 or Solaris 2.x, you can
integrate the new client-side resolver library into your system shared
libraries. This will upgrade all dynamically linked programs to use
the new libraries instead of the o ld ones. For more information, read
the information included in the shres directory of the BIND release.
The IN-ADDR.ARPA domain has enough room for every host on the Internet
given the current 32-bit (four-octet) IP representation.
Remember the domain names are read from the bottom up, like
host.domain.dom. Because of this, IN-ADDR.ARPA domains are
represented with their IP addresses in reverse.
This way the name server can group, organize, and retrieve
IP-to-hostname queries as efficiently as the regular name-based
queries.
Before you proceed, you may want to create your db.DOMAIN and db.IP
files. I created mine in /usr/local/named and renamed DOMAIN and IP
to the name of my domain and network IP, respectively
(db.ACCESSLINK.COM a nd db.204.95.222).
SOA Record
1 ; Serial ID
IN stands for Internet. There are other possible values, but for this
example, and more likely for your needs, this will fit the bill.
The serial id of the record is very important. Any time you update any
of the database files, you must increment this number. If for some
reason you forget to increment the serial id, the secondary name
servers won't realize that you have modified the database and won't
update their information. Secondary name servers use this number to
determine if their copy of the db file is up-to-date. A good strategy
is to put the current date in a format such as YYYYMMDDR where
R is the number of the revision (in case you modify the file more than
once on the same day): 1.
The refresh interval tells the secondary server how often to check for
updates on this file.
The retry interval tells the secondary server how long to wait before
trying to reach the primary server, if the initial attempt failed.
The TTL value specifies how long resource records served from this
file will remain in a caching server's cache. After the TTL expires,
the server will have to requery your server for information about your
domain.
NS Records
Next, you need to specify the names of domain name servers in your
domain. You do this by using name server (NS) resource records. They
look like this:
"domain.dom IN NS hostname.domain.dom."
All domain name servers that you list here will be designated
authoritative for the domain. Replace domain.dom and
hostname.domain.dom. with the name of your domain (don't forget the
period) and the fully qualified domain name of the domain name server
. An example of this is as follows:
ACCESSLINK.COM IN NS ns1.ACCESSLINK.COM.
ACCESSLINK.COM IN NS ns2.ACCESSLINK.COM.
; Host Addresses
localhost IN A 127.0.0.1
router IN A 204.95.222.100
www IN A 204.95.222.200
hydrogen IN A 204.95.222.1
lithium IN A 204.95.222.3
; Aliases
The db.IP file stores an IP-to-name lookup table. The main difference
between the two is that instead of listing regular IP addresses, it
uses the funny IN-ADDR.ARPA notation.
Like the db.DOMAIN file, the db.IP file has a SOA Record. The only
difference is that the name of the domain is specified as IN-ADDR.ARPA
domain notation:
1 ; Serial ID
The db.IP file also lists NS resource records. These are also
specified in IN-ADDR.ARPA domain notation:
1.222.95.204.IN-ADDR.ARPA. IN NS ns1.ACCESSLINK.COM.
3.222.95.204.IN-ADDR.ARPA. IN NS ns2.ACCESSLINK.COM.
In addition, the db.IP file also lists its reverse version of the
Address Records (IN A entries, in your db.DOMAIN file). These are
called PTR Records.
PTR Records
The DNS resource records used for IP-to-name mappings are called
Pointer (PTR) Records. There's one record for each IP address on your
network. All IP addresses are specified using the IN-ADDR.ARPA domain
notation:
In addition to the db.DOMAIN and db.IP files, the server will need a
db.IP file for the loopback interface. This is a special IP address
that hosts use to route traffic to themselves. The address of the
loopback network is (almost always) 127.0.0.0, an d the host number
for the localhost is 127.0.0.1.
The file is pretty standard. If you copy your other db.IP file, you'll
only need to delete all PTR records and insert a new PTR record
pointing to the localhost, the last line in the following listing:
1 ; Serial ID
; Name Servers
1.222.95.204.IN-ADDR.ARPA. IN NS ns1.ACCESSLINK.COM.
3.222.95.204.IN-ADDR.ARPA. IN NS ns2.ACCESSLINK.COM.
; localhost
In addition to knowing all the gory details about your network, DNS
needs to know how to contact the name servers for the root domain.
Your BIND release should have included a copy of this file. If not,
you can find a copy at
ftp://ftp.rs.internic.net/domain/named.root
This file is only used at startup. After named is able to contact the
top-level name servers, it updates its internal information.
If you are following at the terminal, you have now developed and
downloaded all the files you need to get named going. However, you
need to create a configuration file that can tell named where to find
all its files. If you have followed my example and created your files
in /usr/local/named, your boot file will look like this:
directory /usr/local/named
Here's how my boot file looks after I replace the placeholders with
the naming convention described earlier:
directory /usr/local/named
cache . named.root
Starting named
/etc/named.
If you located your boot file somewhere other than in the default
/etc/named.boot, you can tell named where to look for it by using the
-b flag, /etc/named -b pathtobootfile.
If there were any errors in your configuration files, named will log
an error using syslog, and if the error is bad enough, it will quit.
To see where named will log any errors, type in the following:
This will print the name of the file where named will log errors to.
In my case, the result of this command is /usr/adm/messages, yours may
be /usr/var/messages or something like that. Please note that by
default named logs a restart message whenever i t starts. It is very
likely that if you made a typo or forgot to enter a field, named will
complain by saying ...Unknown type:... or ...unknown field 'foo'....
Look for the offending line and compare it to the examples.
If the domainname has not been set up, the superuser can set it up by
giving the command an argument:
domainname domain.dom
Replace domain.dom with the name of your domain. You may want this to
happen automatically at the system startup time. Just include the line
domainname domain.dom on your /etc/rc.local or equivalent system
startup file.
Server: ns1.ACCESSLINK.COM
Address: 204.95.222.1
Name: lithium.ACCESSLINK.COM
Address: 204.95.222.3
You may want to also see if you can use nslookup to find a machine out
of your network::
% nslookup www.next.com
Server: ns1.ACCESSLINK.COM
Address: 204.95.222.1
Non-authoritative answer:
Name: ftp.next.com
Address: 129.18.1.3
Aliases: www.next.com
Server: ns1.inc.net
Address: 204.95.160.2
Name: lithium.ACCESSLINK.COM
Address: 204.95.222.3
if -f [/etc/named.boot]; then
/usr/etc/named
fi
And that's it. To finish, copy the startup commands you put in your
primary server's rc.local file.
Before any client in your network can use your name server, you'll
need to create the /etc/resolv.conf file. This file contains a list of
all the name servers in your network and the order they are queried
in. The basic format is as follows:
search domainname...
nameserver ipaddress
seach accesslink.com
nameserver 204.95.222.1
nameserver 204.95.222.2
Summary
Because the intention of this appendix was to provide you with a basic
reference and to help you quickly set up DNS, the information is by no
means complete. DNS is not particularly complicated. However, complex
networks require complex DNS setups, and as should be expected,
powerful software cannot be mastered in an appendix; DNS keeps the
Internet running. This appendix gets your DNS running; it is not an
absolute reference on the subject. For more information, I would
suggest that you read the docum entation included with your release of
DNS. If you FTPed the package, it contains excellent documentation as
well as a frequently asked questions (FAQ) list. As for printed
information, the following might be helpful.
DNS and BIND, by Paul Albitz & Cricket Liu, is published by O'Reilly
and Associates, Inc. ISBN 1-56592-010-4. It's a great book. However,
some of the information is a little out-of-date.
For an excellent UNIX system administration book, the best this author
has ever seen, check out UNIX System Administration Handbook, now in
its second edition. While it is impossible to cover UNIX in one
volume, it does an excellent job of expla ining the art of UNIX system
administration. It has more than enough detail to get you going. This
book was written by Evi Nemeth, Garth Snyder, Scott Seebass, and Trent
R. Hein. It is published by Prentice Hall, ISBN 0-13-151051-7.