From Gentle Sloth, 6 Days ago, written in Plain Text.
This paste is a reply to DNS-HOWTO from Gentle Sloth - go back
Embed
Viewing differences between DNS-HOWTO and DNS-HOWTO
  DNS HOWTO
HOWTO
  Nicolai Langfeldt (dns-howto(at)langfeldt.net), Jamie   v9.0, 2001-12-20

  
0
  
  
HOWTO become a totally small time DNS admin.
  ______________________________________________________________________

  
admin.
  ______________________________________________________________________

  
Table of Contents


Contents


  1. Preamble

Preamble

     1.1 Legal stuff
stuff
     1.2 Credits and request for help.
help.
     1.3 Dedication
Dedication
     1.4 Updated versions

versions

  2. Introduction.

Introduction.

     2.1 Other nameserver implementations.

implementations.

  3. A resolving, caching name server.

server.

     3.1 Starting named
named
     3.2 Resolvers
Resolvers
     3.3 Congratulations

Congratulations

  4. Forwarding

Forwarding

  5. A

A

     5.1 But first some dry theory
theory
     5.2 Our own domain
domain
     5.3 The reverse zone
zone
     5.4 Words of caution
caution
     5.5 Why reverse lookups don't work.
work.
        5.5.1 The reverse zone isn't delegated.
delegated.
        5.5.2 You've got a classless subnet
subnet
     5.6 Slave servers

servers

  6. Basic security options.

options.

     6.1 Restricting zone transfers
transfers
     6.2 Protecting against spoofing
spoofing
     6.3 Running named as non-root

non-root

  7. A real domain example

example

     7.1 /etc/named.conf (or /var/named/named.conf)
conf)
     7.2 /var/named/root.hints
hints
     7.3 /var/named/zone/127.0.0
0
     7.4 /var/named/zone/land-5.com
com
     7.5 /var/named/zone/206.6.177

177

  8. Maintenance

Maintenance

  9. Migrating to BIND 9

9

  10. Questions and Answers

Answers

  11. How to become a bigger time DNS admin.



  ______________________________________________________________________

admin.



  ______________________________________________________________________

  1.  Preamble

  
Preamble

  
Keywords: DNS, BIND, BIND 4, BIND 8, BIND 9, named, dialup, PPP, slip,
  
slip,
  
ISDN, Internet, domain, name, resolution, hosts, caching.


  
caching.


  
This document is part of the Linux Documentation Project.


Project.


  1.1.  Legal stuff

  
stuff

  
(C)opyright 1995-2001 Nicolai Langfeldt, Jamie Norrish & Co. Do not
  
not
  
modify without amending copyright, distribute freely but retain
  
retain
  
copyright message.


message.


  1.2.  Credits and request for help.

  
help.

  
I want to thank all the people that I have bothered with reading this
  
this
  
HOWTO (you know who you are) and all the readers that have e-mailed
  
e-mailed
  
suggestions and notes.


  
notes.


  
This will never be a finished document; please send me mail about your
your
  problems and successes.  You can help make this a better HOWTO.  So
  
So
  
please send comments and/or questions or money to
to
  janl(at)langfeldt.net.  Or buy my DNS book (it's titled "The Concise
"The Concise
  Guide to DNS and BIND, the bibliography has ISBNs).  If you send e-
  
e-
  
mail and want an answer please show the simple courtesy of making sure
sure
  that the return address is correct and working.  Also, please read the
the
  ``qanda'' section before mailing me.  Another thing, I can only
  
only
  
understand Norwegian and English.


English.


  This is a HOWTO.  I have maintained it as part of the LDP since 1995.
1995.
  I have, during 2000, written a book on the same subject.  I want to
  
to
  
say that, though this HOWTO is in many ways much like the book it is
is
  not a watered down version concocted to market the book.  The readers
  
readers
  
of this HOWTO have helped me understand what is difficult to
to
  understand about DNS.  This has helped the book, but the book has also
also
  helped me to think more about what this HOWTO needs.  The HOWTO begot
begot
  the book.  The book begot version 3 of this HOWTO.  My thanks to the
  
the
  
book publisher, Que, that took a chance on me :-)



:-)



  1.3.  Dedication

Dedication

  This HOWTO is dedicated to Anne Line Norheim Langfeldt.  Though she
  
she
  
will probably never read it since she's not that kind of girl.


girl.


  1.4.  Updated versions

  
versions

  
You should be able to find updated versions of this HOWTO both at
  <http://langfeldt.net/DNS-HOWTO/> 
at
  &lt;http://langfeldt.net/DNS-HOWTO/&gt; 
and on  <http://www.&lt;http://www.linuxdoc.org/>.
  
org/&gt;.
  
Go there if this document is dated more than 9 months ago.


ago.


  2.  Introduction.

  
Introduction.

  
What this is and isn't.


isn't.


  DNS is the Domain Name System.  DNS converts machine names to the IP
IP
  addresses that all machines on the net have.  It translates (or "maps"
  
&quot;maps&quot;
  
as the jargon would have it) from name to address and from address to
to
  name, and some other things.  This HOWTO documents how to define such
  
such
  
mappings using Unix system, with a few things specific to Linux.


  
Linux.


  
A mapping is simply an association between two things, in this case a
a
  machine name, like ftp.linux.org, and the machine's IP number (or
(or
  address) 199.249.150.4.  DNS also contains mappings the other way,
  
way,
  
from the IP number to the machine name; this is called a "reverse
  mapping".


  
&quot;reverse
  mapping&quot;.


  
DNS is, to the uninitiated (you ;-), one of the more opaque areas of
of
  network administration.  Fortunately DNS isn't really that hard.  This
This
  HOWTO will try to make a few things clearer.  It describes how to set
  
set
  
up a simple DNS name server, starting with a caching only server and
and
  going on to setting up a primary DNS server for a domain.  For more
  
more
  
complex setups you can check the ``qanda'' section of this document.
  
document.
  
If it's not described there you will need to read the Real
Real
  Documentation.  I'll get back to what this Real Documentation consists
  
consists
  
of in ``the last chapter''.


  
chapter''.


  
Before you start on this you should configure your machine so that you
  
you
  
can telnet in and out of it, and successfully make all kinds of
  
of
  
connections to the net, and you should especially be able to do telnet
telnet
  127.0.0.1 and get your own machine (test it now!).  You also need good
good
  /etc/nsswitch.conf, /etc/resolv.conf and /etc/hosts files as a
a
  starting point, since I will not explain their function here.  If you
  
you
  
don't already have all this set up and working the Networking-HOWTO
Networking-HOWTO
  and/or the Networking-Overview-HOWTO explains how to set it up.  Read
  them.


  
Read
  them.


  
When I say `your machine' I mean the machine you are trying to set up
  
up
  
DNS on, not any other machine you might have that's involved in your
  
your
  
networking effort.


  
effort.


  
I assume you're not behind any kind of firewall that blocks name
name
  queries.  If you are you will need a special configuration --- see the
  
the
  
section on ``qanda''.


``qanda''.


  Name serving on Unix is done by a program called named.  This is a
  
a
  
part of the ``BIND'' package which is coordinated by The Internet
Internet
  Software Consortium.  Named is included in most Linux distributions
  
distributions
  
and is usually installed as /usr/sbin/named, usually from a package
  
package
  
called BIND, in upper or lower case depending on the whim of the
  packager.


  
the
  packager.


  
If you have a named you can probably use it; if you don't have one you
  
you
  
can get a binary off a Linux ftp site, or get the latest and greatest
  
greatest
  
source from  <ftp://ftp.&lt;ftp://ftp.isc.org/isc/bind9/>.  org/isc/bind9/&gt;.  This HOWTO is about BIND
BIND
  version 9.  The old versions of the HOWTO, about BIND 4 and 8, is
  
is
  
still available at  <http://langfeldt.net/DNS-HOWTO/> &lt;http://langfeldt.net/DNS-HOWTO/&gt; in case you use
use
  BIND 4 or 8 (incidentally, you will find this HOWTO there too).  If
  
If
  
the named man page talks about (at the very end, in the FILES section)
section)
  named.conf you have BIND 8; if it talks about named.boot you have BIND
BIND
  4.  If you have 4 and are security conscious you really ought to
to
  upgrade to the latest version of BIND 8.  Now.


Now.


  DNS is a net-wide database.  Take care about what you put into it.  If
If
  you put junk into it, you, and others, will get junk out of it.  Keep
  
Keep
  
your DNS tidy and consistent and you will get good service from it.
  
it.
  
Learn to use it, admin it, debug it and you will be another good admin
  
admin
  
keeping the net from falling to its knees by mismanagement.


  
mismanagement.


  
Tip: Make backup copies of all the files I instruct you to change if
  
if
  
you already have them, so that if after going through this nothing
  
nothing
  
works you can get it back to your old, working state.


state.


  2.1.  Other nameserver implementations.

  
implementations.

  
This section was written by Joost van Baal.


Baal.


  Various packages exist for getting a DNS server on your box.  There is
  
is
  
the BIND package ( <http://www.&lt;http://www.isc.org/products/BIND/>); the
org/products/BIND/&gt;); the
  implementation this HOWTO is about.  It's the most popular nameserver
  
nameserver
  
around and it's used on the vast majority of name serving machines on
on
  the Internet, around and being deployed since the 1980's.  It's
It's
  available under a BSD license.  Since it's the most popular package,
package,
  loads of documentation and knowledge about BIND is around.  However,
  
However,
  
there have been security problems with BIND.


  
BIND.


  
Then there is djbdns ( <http://djbdns.org/>), &lt;http://djbdns.org/&gt;), a relatively new DNS
DNS
  package written by Daniel J. Bernstein, who also wrote qmail.  It's a
  
a
  
very modular suite: various small programs take care of the different
different
  jobs a nameserver is supposed to handle.  It's designed with security
security
  in mind.  It uses a simpler zone-file format, and is generally easier
easier
  to configure.  However, since it's less well known, your local guru
guru
  might not be able to help you with this.  Unfortunately, this software
software
  is not Open Source.  The author's advertisement is on
  <http://cr.
on
  &lt;http://cr.
yp.to/djbdns/ad.html>.


  
html&gt;.


  
Whether DJBs software is really an improvement over the older
older
  alternatives is a subject of much debate.  A discussion (or is it a
  
a
  
flame-war?) of BIND vs djbdns, joined by ISC people, is on
  <http://www.
on
  &lt;http://www.
isc.org/ml-archives/bind-users/2000/08/msg01075.html>


html&gt;


  3.  A resolving, caching name server.

  
server.

  
A first stab at DNS config, very useful for dialup, cable-modem, ADSL
  
ADSL
  
and similar users.


  
users.


  
On Red Hat and Red Hat related distributions you can achieve the same
  
same
  
practical result as this HOWTO's first section by installing the
the
  packages bind, bind-utils and caching-nameserver.  If you use Debian
  
Debian
  
simply install bind (or bind9, as of this writing, BIND 9 is not
not
  supported by Debian Stable (potato)) and bind-doc.  Of course just
  
just
  
installing those packages won't teach you as much as reading this
this
  HOWTO.  So install the packages, and then read along verifying the
  
the
  
files they installed.


  
installed.


  
A caching only name server will find the answer to name queries and
and
  remember the answer the next time you need it.  This will shorten the
  
the
  
waiting time the next time significantly, especially if you're on a
  
a
  
slow connection.


connection.


  First you need a file called /etc/named.conf (Debian:
(Debian:
  /etc/bind/named.conf).  This is read when named starts.  For now it
  
it
  
should simply contain:


  ______________________________________________________________________
  
contain:


  ______________________________________________________________________
  
// Config file for caching only name server
  //
  
server
  //
  
// The version of the HOWTO you read may contain leading spaces
  
spaces
  
// (spaces in front of the characters on these lines ) in this and
and
  // other files.  You must remove them for things to work.
  //
  
work.
  //
  
// Note that the filenames and directory names may differ, the
  
the
  
// ultimate contents of should be quite similar though.

  
though.

  
options {
          
{
          
directory "/var/named";

          
&quot;/var/named&quot;;

          
// Uncommenting this might help if you have to go through a
a
          // firewall and things are not working out.  But you probably
          
probably
          
// need to talk to your firewall admin.

          
admin.

          
// query-source port 53;
  };

  
53;
  };

  
controls {
{
          inet 127.0.0.1 allow { localhost; } keys { rndc_key; };
  };

  
};
  };

  
key "rndc_key" {
          
&quot;rndc_key&quot; {
          
algorithm hmac-md5;
          
hmac-md5;
          
secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
  };

  
&quot;c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K&quot;;
  };

  
zone "." {
          
&quot;.&quot; {
          
type hint;
          
hint;
          
file "root.hints";
  };

  
&quot;root.hints&quot;;
  };

  
zone "0.&quot;0.0.127.in-addr.arpa" {
          
arpa&quot; {
          
type master;
          
master;
          
file "pz/127.&quot;pz/127.0.0";
  };
  ______________________________________________________________________



  
0&quot;;
  };
  ______________________________________________________________________



  
The Linux distribution packages may use different file names for each
  
each
  
kind of file mentioned here; they will still contain about the same
  things.


same
  things.


  The `directory' line tells named where to look for files.  All files
files
  named subsequently will be relative to this.  Thus pz is a directory
directory
  under /var/named, i.e., /var/named/pz.  /var/named is the right
  
right
  
directory according to the Linux File system Standard.


Standard.


  The file named /var/named/root.hints is named in this.
this.
  /var/named/root.hints should contain this:



  ______________________________________________________________________
  ;
  
this:



  ______________________________________________________________________
  ;
  
; There might be opening comments here if you already have this file.
  
file.
  
; If not don't worry.
  ;
  
worry.
  ;
  
; About any leading spaces in front of the lines here: remove them!
them!
  ; Lines should start in a ;, . or character, not blanks.
  ;
blanks.
  ;
  .                       6D  IN      NS      A.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      B.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      C.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      D.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      E.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      F.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      G.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      H.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      I.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      J.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      K.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      L.ROOT-SERVERS.NET.
NET.
  .                       6D  IN      NS      M.ROOT-SERVERS.NET.
NET.
  A.ROOT-SERVERS.NET.     6D  IN      A       198.41.0.4
4
  B.ROOT-SERVERS.NET.     6D  IN      A       128.9.0.107
107
  C.ROOT-SERVERS.NET.     6D  IN      A       192.33.4.12
12
  D.ROOT-SERVERS.NET.     6D  IN      A       128.8.10.90
90
  E.ROOT-SERVERS.NET.     6D  IN      A       192.203.230.10
10
  F.ROOT-SERVERS.NET.     6D  IN      A       192.5.5.241
241
  G.ROOT-SERVERS.NET.     6D  IN      A       192.112.36.4
4
  H.ROOT-SERVERS.NET.     6D  IN      A       128.63.2.53
53
  I.ROOT-SERVERS.NET.     6D  IN      A       192.36.148.17
17
  J.ROOT-SERVERS.NET.     6D  IN      A       198.41.0.10
10
  K.ROOT-SERVERS.NET.     6D  IN      A       193.0.14.129
129
  L.ROOT-SERVERS.NET.     6D  IN      A       198.32.64.12
12
  M.ROOT-SERVERS.NET.     6D  IN      A       202.12.27.33
  ______________________________________________________________________



33
  ______________________________________________________________________



  The file describes the root name servers in the world.  The servers
servers
  change over time and must be maintained now and then.  See the
  
the
  
``maintenance section'' for how to keep it up to date.


date.


  The next section in named.conf is the last zone.  I will explain its
its
  use in a later chapter; for now just make this a file named 127.0.0 in
  
in
  
the subdirectory pz: (Again, please remove leading spaces if you cut
  
cut
  
and paste this)


  ______________________________________________________________________
  
this)


  ______________________________________________________________________
  
$TTL 3D
3D
  @               IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
                                  
(
                                  
1       ; Serial
                                  
Serial
                                  
8H      ; Refresh
                                  
Refresh
                                  
2H      ; Retry
                                  
Retry
                                  
4W      ; Expire
                                  
Expire
                                  
1D)     ; Minimum TTL
TTL
                          NS      ns.linux.bogus.
  
bogus.
  
1                       PTR     localhost.
  ______________________________________________________________________



  
localhost.
  ______________________________________________________________________



  
The sections called key and controls together specify that your named
  
named
  
can be remotely controlled by a program called rndc if it connects
  
connects
  
from the local host, and identifis itself with the encoded secret key.
key.
  This key is like a password.  For rndc to work you need /etc/rndc.conf
  
conf
  
to match this:


  ______________________________________________________________________
  
this:


  ______________________________________________________________________
  
key rndc_key {
      
{
      
algorithm "hmac-md5";
      
&quot;hmac-md5&quot;;
      
secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
  };

  
&quot;c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K&quot;;
  };

  
options {
      
{
      
default-server localhost;
      
localhost;
      
default-key    rndc_key;
  };
  ______________________________________________________________________



rndc_key;
  };
  ______________________________________________________________________



  As you see the secret is identical.  If you want to use rndc from
  
from
  
other machines their times need to be within 5 minutes of eachother.
  
eachother.
  
I recommend using the ntp (xntpd and ntpdate) software to do this.


this.


  Next, you need a /etc/resolv.conf looking something like this: (Again:
  
(Again:
  
Remove spaces!)


  ______________________________________________________________________
spaces!)


  ______________________________________________________________________
  search subdomain.your-domain.edu your-domain.edu
edu
  nameserver 127.0.0.1
  ______________________________________________________________________



  
1
  ______________________________________________________________________



  
The `search' line specifies what domains should be searched for any
any
  host names you want to connect to.  The `nameserver' line specifies
  
specifies
  
the address of your nameserver, in this case your own machine since
since
  that is where your named runs (127.0.0.1 is right, no matter if your
your
  machine has another address too).  If you want to list several name
name
  servers put in one `nameserver' line for each. (Note: Named never
never
  reads this file, the resolver that uses named does. Note 2: In some
some
  resolv.conf files you find a line saying "domain".  &quot;domain&quot;.  That's fine, but
  
but
  
don't use both "search" &quot;search&quot; and "domain", &quot;domain&quot;, only one of them will work).


  
work).


  
To illustrate what this file does: If a client tries to look up foo,
foo,
  then foo.subdomain.your-domain.edu is tried first, then foo.your-
your-
  domain.edu, and finally foo.  You may not want to put in too many
  
many
  
domains in the search line, as it takes time to search them all.


all.


  The example assumes you belong in the domain subdomain.your-
your-
  domain.edu; your machine, then, is probably called your-
your-
  machine.subdomain.your-domain.edu.  The search line should not contain
contain
  your TLD (Top Level Domain, `edu' in this case).  If you frequently
  
frequently
  
need to connect to hosts in another domain you can add that domain to
  
to
  
the search line like this: (Remember to remove the leading spaces, if
  any)



  ______________________________________________________________________
if
  any)



  ______________________________________________________________________
  search subdomain.your-domain.edu your-domain.edu other-domain.com
  ______________________________________________________________________



com
  ______________________________________________________________________



  and so on. Obviously you need to put real domain names in instead.
instead.
  Please note the lack of periods at the end of the domain names.  This
  
This
  
is important; please note the lack of periods at the end of the domain
  names.


domain
  names.


  3.1.  Starting named

named

  After all this it's time to start named.  If you're using a dialup
dialup
  connection connect first.  Now run named, either by running the boot
boot
  script: /etc/init.d/named start or named directly: /usr/sbin/named.
  
/usr/sbin/named.
  
If you have tried previous versions of BIND you're probably used to
to
  ndc.  I BIND 9 it has been replaced with rndc, which can controll your
your
  named remotely, but it can't start named anymore. If you view your
  
your
  
syslog message file (usually called /var/log/messages, Debian calls it
  
it
  
/var/log/daemon, another directory to look is the other files
  
files
  
/var/log) while starting named (do tail -f /var/log/messages) you
  
you
  
should see something like:


  
like:


  
(the lines ending in \ continues on the next line)



line)



       Dec 23 02:21:12 lookfar named[11031]: starting BIND 9.1.3
       
3
       
Dec 23 02:21:12 lookfar named[11031]: using 1 CPU
       
CPU
       
Dec 23 02:21:12 lookfar named[11034]: loading configuration from \
\
           '/etc/named.conf'
       
conf'
       
Dec 23 02:21:12 lookfar named[11034]: the default for the \
           
\
           
'auth-nxdomain' option is now 'no'
       
'no'
       
Dec 23 02:21:12 lookfar named[11034]: no IPv6 interfaces found
       
found
       
Dec 23 02:21:12 lookfar named[11034]: listening on IPv4 interface lo, \
\
           127.0.0.1#53
       
1#53
       
Dec 23 02:21:12 lookfar named[11034]: listening on IPv4 interface eth0, \
\
           10.0.0.129#53
       
129#53
       
Dec 23 02:21:12 lookfar named[11034]: command channel listening on \
\
           127.0.0.1#953
       
1#953
       
Dec 23 02:21:13 lookfar named[11034]: running



running



  If there are any messages about errors then there is a mistake.  Named
Named
  will name the file it is reading.  Go back and check the file.  Start
  
Start
  
named over when it is fixed.


fixed.


  Now you can test your setup.  Traditionally a program called nslookup
nslookup
  is used for this.  These days dig is recommended:



recommended:



  $ dig -x 127.0.0.1
  
1
  
;; Got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 26669
  
26669
  
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

  
0

  
;; QUESTION SECTION:
SECTION:
  ;1.0.0.127.in-addr.arpa.                IN      PTR

  
PTR

  
;; ANSWER SECTION:
SECTION:
  1.0.0.127.in-addr.arpa. 259200  IN      PTR     localhost.

  
localhost.

  
;; AUTHORITY SECTION:
SECTION:
  0.0.127.in-addr.arpa.   259200  IN      NS      ns.linux.bogus.

  
bogus.

  
;; Query time: 3 msec
msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  
1)
  
;; WHEN: Sun Dec 23 02:26:17 2001
  
2001
  
;; MSG SIZE  rcvd: 91



91



  If that's what you get it's working.  We hope.  Anything very
very
  different, go back and check everything.  Each time you change a file
  
file
  
you need to run rndc reload.


reload.


  Now you can enter a query.  Try looking up some machine close to you.
you.
  pat.uio.no is close to me, at the University of Oslo:



Oslo:



       $ dig pat.uio.no
       
no
       
<<>> &lt;&lt;&gt;&gt; DiG 9.1.3 <<>> &lt;&lt;&gt;&gt; pat.uio.no
       
no
       
;; global options:  printcmd
       
printcmd
       
;; Got answer:
       
answer:
       
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 15574
       
15574
       
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0

       
0

       
;; QUESTION SECTION:
SECTION:
       ;pat.uio.no.                    IN      A

       
A

       
;; ANSWER SECTION:
SECTION:
       pat.uio.no.             86400   IN      A       129.240.130.16

       
16

       
;; AUTHORITY SECTION:
SECTION:
       uio.no.                 86400   IN      NS      nissen.uio.no.
no.
       uio.no.                 86400   IN      NS      nn.uninett.no.
no.
       uio.no.                 86400   IN      NS      ifi.uio.no.

       
no.

       
;; Query time: 651 msec
msec
       ;; SERVER: 127.0.0.1#53(127.0.0.1)
       
1)
       
;; WHEN: Sun Dec 23 02:28:35 2001
       
2001
       
;; MSG SIZE  rcvd: 108



108



  This time dig asked your named to look for the machine pat.uio.no.  It
  
It
  
then contacted one of the name server machines named in your
your
  root.hints file, and asked its way from there.  It might take tiny
  
tiny
  
while before you get the result as it may need to search all the
the
  domains you named in /etc/resolv.conf.

  
conf.

  
If you ask the same again you get this:



this:



       $ dig pat.uio.no

       
no

       
<<>> &lt;&lt;&gt;&gt; DiG 8.2 <<>> &lt;&lt;&gt;&gt; pat.uio.no
       
no
       
;; res options: init recurs defnam dnsrch
       
dnsrch
       
;; got answer:
       
answer:
       
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 4
       
4
       
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
       
3
       
;; QUERY SECTION:
SECTION:
       ;;      pat.uio.no, type = A, class = IN

       
IN

       
;; ANSWER SECTION:
SECTION:
       pat.uio.no.             23h59m58s IN A  129.240.130.16

       
16

       
;; AUTHORITY SECTION:
SECTION:
       UIO.NO.                 23h59m58s IN NS  nissen.UIO.NO.
NO.
       UIO.NO.                 23h59m58s IN NS  ifi.UIO.NO.
NO.
       UIO.NO.                 23h59m58s IN NS  nn.uninett.NO.

       
NO.

       
;; ADDITIONAL SECTION:
SECTION:
       nissen.UIO.NO.          23h59m58s IN A  129.240.2.3
3
       ifi.UIO.NO.             1d23h59m58s IN A  129.240.64.2
2
       nn.uninett.NO.          1d23h59m58s IN A  158.38.0.181

       
181

       
;; Total query time: 4 msec
msec
       ;; FROM: lookfar to SERVER: default -- 127.0.0.1
       
1
       
;; WHEN: Sat Dec 16 00:23:09 2000
       
2000
       
;; MSG SIZE  sent: 28  rcvd: 162



  
162



  
As you can plainly see this time it was much faster, 4ms versus more
more
  than half a second earlier.  The answer was cached.  With cached
  
cached
  
answers there is the possibility that the answer is out of date, but
  
but
  
the origin servers can control the time cached answers should be
  
be
  
considered valid, so there is a high probability that the answer you
  
you
  
get is valid.


valid.


  3.2.  Resolvers

  
Resolvers

  
All OSes implementing the standard C API has the calls gethostbyname
gethostbyname
  and gethostbyaddr.  These can get information from several different
different
  sources.  Which sources it gets it from is configured in
in
  /etc/nsswitch.conf on Linux (and some other Unixes).  This is a long
  
long
  
file specifying from which file or database to get different kinds of
of
  data types.  It usually contains helpful comments at the top, which
which
  you should consider reading.  After that find the line starting with
  
with
  
`hosts:'; it should read:


  ______________________________________________________________________
  
read:


  ______________________________________________________________________
  
hosts:      files dns
  ______________________________________________________________________



  
dns
  ______________________________________________________________________



  
(You remembered about the leading spaces, right? I won't mention them
them
  again.)

  
)

  
If there is no line starting with `hosts:' then put in the one above.
  
above.
  
It says that programs should first look in the /etc/hosts file, then
then
  check DNS according to resolv.conf.



conf.



  3.3.  Congratulations

Congratulations

  Now you know how to set up a caching named.  Take a beer, milk, or
  
or
  
whatever you prefer to celebrate it.



it.



  4.  Forwarding

  
Forwarding

  
In large, well organized, academic or ISP (Internet Service Provider)
  
Provider)
  
networks you will sometimes find that the network people have set up a
  
a
  
forwarder hierarchy of DNS servers which helps lighten the internal
internal
  network load and the load on the outside servers as well.  It's not
not
  easy to know if you're inside such a network or not.  But by using the
  
the
  
DNS server of your network provider as a ``forwarder'' you can make
  
make
  
the responses to queries faster and less of a load on your network.
  
network.
  
This works by your nameserver forwarding queries to your ISP
ISP
  nameserver.  Each time this happens you will dip into the big cache of
  
of
  
your ISPs nameserver, thus speeding your queries up, your nameserver
nameserver
  does not have to do all the work itself.  If you use a modem this can
can
  be quite a win.  For the sake of this example we assume that your
  
your
  
network provider has two name servers they want you to use, with IP
IP
  numbers 10.0.0.1 and 10.1.0.1.  Then, in your named.conf file, inside
  
inside
  
the opening section called ``options'', insert these lines:


  ______________________________________________________________________
             
lines:


  ______________________________________________________________________
             
forward first;
             
first;
             
forwarders {
{
                  10.0.0.1;
1;
                  10.1.0.1;
              };
  ______________________________________________________________________



  
1;
              };
  ______________________________________________________________________



  
There is also a nice trick for dialup machines using forwarders, it is
  
is
  
described in the ``qanda'' section.


section.


  Restart your nameserver and test it with dig.  Should still work fine.


fine.


  5.  A simple  domain.

  
domain.

  
How to set up your own domain.


domain.


  5.1.  But first some dry theory

  
theory

  
First of all: you read all the stuff before here right? You have to.


  
to.


  
Before we really start this section I'm going to serve you some theory
theory
  on and an example of how DNS works.  And you're going to read it
it
  because it's good for you.  If you don't want to you should at least
least
  skim it very quickly.  Stop skimming when you get to what should go in
in
  your named.conf file.

file.

  DNS is a hierarchical, tree structured system.  The top is written `.'
'
  and pronounced `root', as is usual for tree data-structures.  Under .
  
Under .
  
there are a number of Top Level Domains (TLDs); the best known ones
ones
  are ORG, COM, EDU and NET, but there are many more.  Just like a tree
tree
  it has a root and it branches out.  If you have any computer science
  
science
  
background you will recognize DNS as a search tree, and you will be
be
  able to find nodes, leaf nodes and edges.  The dots are nodes, the
  
the
  
edges are on the names.


  
names.


  
When looking for a machine the query proceeds recursively into the
the
  hierarchy starting at the root.  If you want to find the address of
of
  prep.ai.mit.edu., your nameserver has to start asking somewhere.  It
It
  starts by looking it its cache.  If it knows the answer, having cached
  
cached
  
it before, it will answer right away as we saw in the last section.
  
section.
  
If it does not know it will see how closely it can match the requested
requested
  name and use whatever information it has cached.  In the worst case
case
  there is no match but the `.' (root) of the name, and the root servers
servers
  have to be consulted.  It will remove the leftmost parts one at a
a
  time, checking if it knows anything about ai.mit.edu., then mit.edu.,
,
  then edu., and if not that it does know about . because that was in
in
  the hints file.  It will then ask a .  server about prep.ai.mit.edu.
edu.
  This . server will not know the answer, but it will help your server
  
server
  
on its way by giving a referral, telling it where to look instead.
  
instead.
  
These referrals will eventually lead your server to a nameserver that
that
  knows the answer.  I will illustrate that now.  +norec means that dig
  
dig
  
is asking non-recursive questions so that we get to do the recursion
recursion
  ourselves.  The other options are to reduce the amount of dig produces
  
produces
  
so this won't go on for too many pages:



       
pages:



       
$ ;; Got answer:
       
answer:
       
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 980
       
980
       
;; flags: qr ra; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 0

       
0

       
;; AUTHORITY SECTION:
SECTION:
       .                       518400  IN      NS      J.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      K.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      L.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      M.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      A.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      B.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      C.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      D.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      E.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      F.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      G.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      H.ROOT-SERVERS.NET.
NET.
       .                       518400  IN      NS      I.ROOT-SERVERS.NET.



NET.



  This is a referral. It is giving us an "Authority section" &quot;Authority section&quot; only, no
  "Answer section".
no
  &quot;Answer section&quot;.
 Our own nameserver refers us to a nameserver.  Pick
  
Pick
  
one at random:



random:



  $ dig +norec +noques +nostats +nocmd prep.ai.mit.edu. @D.ROOT-SERVERS.NET.
  
NET.
  
;; Got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 58260
  
58260
  
;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 3, ADDITIONAL: 3

  
3

  
;; AUTHORITY SECTION:
SECTION:
  mit.edu.                172800  IN      NS      BITSY.mit.edu.
edu.
  mit.edu.                172800  IN      NS      STRAWB.mit.edu.
edu.
  mit.edu.                172800  IN      NS      W20NS.mit.edu.

  
edu.

  
;; ADDITIONAL SECTION:
SECTION:
  BITSY.mit.edu.          172800  IN      A       18.72.0.3
3
  STRAWB.mit.edu.         172800  IN      A       18.71.0.151
151
  W20NS.mit.edu.          172800  IN      A       18.70.0.160



160



  It refers us to MIT.EDU servers at once.  Again pick one at random:



random:



       $ dig +norec +noques +nostats +nocmd prep.ai.mit.edu. @BITSY.mit.edu.
       
edu.
       
;; Got answer:
       
answer:
       
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 29227
       
29227
       
;; flags: qr ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4

       
4

       
;; ANSWER SECTION:
SECTION:
       prep.ai.mit.edu.        10562   IN      A       198.186.203.77

       
77

       
;; AUTHORITY SECTION:
SECTION:
       ai.mit.edu.             21600   IN      NS      FEDEX.ai.mit.edu.
edu.
       ai.mit.edu.             21600   IN      NS      LIFE.ai.mit.edu.
edu.
       ai.mit.edu.             21600   IN      NS      ALPHA-BITS.ai.mit.edu.
edu.
       ai.mit.edu.             21600   IN      NS      BEET-CHEX.ai.mit.edu.

       
edu.

       
;; ADDITIONAL SECTION:
SECTION:
       FEDEX.ai.mit.edu.       21600   IN      A       192.148.252.43
43
       LIFE.ai.mit.edu.        21600   IN      A       128.52.32.80
80
       ALPHA-BITS.ai.mit.edu.  21600   IN      A       128.52.32.5
5
       BEET-CHEX.ai.mit.edu.   21600   IN      A       128.52.32.22



  
22



  
This time we got a "ANSWER SECTION", &quot;ANSWER SECTION&quot;, and an answer for our question.
  
question.
  
The "AUTHORITY SECTION" &quot;AUTHORITY SECTION&quot; contains information about which servers to
to
  ask about ai.mit.edu the next time.  So you can ask them directly the
the
  next time you wonder about ai.mit.edu names.  Named also gathered
gathered
  information about mit.edu, so of www.mit.edu is requested it is much
  
much
  
closer to being able to answer the question.


question.


  So starting at . we found the successive name servers for each level
level
  in the domain name by referral.  If you had used your own DNS server
  
server
  
instead of using all those other servers, your named would of-course
  
of-course
  
cache all the information it found while digging this out for you, and
  
and
  
it would not have to ask again for a while.


while.


  In the tree analogue each ``.'' in the name is a branching point.  And
And
  each part between the ``.''s are the names of individual branches in
in
  the tree.  One climbs the tree by taking the name we want
want
  (prep.ai.mit.edu) asking the root (.) or whatever servers father from
from
  the root toward prep.ai.mit.edu we have information about in the
the
  cache.  Once the cache limits are reached the recursive resolver goes
  
goes
  
out asking servers, pursuing referrals (edges) further into the name.


  
name.


  
A much less talked about, but just as important domain is in-
in-
  addr.arpa.  It too is nested like the `normal' domains.  in-addr.arpa
arpa
  allows us to get the host's name when we have its address.  A
  
A
  
important thing to note here is that the IP addresses are written in
in
  reverse order in the in-addr.arpa domain.  If you have the address of
of
  a machine: 198.186.203.77 named proceeds to find the named
named
  77.203.168.198.in-addr.arpa/ just like it did for prep.ai.mit.edu.
edu.
  Example: Finding no cache entry for any match but `.', ask a root
root
  server, m.root-servers.net refers you to some other root servers.
servers.
  b.root-servers.net refers you directly to bitsy.mit.edu/.  You should
  
should
  
be able to take it from there.



there.



  5.2.  Our own domain

domain

  Now to define our own domain.  We're going to make the domain
domain
  linux.bogus and define machines in it.  I use a totally bogus domain
  
domain
  
name to make sure we disturb no-one Out There.


  
There.


  
One more thing before we start: Not all characters are allowed in host
host
  names.  We're restricted to the characters of the English alphabet: a-
a-
  z, and numbers 0-9 and the character '-' (dash).  Keep to those
  
those
  
characters (BIND 9 will not bug you if you break this rule, BIND 8
8
  will). Upper and lower-case characters are the same for DNS, so
so
  pat.uio.no is identical to Pat.UiO.No.


No.


  We've already started this part with this line in named.conf:


  ______________________________________________________________________
  
conf:


  ______________________________________________________________________
  
zone "0.&quot;0.0.127.in-addr.arpa" {
          
arpa&quot; {
          
type master;
          
master;
          
file "pz/127.&quot;pz/127.0.0";
  };
  ______________________________________________________________________



0&quot;;
  };
  ______________________________________________________________________



  Please note the lack of `.' at the end of the domain names in this
this
  file.  This says that now we will define the zone 0.0.127.in-
in-
  addr.arpa, that we're the master server for it and that it is stored
stored
  in a file called pz/127.0.0.  We've already set up this file, it
  reads:


  ______________________________________________________________________
  
it
  reads:


  ______________________________________________________________________
  
$TTL 3D
3D
  @               IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
                                  
(
                                  
1       ; Serial
                                  
Serial
                                  
8H      ; Refresh
                                  
Refresh
                                  
2H      ; Retry
                                  
Retry
                                  
4W      ; Expire
                                  
Expire
                                  
1D)     ; Minimum TTL
TTL
                          NS      ns.linux.bogus.
  
bogus.
  
1                       PTR     localhost.
  ______________________________________________________________________

localhost.
  ______________________________________________________________________

  Please note the `.' at the end of all the full domain names in this
this
  file, in contrast to the named.conf file above. Some people like to
  
to
  
start each zone file with a $ORIGIN directive, but this is
is
  superfluous.  The origin (where in the DNS hierarchy it belongs) of a
a
  zone file is specified in the zone section of the named.conf file; in
in
  this case it's 0.0.127.in-addr.arpa.


arpa.


  This `zone file' contains 3 `resource records' (RRs): A SOA RR.  A NS
NS
  RR and a PTR RR.  SOA is short for Start Of Authority.  The `@' is a
  
a
  
special notation meaning the origin, and since the `domain' column for
for
  this file says 0.0.127.in-addr.arpa the first line really means



means



       0.0.127.in-addr.arpa.   IN      SOA ...



SOA ...



  NS is the Name Server RR.  There is no '@' at the start of this line;
line;
  it is implicit since the previous line started with a '@'.  Saves some
some
  typing that.  So the NS line could also be written



written



       0.0.127.in-addr.arpa.   IN      NS      ns.linux.bogus



bogus



  It tells DNS what machine is the name server of the domain 0.0.127.in-
in-
  addr.arpa, it is ns.linux.bogus.  'ns' is a customary name for name-
  
name-
  
servers, but as with web servers who are customarily named
named
  www.something. The name may be anything.


  
anything.


  
And finally the PTR (Domain Name Pointer) record says that the host at
at
  address 1 in the subnet 0.0.127.in-addr.arpa, i.e., 127.0.0.1 is named
  localhost.


  
named
  localhost.


  
The SOA record is the preamble to all zone files, and there should be
  
be
  
exactly one in each zone file, at the top (but after the $TTL
$TTL
  directive).  It describes the zone, where it comes from (a machine
machine
  called ns.linux.bogus), who is responsible for its contents
contents
  (hostmaster@linux.bogus; you should insert your e-mail address here),
  
here),
  
what version of the zone file this is (serial: 1), and other things
things
  having to do with caching and secondary DNS servers.  For the rest of
  
of
  
the fields (refresh, retry, expire and minimum) use the numbers used
used
  in this HOWTO and you should be safe.  Before the SOA comes a
a
  mandatory line, the $TTL 3D line.  Put it in all your zone files.


  
files.


  
Now restart your named (rndc stop; named) and use dig to examine your
your
  handy work.  -x asks for the inverse query:



query:



  $ dig -x 127.0.0.1
  
1
  
;; Got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 30944
  
30944
  
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

  
0

  
;; QUESTION SECTION:
SECTION:
  ;1.0.0.127.in-addr.arpa.                IN      PTR

  
PTR

  
;; ANSWER SECTION:
SECTION:
  1.0.0.127.in-addr.arpa. 259200  IN      PTR     localhost.

  
localhost.

  
;; AUTHORITY SECTION:
SECTION:
  0.0.127.in-addr.arpa.   259200  IN      NS      ns.linux.bogus.

  
bogus.

  
;; Query time: 3 msec
msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  
1)
  
;; WHEN: Sun Dec 23 03:02:39 2001
  
2001
  
;; MSG SIZE  rcvd: 91



91



  So it manages to get localhost from 127.0.0.1, good.  Now for our main
main
  task, the linux.bogus domain, insert a new 'zone' section in
in
  named.conf:


  ______________________________________________________________________
  
conf:


  ______________________________________________________________________
  
zone "linux.bogus" {
          
&quot;linux.bogus&quot; {
          
type master;
          
master;
          
notify no;
          
no;
          
file "pz/linux.bogus";
  };
  ______________________________________________________________________



&quot;pz/linux.bogus&quot;;
  };
  ______________________________________________________________________



  Note again the lack of ending `.' on the domain name in the named.conf
  file.


conf
  file.


  In the linux.bogus zone file we'll put some totally bogus data:



  ______________________________________________________________________
  ;
data:



  ______________________________________________________________________
  ;
  ; Zone file for linux.bogus
  ;
  
bogus
  ;
  
; The full zone file
  ;
  
file
  ;
  
$TTL 3D
3D
  @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
                          
(
                          
199802151       ; serial, todays date + todays serial #
                          
#
                          
8H              ; refresh, seconds
                          
seconds
                          
2H              ; retry, seconds
                          
seconds
                          
4W              ; expire, seconds
                          
seconds
                          
1D )            ; minimum, seconds
  ;
                  
seconds
  ;
                  
NS      ns              ; Inet Address of name server
server
                  MX      10 mail.linux.bogus     ; Primary Mail Exchanger
Exchanger
                  MX      20 mail.friend.bogus.   ; Secondary Mail Exchanger
  ;
Exchanger
  ;
  localhost       A       127.0.0.1
1
  ns              A       192.168.196.2
2
  mail            A       192.168.196.4
  ______________________________________________________________________



4
  ______________________________________________________________________



  Two things must be noted about the SOA record.  ns.linux.bogus must be
be
  a actual machine with a A record.  It is not legal to have a CNAME
CNAME
  record for the machine mentioned in the SOA record.  Its name need not
not
  be `ns', it could be any legal host name.  Next,
Next,
  hostmaster.linux.bogus should be read as hostmaster@linux.bogus.  This
  
This
  
should be a mail alias, or a mailbox, where the person(s) maintaining
maintaining
  DNS should read mail frequently.  Any mail regarding the domain will
will
  be sent to the address listed here.  The name need not be
  
be
  
`hostmaster', it can be your normal e-mail address, but the e-mail
  
e-mail
  
address `hostmaster' is often expected to work as well.


  
well.


  
There is one new RR type in this file, the MX, or Mail eXchanger RR.
  
RR.
  
It tells mail systems where to send mail that is addressed to
to
  someone@linux.bogus, namely to mail.linux.bogus or mail.friend.bogus.
bogus.
  The number before each machine name is that MX RR's priority.  The RR
  
RR
  
with the lowest number (10) is the one mail should be sent to if
if
  possible.  If that fails the mail can be sent to one with a higher
higher
  number, a secondary mail handler, i.e., mail.friend.bogus which has
  
has
  
priority 20 here.


here.


  Reload named by running rndc reload.  Examine the results with dig:



dig:



  $ dig any linux.bogus
  
bogus
  
<<>> &lt;&lt;&gt;&gt; DiG 9.1.3 <<>> &lt;&lt;&gt;&gt; any linux.bogus
  
bogus
  
;; global options:  printcmd
  
printcmd
  
;; Got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 55239
  
55239
  
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 1, ADDITIONAL: 1

  
1

  
;; QUESTION SECTION:
SECTION:
  ;linux.bogus.               IN      ANY

  
ANY

  
;; ANSWER SECTION:
SECTION:
  linux.bogus.        259200  IN      SOA     ns.linux.bogus. \
\
        hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
86400
  linux.bogus.        259200  IN      NS      ns.linux.bogus.
bogus.
  linux.bogus.        259200  IN      MX      20 mail.friend.bogus.
bogus.
  linux.bogus.        259200  IN      MX      10 mail.linux.bogus.linux.bogus.

  
bogus.

  
;; AUTHORITY SECTION:
SECTION:
  linux.bogus.        259200  IN      NS      ns.linux.bogus.

  
bogus.

  
;; ADDITIONAL SECTION:
SECTION:
  ns.linux.bogus.     259200  IN      A       192.168.196.2

  
2

  
;; Query time: 4 msec
msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  
1)
  
;; WHEN: Sun Dec 23 03:06:45 2001
  
2001
  
;; MSG SIZE  rcvd: 184



184



  Upon careful examination you will discover a bug.  The line



line



       linux.bogus.        259200  IN MX        10 mail.linux.bogus.linux.bogus.



bogus.



  is all wrong.  It should be



be



       linux.bogus.        259200  IN MX        10 mail.linux.bogus.



  
bogus.



  
I deliberately made a mistake so you could learn from it :-) Looking
  
Looking
  
in the zone file we find this line:



line:



                       MX      10 mail.linux.bogus     ; Primary Mail Exchanger



Exchanger



  It is missing a period.  Or has a 'linux.bogus' too many.  If a
  
a
  
machine name does not end in a period in a zone file the origin is
is
  added to its end causing the double linux.bogus.linux.bogus.  So
  either


  ______________________________________________________________________
So
  either


  ______________________________________________________________________
                  MX      10 mail.linux.bogus.    ; Primary Mail Exchanger
  ______________________________________________________________________



  or


  ______________________________________________________________________
                  
Exchanger
  ______________________________________________________________________



  or


  ______________________________________________________________________
                  
MX      10 mail                 ; Primary Mail Exchanger
  ______________________________________________________________________



Exchanger
  ______________________________________________________________________



  is correct.  I prefer the latter form, it's less to type.  There are
are
  some BIND experts that disagree, and some that agree with this.  In a
a
  zone file the domain should either be written out and ended with a `.'
  
'
  
or it should not be included at all, in which case it defaults to the
  origin.


the
  origin.


  I must stress that in the named.conf file there should not be `.'s
's
  after the domain names.  You have no idea how many times a `.' too
  
too
  
many or few have fouled up things and confused the h*ll out of people.


  
people.


  
So having made my point here is the new zone file, with some extra
  
extra
  
information in it as well:



  ______________________________________________________________________
  ;
well:



  ______________________________________________________________________
  ;
  ; Zone file for linux.bogus
  ;
  
bogus
  ;
  
; The full zone file
  ;
  
file
  ;
  
$TTL 3D
3D
  @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
                          
(
                          
199802151       ; serial, todays date + todays serial #
                          
#
                          
8H              ; refresh, seconds
                          
seconds
                          
2H              ; retry, seconds
                          
seconds
                          
4W              ; expire, seconds
                          
seconds
                          
1D )            ; minimum, seconds
  ;
                  
seconds
  ;
                  
TXT     "Linux.&quot;Linux.Bogus, your DNS consultants"
                  
consultants&quot;
                  
NS      ns              ; Inet Address of name server
server
                  NS      ns.friend.bogus.
                  
bogus.
                  
MX      10 mail         ; Primary Mail Exchanger
Exchanger
                  MX      20 mail.friend.bogus. ; Secondary Mail Exchanger

Exchanger

  localhost       A       127.0.0.1

1

  gw              A       192.168.196.1
                  
1
                  
TXT     "The router"

&quot;The router&quot;

  ns              A       192.168.196.2
                  
2
                  
MX      10 mail
mail
                  MX      20 mail.friend.bogus.
  
bogus.
  
www             CNAME   ns

ns

  donald          A       192.168.196.3
                  
3
                  
MX      10 mail
mail
                  MX      20 mail.friend.bogus.
                  
bogus.
                  
TXT     "DEK"

&quot;DEK&quot;

  mail            A       192.168.196.4
                  
4
                  
MX      10 mail
mail
                  MX      20 mail.friend.bogus.

bogus.

  ftp             A       192.168.196.5
                  
5
                  
MX      10 mail
mail
                  MX      20 mail.friend.bogus.
  ______________________________________________________________________



  
bogus.
  ______________________________________________________________________



  
CNAME (Canonical NAME) is a way to give each machine several names.
names.
  So www is an alias for ns.  CNAME record usage is a bit controversial.
  
controversial.
  
But it's safe to follow the rule that a MX, CNAME or SOA record should
  
should
  
never refer to a CNAME record, they should only refer to something
  
something
  
with an A record, so it is inadvisable to have


  ______________________________________________________________________
  
have


  ______________________________________________________________________
  
foobar          CNAME   www                     ; NO!
  ______________________________________________________________________



  
NO!
  ______________________________________________________________________



  
but correct to have



  ______________________________________________________________________
  
have



  ______________________________________________________________________
  
foobar          CNAME   ns                      ; Yes!
  ______________________________________________________________________



  
Yes!
  ______________________________________________________________________



  
Load the new database by running rndc reload, which causes named to
  
to
  
read its files again.



again.



       $ dig linux.bogus axfr

       
axfr

       
<<>> &lt;&lt;&gt;&gt; DiG 9.1.3 <<>> &lt;&lt;&gt;&gt; linux.bogus axfr
       
axfr
       
;; global options:  printcmd
printcmd
       linux.bogus.            259200  IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
86400
       linux.bogus.            259200  IN      NS      ns.linux.bogus.
bogus.
       linux.bogus.            259200  IN      MX      10 mail.linux.bogus.
bogus.
       linux.bogus.            259200  IN      MX      20 mail.friend.bogus.
bogus.
       donald.linux.bogus.     259200  IN      A       192.168.196.3
3
       donald.linux.bogus.     259200  IN      MX      10 mail.linux.bogus.
bogus.
       donald.linux.bogus.     259200  IN      MX      20 mail.friend.bogus.
bogus.
       donald.linux.bogus.     259200  IN      TXT     "DEK"
&quot;DEK&quot;
       ftp.linux.bogus.        259200  IN      A       192.168.196.5
5
       ftp.linux.bogus.        259200  IN      MX      10 mail.linux.bogus.
bogus.
       ftp.linux.bogus.        259200  IN      MX      20 mail.friend.bogus.
bogus.
       gw.linux.bogus.         259200  IN      A       192.168.196.1
1
       gw.linux.bogus.         259200  IN      TXT     "The router"
&quot;The router&quot;
       localhost.linux.bogus.  259200  IN      A       127.0.0.1
1
       mail.linux.bogus.       259200  IN      A       192.168.196.4
4
       mail.linux.bogus.       259200  IN      MX      10 mail.linux.bogus.
bogus.
       mail.linux.bogus.       259200  IN      MX      20 mail.friend.bogus.
bogus.
       ns.linux.bogus.         259200  IN      MX      10 mail.linux.bogus.
bogus.
       ns.linux.bogus.         259200  IN      MX      20 mail.friend.bogus.
bogus.
       ns.linux.bogus.         259200  IN      A       192.168.196.2
2
       www.linux.bogus.        259200  IN      CNAME   ns.linux.bogus.
bogus.
       linux.bogus.            259200  IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
       
86400
       
;; Query time: 41 msec
msec
       ;; SERVER: 127.0.0.1#53(127.0.0.1)
       
1)
       
;; WHEN: Sun Dec 23 03:12:31 2001
       
2001
       
;; XFR size: 23 records



records



  That's good.  As you see it looks a bit like the zone file itself.
  
itself.
  
Let's check what it says for www alone:



alone:



  $ dig www.linux.bogus

  
bogus

  
<<>> &lt;&lt;&gt;&gt; DiG 9.1.3 <<>> &lt;&lt;&gt;&gt; www.linux.bogus
  
bogus
  
;; global options:  printcmd
  
printcmd
  
;; Got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 16633
  
16633
  
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0

  
0

  
;; QUESTION SECTION:
SECTION:
  ;www.linux.bogus.               IN      A

  
A

  
;; ANSWER SECTION:
SECTION:
  www.linux.bogus.        259200  IN      CNAME   ns.linux.bogus.
bogus.
  ns.linux.bogus.         259200  IN      A       192.168.196.2

  
2

  
;; AUTHORITY SECTION:
SECTION:
  linux.bogus.            259200  IN      NS      ns.linux.bogus.

  
bogus.

  
;; Query time: 5 msec
msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  
1)
  
;; WHEN: Sun Dec 23 03:14:14 2001
  
2001
  
;; MSG SIZE  rcvd: 80



80



  In other words, the real name of www.linux.bogus is ns.linux.bogus,
  
bogus,
  
and it gives you some of the information it has about ns as well,
  
well,
  
enough to connect to it if you were a program.


  
program.


  
Now we're halfway.


halfway.


  5.3.  The reverse zone

zone

  Now programs can convert the names in linux.bogus to addresses which
which
  they can connect to. But also required is a reverse zone, one making
making
  DNS able to convert from an address to a name. This name is used by a
  
a
  
lot of servers of different kinds (FTP, IRC, WWW and others) to decide
  
decide
  
if they want to talk to you or not, and if so, maybe even how much
much
  priority you should be given. For full access to all services on the
  
the
  
Internet a reverse zone is required.


required.


  Put this in named.conf:


  ______________________________________________________________________
  
conf:


  ______________________________________________________________________
  
zone "196.&quot;196.168.192.in-addr.arpa" {
          
arpa&quot; {
          
type master;
          
master;
          
notify no;
          
no;
          
file "pz/192.&quot;pz/192.168.196";
  };
  ______________________________________________________________________



196&quot;;
  };
  ______________________________________________________________________



  This is exactly as with the 0.0.127.in-addr.arpa, and the contents are
  similar:



  ______________________________________________________________________
  
are
  similar:



  ______________________________________________________________________
  
$TTL 3D
3D
  @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
                          
(
                          
199802151 ; Serial, todays date + todays serial
                          
serial
                          
8H      ; Refresh
                          
Refresh
                          
2H      ; Retry
                          
Retry
                          
4W      ; Expire
                          
Expire
                          
1D)     ; Minimum TTL
TTL
                  NS      ns.linux.bogus.

bogus.

  1               PTR     gw.linux.bogus.
bogus.
  2               PTR     ns.linux.bogus.
bogus.
  3               PTR     donald.linux.bogus.
bogus.
  4               PTR     mail.linux.bogus.
bogus.
  5               PTR     ftp.linux.bogus.
  ______________________________________________________________________



  
bogus.
  ______________________________________________________________________



  
Now you reload your named (rndc reload) and examine your work with dig
  again:


  ______________________________________________________________________
dig
  again:


  ______________________________________________________________________
  $ dig -x 192.168.196.4
  
4
  
;; Got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 58451
  
58451
  
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

  
1

  
;; QUESTION SECTION:
SECTION:
  ;4.196.168.192.in-addr.arpa.    IN      PTR

  
PTR

  
;; ANSWER SECTION:
SECTION:
  4.196.168.192.in-addr.arpa. 259200 IN   PTR     mail.linux.bogus.

  
bogus.

  
;; AUTHORITY SECTION:
SECTION:
  196.168.192.in-addr.arpa. 259200 IN     NS      ns.linux.bogus.

  
bogus.

  
;; ADDITIONAL SECTION:
SECTION:
  ns.linux.bogus.         259200  IN      A       192.168.196.2

  
2

  
;; Query time: 4 msec
msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  
1)
  
;; WHEN: Sun Dec 23 03:16:05 2001
  
2001
  
;; MSG SIZE  rcvd: 107
  ______________________________________________________________________



  
107
  ______________________________________________________________________



  
so, it looks OK, dump the whole thing to examine that too:



  ______________________________________________________________________
too:



  ______________________________________________________________________
  $ dig 196.168.192.in-addr.arpa. AXFR

  
AXFR

  
<<>> &lt;&lt;&gt;&gt; DiG 9.1.3 <<>> &lt;&lt;&gt;&gt; 196.168.192.in-addr.arpa. AXFR
  
AXFR
  
;; global options:  printcmd
printcmd
  196.168.192.in-addr.arpa. 259200 IN     SOA     ns.linux.bogus. \
\
          hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
86400
  196.168.192.in-addr.arpa. 259200 IN     NS      ns.linux.bogus.
bogus.
  1.196.168.192.in-addr.arpa. 259200 IN   PTR     gw.linux.bogus.
bogus.
  2.196.168.192.in-addr.arpa. 259200 IN   PTR     ns.linux.bogus.
bogus.
  3.196.168.192.in-addr.arpa. 259200 IN   PTR     donald.linux.bogus.
bogus.
  4.196.168.192.in-addr.arpa. 259200 IN   PTR     mail.linux.bogus.
bogus.
  5.196.168.192.in-addr.arpa. 259200 IN   PTR     ftp.linux.bogus.
bogus.
  196.168.192.in-addr.arpa. 259200 IN     SOA     ns.linux.bogus. \
\
          hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
  
86400
  
;; Query time: 6 msec
msec
  ;; SERVER: 127.0.0.1#53(127.0.0.1)
  
1)
  
;; WHEN: Sun Dec 23 03:16:58 2001
  
2001
  
;; XFR size: 9 records
  ______________________________________________________________________



  
records
  ______________________________________________________________________



  
Looks good!  If your output didn't look like that look for error-
  
error-
  
messages in your syslog, I explained how to do that in the first
  
first
  
section under the heading ``Starting named''


named''


  5.4.  Words of caution

caution

  There are some things I should add here.  The IP numbers used in the
  
the
  
examples above are taken from one of the blocks of 'private nets',
nets',
  i.e., they are not allowed to be used publicly on the Internet.  So
So
  they are safe to use in an example in a HOWTO.  The second thing is
is
  the notify no; line.  It tells named not to notify its secondary
  
secondary
  
(slave) servers when it has gotten a update to one of its zone files.
  
files.
  
In BIND 8 and later the named can notify the other servers listed in
in
  NS records in the zone file when a zone is updated.  This is handy for
for
  ordinary use.  But for private experiments with zones this feature
  
feature
  
should be off --- we don't want the experiment to pollute the Internet
  
Internet
  
do we?


  
we?


  
And, of course, this domain is highly bogus, and so are all the
the
  addresses in it.  For a real example of a real-life domain see the
  
the
  
next main-section.


main-section.


  5.5.  Why reverse lookups don't work.

  
work.

  
There are a couple of ``gotchas'' that normally are avoided with name
name
  lookups that are often seen when setting up reverse zones.  Before you
  
you
  
go on you need reverse lookups of your machines working on your own
own
  nameserver.  If it isn't go back and fix it before continuing.


  
continuing.


  
I will discuss two failures of reverse lookups as seen from outside
  
outside
  
your network:


network:


  5.5.1.  The reverse zone isn't delegated.

  
delegated.

  
When you ask a service provider for a network-address range and a
  
a
  
domain name the domain name is normally delegated as a matter of
of
  course.  A delegation is the glue NS record that helps you get from
  
from
  
one nameserver to another as explained in the dry theory section
section
  above.  You read that, right?  If your reverse zone doesn't work go
go
  back and read it.  Now.


Now.


  The reverse zone also needs to be delegated.  If you got the
the
  192.168.196 net with the linux.bogus domain from your provider they
  
they
  
need to put NS records in for your reverse zone as well as for your
your
  forward zone.  If you follow the chain from in-addr.arpa and up to
  
to
  
your net you will probably find a break in the chain, most probably at
at
  your service provider.  Having found the break in the chain contact
  
contact
  
your service-provider and ask them to correct the error.


error.


  5.5.2.  You've got a classless subnet

  
subnet

  
This is a somewhat advanced topic, but classless subnets are very
  
very
  
common these days and you probably have one if you're a small company.


company.


  A classless subnet is what keeps the Internet going these days.  Some
Some
  years ago there was much ado about the shortage of IP numbers.  The
  
The
  
smart people in IETF (the Internet Engineering Task Force, they keep
  
keep
  
the Internet working) stuck their heads together and solved the
the
  problem.  At a price.  The price is in part that you'll get less than
than
  a ``C'' subnet and some things may break.  Please see Ask Mr. DNS
  <http://www.
DNS
  &lt;http://www.
acmebw.com/askmrdns/00007.htm> htm&gt; for an good explanation of
  
of
  
this and how to handle it.


  
it.


  
Did you read it?  I'm not going to explain it so please read it.


  
it.


  
The first part of the problem is that your ISP must understand the
the
  technique described by Mr. DNS.  Not all small ISPs have a working
working
  understanding of this.  If so you might have to explain to them and be
be
  persistent.  But be sure you understand it first ;-).  They will then
  
then
  
set up a nice reverse zone at their server which you can examine for
  
for
  
correctness with dig.


  
dig.


  
The second and last part of the problem is that you must understand
understand
  the technique.  If you're unsure go back and read about it again.
  
again.
  
Then you can set up your own classless reverse zone as described by
by
  Mr. DNS.


DNS.


  There is another trap lurking here.  (Very) Old resolvers will not be
  
be
  
able to follow the CNAME trick in the resolving chain and will fail to
to
  reverse-resolve your machine.  This can result in the service
  
service
  
assigning it an incorrect access class, deny access or something along
along
  those lines.  If you stumble into such a service the only solution
  
solution
  
(that I know of) is for your ISP to insert your PTR record directly
  
directly
  
into their trick classless zone file instead of the trick CNAME
  record.


  
CNAME
  record.


  
Some ISPs will offer other ways to handle this, like Web based forms
  
forms
  
for you to input your reverse-mappings in or other automagical
  systems.


automagical
  systems.


  5.6.  Slave servers

  
servers

  
Once you have set up your zones correctly on the master servers you
you
  need to set up at least one slave server.  Slave servers are needed
needed
  for robustness.  If your master goes down the people out there on the
  
the
  
net will still be able to get information about your domain from the
the
  slave.  A slave should be as long away from you as possible.  Your
  
Your
  
master and slave should share as few as possible of these: Power
Power
  supply, LAN, ISP, city and country.  If all of these things are
  
are
  
different for your master and slave you've found a really good slave.


  
slave.


  
A slave is simply a nameserver that copies zone files from a master.
  
master.
  
You set it up like this:


  ______________________________________________________________________
  
this:


  ______________________________________________________________________
  
zone "linux.bogus" {
          
&quot;linux.bogus&quot; {
          
type slave;
          
slave;
          
file "sz/linux.bogus";
&quot;sz/linux.bogus&quot;;
          masters { 192.168.196.2; };
  };
  ______________________________________________________________________



};
  };
  ______________________________________________________________________



  A mechanism called zone-transfer is used to copy the data.  The zone
  
zone
  
transfer is controlled by your SOA record:


  ______________________________________________________________________
record:


  ______________________________________________________________________
  @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
                          
(
                          
199802151       ; serial, todays date + todays serial #
                          
#
                          
8H              ; refresh, seconds
                          
seconds
                          
2H              ; retry, seconds
                          
seconds
                          
4W              ; expire, seconds
                          
seconds
                          
1D )            ; minimum, seconds
  ______________________________________________________________________



  
seconds
  ______________________________________________________________________



  
A zone is only transferred if the serial number on the master is
is
  larger than on the slave.  Every refresh interval the slave will check
check
  if the master has been updated.  If the check fails (because the
  
the
  
master is unavailable) it will retry the check every retry interval.
  
interval.
  
If it continues to fail as long as the expire interval the slave will
  
will
  
remove the zone from it's filesystem and no longer be a server for it.



it.



  6.  Basic security options.

  
options.

  
By Jamie Norrish


  
Norrish


  
Setting configuration options to reduce the possibility of problems.


  
problems.


  
There are a few simple steps that you can take which will both make
make
  your server more secure and potentially reduce its load. The material
  
material
  
presented here is nothing more than a starting point; if you are
  
are
  
concerned about security (and you should be), please consult other
  
other
  
resources on the net (see ``the last chapter'').


chapter'').


  The following configuration directives occur in named.conf. If a
  
a
  
directive occurs in the options section of the file, it applies to all
all
  zones listed in that file. If it occurs within a zone entry, it
it
  applies only to that zone. A zone entry overrides an options entry.


entry.


  6.1.  Restricting zone transfers

  
transfers

  
In order for your slave server(s) to be able to answer queries about
  
about
  
your domain, they must be able to transfer the zone information from
from
  your primary server.  Very few others have a need to do so.  Therefore
  
Therefore
  
restrict zone transfers using the allow-transfer option, assuming
assuming
  192.168.1.4 is the IP address of ns.friend.bogus and adding yourself
  
yourself
  
for debugging purposes:


  ______________________________________________________________________
  
purposes:


  ______________________________________________________________________
  
zone "linux.bogus" {
&quot;linux.bogus&quot; {
        allow-transfer { 192.168.1.4; localhost; };
  };
  ______________________________________________________________________



  
};
  };
  ______________________________________________________________________



  
By restricting zone transfers you ensure that the only information
  
information
  
available to people is that which they ask for directly - no one can
  
can
  
just ask for all the details about your set-up.


set-up.


  6.2.  Protecting against spoofing

  
spoofing

  
Firstly, disable any queries for domains you don't own, except from
from
  your internal/local machines. This not only helps prevent malicious
  
malicious
  
use of your DNS server, but also reduces unnecessary use of your
  server.


  ______________________________________________________________________
  
your
  server.


  ______________________________________________________________________
  
options {
{
        allow-query { 192.168.196.0/24; localhost; };
  };

  
};
  };

  
zone "linux.bogus" {
        
&quot;linux.bogus&quot; {
        
allow-query { any; };
  };

  
};
  };

  
zone "196.&quot;196.168.192.in-addr.arpa" {
        
arpa&quot; {
        
allow-query { any; };
  };
  ______________________________________________________________________



  
};
  };
  ______________________________________________________________________



  
Further, disable recursive queries except from internal/local sources.
  
sources.
  
This reduces the risk of cache poisoning attacks (where false data is
  
is
  
fed to your server).


  ______________________________________________________________________
  
server).


  ______________________________________________________________________
  
options {
{
          allow-recursion { 192.168.196.0/24; localhost; };
  };
  ______________________________________________________________________



};
  };
  ______________________________________________________________________



  6.3.  Running named as non-root

  
non-root

  
It is a good idea to run named as a user other than root, so that if
  
if
  
it is compromised the privileges gained by the cracker are as limited
limited
  as possible. You first have to create a user for named to run under,
under,
  and then modify whatever init script you use that starts named. Pass
  
Pass
  
the new user name and group to named using the -u and -g flags.


flags.


  For example, in Debian GNU/Linux 2.2 you might modify your
your
  /etc/init.d/bind script to have the following line (where user named
  
named
  
have been created):


  ______________________________________________________________________
  
created):


  ______________________________________________________________________
  
start-stop-daemon --start --quiet --exec /usr/sbin/named -- -u named
  ______________________________________________________________________



  
named
  ______________________________________________________________________



  
The same can be done with Red Hat and the other distributions.


  
distributions.


  
Dave Lugo has described a secure dual chroot setup
  <http://www.
setup
  &lt;http://www.
etherboy.com/dns/chrootdns.html> html&gt; which you may find
  
find
  
interesting to read, it makes the host your run your named on even
  
even
  
more secure.


secure.


  7.  A real domain example

  
example

  
Where we list some real zone files


  
files


  
Users have suggested that I include a real example of a working domain
  
domain
  
as well as the tutorial example.


  
example.


  
I use this example with permission from David Bullock of LAND-5.
  
LAND-5.
  
These files were current 24th of September 1996, and were then edited
edited
  to fit BIND 8 restrictions and use extensions by me.  So, what you see
  
see
  
here differs a bit from what you find if you query LAND-5's name
  
name
  
servers now.


now.


  7.1.  /etc/named.conf (or /var/named/named.conf)

  
conf)

  
Here we find master zone sections for the two reverse zones needed:
needed:
  the 127.0.0 net, as well as LAND-5's 206.6.177 subnet, and a primary
primary
  line for land-5's forward zone land-5.com. Also note that instead of
  
of
  
stuffing the files in a directory called pz, as I do in this HOWTO, he
  
he
  
puts them in a directory called zone.



  ______________________________________________________________________
  
zone.



  ______________________________________________________________________
  
// Boot file for LAND-5 name server

  
server

  
options {
          
{
          
directory "/var/named";
  };

  
&quot;/var/named&quot;;
  };

  
controls {
{
          inet 127.0.0.1 allow { localhost; } keys { rndc_key; };
  };

  
};
  };

  
key "rndc_key" {
          
&quot;rndc_key&quot; {
          
algorithm hmac-md5;
          
hmac-md5;
          
secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
  };

  
&quot;c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K&quot;;
  };

  
zone "." {
          
&quot;.&quot; {
          
type hint;
          
hint;
          
file "root.hints";
  };

  
&quot;root.hints&quot;;
  };

  
zone "0.&quot;0.0.127.in-addr.arpa" {
          
arpa&quot; {
          
type master;
          
master;
          
file "zone/127.&quot;zone/127.0.0";
  };

  
0&quot;;
  };

  
zone "land-5.com" {
          
&quot;land-5.com&quot; {
          
type master;
          
master;
          
file "zone/land-5.com";
  };

  
&quot;zone/land-5.com&quot;;
  };

  
zone "177.&quot;177.6.206.in-addr.arpa" {
          
arpa&quot; {
          
type master;
          
master;
          
file "zone/206.&quot;zone/206.6.177";
  };
  ______________________________________________________________________



177&quot;;
  };
  ______________________________________________________________________



  If you put this in your named.conf file to play with PLEASE put
  
put
  
``notify no;'' in the zone sections for the two land-5 zones so as to
  
to
  
avoid accidents.


accidents.


  7.2.  /var/named/root.hints

  
hints

  
Keep in mind that this file is dynamic, and the one listed here is
is
  old.  You're better off using a new one as explained earlier.



  ______________________________________________________________________
  
earlier.



  ______________________________________________________________________
  
<<>> &lt;&lt;&gt;&gt; DiG 8.1 <<>> &lt;&lt;&gt;&gt; @A.ROOT-SERVERS.NET.
  
NET.
  
; (1 server found)
  
found)
  
;; res options: init recurs defnam dnsrch
  
dnsrch
  
;; got answer:
  
answer:
  
;; ->>HEADER<<- -&gt;&gt;HEADER&lt;&lt;- opcode: QUERY, status: NOERROR, id: 10
  
10
  
;; flags: qr aa rd; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
  
13
  
;; QUERY SECTION:
SECTION:
  ;;      ., type = NS, class = IN

  
IN

  
;; ANSWER SECTION:
SECTION:
  .                     6D IN NS        G.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        J.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        K.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        L.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        M.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        A.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        H.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        B.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        C.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        D.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        E.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        I.ROOT-SERVERS.NET.
NET.
  .                     6D IN NS        F.ROOT-SERVERS.NET.

  
NET.

  
;; ADDITIONAL SECTION:
SECTION:
  G.ROOT-SERVERS.NET.     5w6d16h IN A    192.112.36.4
4
  J.ROOT-SERVERS.NET.     5w6d16h IN A    198.41.0.10
10
  K.ROOT-SERVERS.NET.     5w6d16h IN A    193.0.14.129
129
  L.ROOT-SERVERS.NET.     5w6d16h IN A    198.32.64.12
12
  M.ROOT-SERVERS.NET.     5w6d16h IN A    202.12.27.33
33
  A.ROOT-SERVERS.NET.     5w6d16h IN A    198.41.0.4
4
  H.ROOT-SERVERS.NET.     5w6d16h IN A    128.63.2.53
53
  B.ROOT-SERVERS.NET.     5w6d16h IN A    128.9.0.107
107
  C.ROOT-SERVERS.NET.     5w6d16h IN A    192.33.4.12
12
  D.ROOT-SERVERS.NET.     5w6d16h IN A    128.8.10.90
90
  E.ROOT-SERVERS.NET.     5w6d16h IN A    192.203.230.10
10
  I.ROOT-SERVERS.NET.     5w6d16h IN A    192.36.148.17
17
  F.ROOT-SERVERS.NET.     5w6d16h IN A    192.5.5.241

  
241

  
;; Total query time: 215 msec
msec
  ;; FROM: roke.uio.no to SERVER: A.ROOT-SERVERS.NET.  198.41.0.4
  
4
  
;; WHEN: Sun Feb 15 01:22:51 1998
  
1998
  
;; MSG SIZE  sent: 17  rcvd: 436
  ______________________________________________________________________



436
  ______________________________________________________________________



  7.3.  /var/named/zone/127.0.0

  
0

  
Just the basics, the obligatory SOA record, and a record that maps
maps
  127.0.0.1 to localhost.  Both are required.  No more should be in this
this
  file.  It will probably never need to be updated, unless your
  
your
  
nameserver or hostmaster address changes.



  ______________________________________________________________________
  
changes.



  ______________________________________________________________________
  
$TTL 3D
3D
  @               IN      SOA     land-5.com. root.land-5.com. (
                                  
(
                                  
199609203       ; Serial
                                  
Serial
                                  
28800   ; Refresh
                                  
Refresh
                                  
7200    ; Retry
                                  
Retry
                                  
604800  ; Expire
                                  
Expire
                                  
86400)  ; Minimum TTL
TTL
                          NS      land-5.com.

  
com.

  
1                       PTR     localhost.
  ______________________________________________________________________



  
localhost.
  ______________________________________________________________________



  
If you look at a random BIND installation you will probably find that
that
  the $TTL line is missing as it is here.  It was not used before, and
and
  only version 8.2 of BIND has started to warn about its absence.  BIND
  
BIND
  
9 requires the $TTL.


$TTL.


  7.4.  /var/named/zone/land-5.com

com

  Here we see the mandatory SOA record, the needed NS records.  We can
can
  see that he has a secondary name server at ns2.psi.net.  This is as it
it
  should be, always have a off site secondary server as backup.  We can
  
can
  
also see that he has a master host called land-5 which takes care of
  
of
  
many of the different Internet services, and that he's done it with
  
with
  
CNAMEs (a alternative is using A records).


  
records).


  
As you see from the SOA record, the zone file originates at
at
  land-5.com, the contact person is root@land-5.com. hostmaster is
is
  another oft used address for the contact person.  The serial number is
  
is
  
in the customary yyyymmdd format with todays serial number appended;
  
appended;
  
this is probably the sixth version of zone file on the 20th of
of
  September 1996.  Remember that the serial number must increase
  
increase
  
monotonically, here there is only one digit for todays serial#, so
  
so
  
after 9 edits he has to wait until tomorrow before he can edit the
the
  file again.  Consider using two digits.



  ______________________________________________________________________
  
digits.



  ______________________________________________________________________
  
$TTL 3D
3D
  @       IN      SOA     land-5.com. root.land-5.com. (
                          
(
                          
199609206       ; serial, todays date + todays serial #
                          
#
                          
8H              ; refresh, seconds
                          
seconds
                          
2H              ; retry, seconds
                          
seconds
                          
4W              ; expire, seconds
                          
seconds
                          
1D )            ; minimum, seconds
seconds
                  NS      land-5.com.
com.
                  NS      ns2.psi.net.
net.
                  MX      10 land-5.com.  ; Primary Mail Exchanger
                  
Exchanger
                  
TXT     "LAND-5 Corporation"

&quot;LAND-5 Corporation&quot;

  localhost       A       127.0.0.1

1

  router          A       206.6.177.1

1

  land-5.com.     A       206.6.177.2
2
  ns              A       206.6.177.3
3
  www             A       207.159.141.192

192

  ftp             CNAME   land-5.com.
com.
  mail            CNAME   land-5.com.
com.
  news            CNAME   land-5.com.

com.

  funn            A       206.6.177.2

  ;
  
2

  ;
  
;       Workstations
  ;
Workstations
  ;
  ws-177200       A       206.6.177.200
200
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177201       A       206.6.177.201
201
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177202       A       206.6.177.202
202
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177203       A       206.6.177.203
203
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177204       A       206.6.177.204
204
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177205       A       206.6.177.205
205
                  MX      10 land-5.com.   ; Primary Mail Host
  
Host
  
; {Many repetitive definitions deleted - SNIP}
SNIP}
  ws-177250       A       206.6.177.250
250
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177251       A       206.6.177.251
251
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177252       A       206.6.177.252
252
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177253       A       206.6.177.253
253
                  MX      10 land-5.com.   ; Primary Mail Host
Host
  ws-177254       A       206.6.177.254
254
                  MX      10 land-5.com.   ; Primary Mail Host
  ______________________________________________________________________



  
Host
  ______________________________________________________________________



  
If you examine land-5s nameserver you will find that the host names
names
  are of the form ws_number.  As of late BIND 4 versions named started
  
started
  
enforcing the restrictions on what characters may be used in host
host
  names.  So that does not work with BIND 8 at all, and I substituted
substituted
  '-' (dash) for '_' (underline) for use in this HOWTO.  But, as
  
as
  
mentioned earlier, BIND 9 no longer enforces this restriction.


  
restriction.


  
Another thing to note is that the workstations don't have individual
  
individual
  
names, but rather a prefix followed by the two last parts of the IP
IP
  numbers.  Using such a convention can simplify maintenance
  
maintenance
  
significantly, but can be a bit impersonal, and, in fact, be a source
  
source
  
of irritation among your customers.


customers.


  We also see that funn.land-5.com is an alias for land-5.com, but using
  
using
  
an A record, not a CNAME record.


record.


  7.5.  /var/named/zone/206.6.177

  
177

  
I'll comment on this file below


  ______________________________________________________________________
  
below


  ______________________________________________________________________
  
$TTL 3D
3D
  @               IN      SOA     land-5.com. root.land-5.com. (
                                  
(
                                  
199609206       ; Serial
                                  
Serial
                                  
28800   ; Refresh
                                  
Refresh
                                  
7200    ; Retry
                                  
Retry
                                  
604800  ; Expire
                                  
Expire
                                  
86400)  ; Minimum TTL
TTL
                          NS      land-5.com.
com.
                          NS      ns2.psi.net.
  ;
  
net.
  ;
  
;       Servers
  ;
Servers
  ;
  1       PTR     router.land-5.com.
com.
  2       PTR     land-5.com.
com.
  2       PTR     funn.land-5.com.
  ;
  
com.
  ;
  
;       Workstations
  ;
Workstations
  ;
  200     PTR     ws-177200.land-5.com.
com.
  201     PTR     ws-177201.land-5.com.
com.
  202     PTR     ws-177202.land-5.com.
com.
  203     PTR     ws-177203.land-5.com.
com.
  204     PTR     ws-177204.land-5.com.
com.
  205     PTR     ws-177205.land-5.com.
  
com.
  
; {Many repetitive definitions deleted - SNIP}
SNIP}
  250     PTR     ws-177250.land-5.com.
com.
  251     PTR     ws-177251.land-5.com.
com.
  252     PTR     ws-177252.land-5.com.
com.
  253     PTR     ws-177253.land-5.com.
com.
  254     PTR     ws-177254.land-5.com.
  ______________________________________________________________________



  
com.
  ______________________________________________________________________



  
The reverse zone is the bit of the setup that seems to cause the most
most
  grief.  It is used to find the host name if you have the IP number of
of
  a machine.  Example: you are an FTP server and accept connections from
from
  FTP clients.  As you are a Norwegian FTP server you want to accept
  
accept
  
more connections from clients in Norway and other Scandinavian
Scandinavian
  countries and less from the rest of the world.  When you get a
  
a
  
connection from a client the C library is able to tell you the IP
  
IP
  
number of the connecting machine because the IP number of the client
client
  is contained in all the packets that are passed over the network.  Now
  
Now
  
you can call a function called gethostbyaddr that looks up the name of
of
  a host given the IP number.  Gethostbyaddr will ask a DNS server,
server,
  which will then traverse the DNS looking for the machine.  Supposing
Supposing
  the client connection is from ws-177200.land-5.com.  The IP number the
the
  C library provides to the FTP server is 206.6.177.200.  To find out
out
  the name of that machine we need to find 200.177.6.206.in-addr.arpa.
arpa.
  The DNS server will first find the arpa. servers, then find in-
in-
  addr.arpa. servers, following the reverse trail through 206, then 6
6
  and at last finding the server for the 177.6.206.in-addr.arpa zone at
at
  LAND-5.  From which it will finally get the answer that for
for
  200.177.6.206.in-addr.arpa we have a ``PTR ws-177200.land-5.com''
com''
  record, meaning that the name that goes with 206.6.177.200 is
is
  ws-177200.land-5.com.


  
com.


  
The FTP server prioritizes connections from the Scandinavian
Scandinavian
  countries, i.e., *.no, *.se, *.dk, the name ws-177200.land-5.com
  
com
  
clearly does not match any of those, and the server will put the
  
the
  
connection in a connection class with less bandwidth and fewer clients
clients
  allowed.  If there was no reverse mapping of 206.2.177.200 through the
the
  in-addr.arpa zone the server would have been unable to find the name
name
  at all and would have to settle to comparing 206.2.177.200 with *.no,
no,
  *.se and *.dk, none of which will match at all, it may even deny the
  
the
  
connection for lack of classification.


  
classification.


  
Some people will tell you that reverse lookup mappings are only
only
  important for servers, or not important at all.  Not so: Many ftp,
  
ftp,
  
news, IRC and even some http (WWW) servers will not accept connections
connections
  from machines of which they are not able to find the name.  So reverse
  
reverse
  
mappings for machines are in fact mandatory.


mandatory.


  8.  Maintenance

  
Maintenance

  
Keeping it working.


  
working.


  
There is one maintenance task you have to do on nameds, other than
than
  keeping them running.  That's keeping the root.hints file updated.
updated.
  The easiest way is using dig. First run dig with no arguments you will
will
  get the root.hints according to your own server.  Then ask one of the
the
  listed root servers with dig @rootserver.  You will note that the
the
  output looks terribly like a root.hints file.  Save it to a file (dig
(dig
  @e.root-servers.net . ns >root.&gt;root.hints.new) and replace the old
old
  root.hints with it.


  
it.


  
Remember to reload named after replacing the cache file.


  
file.


  
Al Longyear sent me this script that can be run automatically to
to
  update root.hints.  Install a crontab entry to run it once a month and
and
  forget it.  The script assumes you have mail working and that the
the
  mail-alias `hostmaster' is defined.  You must hack it to suit your
  setup.



  ______________________________________________________________________
  #!/bin/sh
  #
  
your
  setup.



  ______________________________________________________________________
  #!/bin/sh
  #
  
# Update the nameserver cache information file once per month.
  
month.
  
# This is run automatically by a cron entry.
  #
  
entry.
  #
  
# Original by Al Longyear
  
Longyear
  
# Updated for BIND 8 by Nicolai Langfeldt
Langfeldt
  # Miscelanious error-conditions reported by David A. Ranch
  
Ranch
  
# Ping test suggested by Martin Foster
  
Foster
  
# named up-test suggested by Erik Bryer.
  #
  (
   
Bryer.
  #
  (
   
echo "To: &quot;To: hostmaster <hostmaster>"
   
&lt;hostmaster&gt;&quot;
   
echo "From: &quot;From: system <root>"

   
&lt;root&gt;&quot;

   
# Is named up? Check the status of named.
   
named.
   
case `rndc status 2>&1` in
      *refused*)
          
2&gt;&amp;1` in
      *refused*)
          
echo "named &quot;named is DOWN. root.hints was NOT updated"
          echo
          
updated&quot;
          echo
          
exit 0
          ;;
   esac

   PATH=/sbin:/usr/sbin:/bin:/usr/bin:
   
0
          ;;
   esac

   PATH=/sbin:/usr/sbin:/bin:/usr/bin:
   
export PATH
   
PATH
   
# NOTE: /var/named must be writable only by trusted users or this script
   
script
   
# will cause root compromise/denial of service opportunities.
   
opportunities.
   
cd /var/named 2>/dev/null 2&gt;/dev/null || {
      
{
      
echo "Subject: &quot;Subject: Cannot cd to /var/named, error $?"
      echo
      
$?&quot;
      echo
      
echo "The &quot;The subject says it all"
      
all&quot;
      
exit 1
   }

   
1
   }

   
# Are we online?  Ping a server at your ISP
ISP
   case `ping -qnc 1 some.machine.net 2>&1` in
     
2&gt;&amp;1` in
     
*'100% packet loss'*)
          
loss'*)
          
echo "Subject: &quot;Subject: root.hints NOT updated.  The network is DOWN."
          echo
          
&quot;
          echo
          
echo "The &quot;The subject says it all"
          
all&quot;
          
exit 1
          ;;
   esac

1
          ;;
   esac

   dig @e.root-servers.net . ns >root.&gt;root.hints.new 2> errors

2&gt; errors

   case `cat root.hints.new` in
     *NOERROR*)
          
in
     *NOERROR*)
          
# It worked
          :;;
     *)
          
worked
          :;;
     *)
          
echo "Subject: &quot;Subject: The root.hints file update has FAILED."
          echo
          
&quot;
          echo
          
echo "The &quot;The root.hints update has failed"
          
failed&quot;
          
echo "This &quot;This is the dig output reported:"
          echo
reported:&quot;
          echo
          cat root.hints.new errors
          
errors
          
exit 1
          ;;
   esac

   
1
          ;;
   esac

   
echo "Subject: &quot;Subject: The root.hints file has been updated"
   echo
   
updated&quot;
   echo
   
echo "The &quot;The root.hints file has been updated to contain the following
  information:"
   echo
following
  information:&quot;
   echo
   cat root.hints.new

new

   chown root.root root.hints.new
new
   chmod 444 root.hints.new
new
   rm -f root.hints.old errors
errors
   mv root.hints root.hints.old
old
   mv root.hints.new root.hints
   
hints
   
rndc restart
   echo
   
restart
   echo
   
echo "The &quot;The nameserver has been restarted to ensure that the update is complete."
   
&quot;
   
echo "The &quot;The previous root.hints file is now called
called
  /var/named/root.hints.old."
  
&quot;
  
2>&1 2&gt;&amp;1 | /usr/lib/sendmail -t
  
-t
  
exit 0
  ______________________________________________________________________



0
  ______________________________________________________________________



  Some of you might have picked up that the root.hints file is also
also
  available by ftp from Internic.  Please don't use ftp to update
update
  root.hints, the above method is much more friendly to the net, and
  Internic.


and
  Internic.


  9.  Migrating to BIND 9

  
9

  
The BIND 9 distribution, and the prepackaged versions too, contains a
  
a
  
document called migration that contains notes about how to migrate
migrate
  from BIND 8 to BIND 9.  The document is very straight forward.  If you
  
you
  
installed binary packages it's likely stored in /usr/share/doc/bind*
  
/usr/share/doc/bind*
  
or /usr/doc/bind* somewhere.


  
somewhere.


  
If you're running BIND 4, you may find a document called
  
called
  
migration-4to9 in the same place.


place.


  10.  Questions and Answers

  
Answers

  
Please read this section before mailing me.


me.


  1. My named wants a named.boot file


file


     You are reading the wrong HOWTO.  Please see the old version of
     
of
     
this HOWTO, which covers BIND 4, at  <http://langfeldt.net/DNS-
     HOWTO/>


&lt;http://langfeldt.net/DNS-
     HOWTO/&gt;


  2. How do use DNS from inside a firewall?


firewall?


     A hint: forward only;.  You might also need


     ___________________________________________________________________
       
need


     ___________________________________________________________________
       
query-source port 53;

     ___________________________________________________________________



53;

     ___________________________________________________________________



  inside the ``options'' part of the named.conf file as suggested in the
  
the
  
example ``caching'' section.


section.


  3. How do I make DNS rotate through the available addresses for a
a
     service, say www.busy.site to obtain a load balancing effect, or
     similar?


or
     similar?


     Make several A records for www.busy.site and use BIND 4.9.3 or
or
     later.  Then BIND will round-robin the answers.  It will not work
     
work
     
with earlier versions of BIND.


BIND.


  4. I want to set up DNS on a (closed) intranet.  What do I do?


do?


     You drop the root.hints file and just do zone files.  That also
     
also
     
means you don't have to get new hint files all the time.


time.


  5. How do I set up a secondary (slave) name server?


server?


     If the primary/master server has address 127.0.0.1 you put a line
line
     like this in the named.conf file of your secondary:


     ___________________________________________________________________
       
secondary:


     ___________________________________________________________________
       
zone "linux.bogus" {
             
&quot;linux.bogus&quot; {
             
type slave;
             
slave;
             
file "sz/linux.bogus";
&quot;sz/linux.bogus&quot;;
             masters { 127.0.0.1; };
       };

     ___________________________________________________________________



  
};
       };

     ___________________________________________________________________



  
You may list several alternate master servers the zone can be copied
  
copied
  
from inside the masters list, separated by ';' (semicolon).


(semicolon).


  6. I want BIND running when I'm disconnected from the net.


     
net.


     
There are four items regarding this:


  
this:


  
about
     
about
     
how to run DNS painlessly on a dialup machine:



  
machine:



  
I have discovered with newer versions of BIND that this
  [<em/shuffeling 
this
  [&lt;em/shuffeling 
files, -ed/] is no longer necessary.  There is a
  "forward" 
a
  &quot;forward&quot; 
directive in addition to the "forwarders" &quot;forwarders&quot; directive that
that
  controls how they are used.  The default setting is "forward first",
  
&quot;forward first&quot;,
  
which first asks each of the forwarders, and then tries the normal
normal
  approach of doing the legwork itself if that fails.  This gives the
  
the
  
familiar behaviour of gethostbyname() taking an inordinately long time
time
  when the link is not up.  But if "forward only" &quot;forward only&quot; is set, then BIND
  
BIND
  
gives up when it doesn't get a response from the forwarders, and
and
  gethostbyname() returns immediately.  Hence there is no need to
  
to
  
perform sleight-of-hand with files in /etc and restart the server.

  
server.

  
In my case, I just added the lines

  
lines

  
forward only;
only;
  forwarders { 193.133.58.5; };

};

  to the options { } section of my named.conf file. It works very
very
  nicely. The only disadvantage of this is that it reduces an incredibly
incredibly
  sophisticated piece of DNS software to the status of a dumb cache. To
  
To
  
some extent, I would just like to run a dumb cache for DNS instead,
  
instead,
  
but there doesn't seem to be such a piece of software available for
  Linux.



  
for
  Linux.



  
<ic@deakin.&lt;ic@deakin.edu.au> where
     
au&gt; where
     
he explains his way of doing this:



this:



       I run named on my 'Masquerading' machine here. I have
have
       two root.hints files, one called root.hints.real which contains
contains
       the real root server names and the other called root.hints.fake
       
fake
       
which contains...

       ----
contains...

       ----
       ; root.hints.fake
       
fake
       
; this file contains no information
       ----

information
       ----

       When I go off line I copy the root.hints.fake file to root.hints and
       
and
       
restart named.

named.

       When I go online I copy root.hints.real to root.hints and restart
       named.

       
restart
       named.

       
This is done from ip-down &amp; ip-up respectively.

       
respectively.

       
The first time I do a query off line on a domain name named doesn't
       
doesn't
       
have details for it puts an entry like this in messages..

       
messages..

       
Jan 28 20:10:11 hazchem named[10147]: No root nameserver for class IN

       
IN

       
which I can live with.

with.

       It certainly seems to work for me. I can use the nameserver for
       
for
       
local machines while off the 'net without the timeout delay for
       
for
       
external domain names and I while on the 'net queries for external
       
external
       
domains work normally



normally



  Peter Denison thought that Ian does not go far enough though.  He
  writes:



       
He
  writes:



       
When connected) serve all cached (and local network) entries immediately
                       
immediately
                       
for non-cached entries, forward to my ISPs nameserver
       
nameserver
       
When off-line)  serve local network queries immediately
                       
immediately
                       
fail all other queries **immediately**

       
**immediately**

       
The combination of changing the root cache file and forwarding queries
       
queries
       
doesn't work.

       
work.

       
So, I've set up (with some discussion of this on the local LUG) two nameds
       
nameds
       
as follows:

       
follows:

       
named-online:   forwards to ISPs nameserver
                       
nameserver
                       
master for localnet zone
zone
                       master for localnet reverse zone (1.168.192.in-addr.arpa)
arpa)
                       master for 0.0.127.in-addr.arpa
                       
arpa
                       
listens on port 60053

       
60053

       
named-offline:  no forwarding
                       "fake" 
forwarding
                       &quot;fake&quot; 
root cache file
file
                       slave for 3 local zones (master is 127.0.0.1:60053)
                       
1:60053)
                       
listens on port 61053

       
61053

       
And combined this with port forwarding, to send port 53 to 61053 when
when
       off-line, and to port 60053 when online. (I'm using the new netfilter
netfilter
       package under 2.3.18, but the old (ipchains) mechanism should work.)

       
)

       
Note that this won't quite work out-of-the-box, as there's a slight bug in
in
       BIND 8.2, which I have logged wth the developers, preventing a slave
slave
       having a master on the same IP address (even if a different port). It's a
       
a
       
trivial patch, and should go in soon I hope.



  
hope.



  
NFS
     
NFS
     
and the portmapper on a mostly offline machine from Karl-Max
     Wanger:



  
Karl-Max
     Wanger:



  
I use to run my own named on all my machines which are only
only
  occasionally connected to the Internet by modem. The nameserver only
  
only
  
acts as a cache, it has no area of authority and asks back for
for
  everything at the name servers in the root.cache file. As is usual
  
usual
  
with Slackware, it is started before nfsd and mountd.

  
mountd.

  
With one of my machines (a Libretto 30 notebook) I had the problem
  
problem
  
that sometimes I could mount it from another system connected to my
my
  local LAN, but most of the time it didn't work.  I had the same effect
  
effect
  
regardless of using PLIP, a PCMCIA ethernet card or PPP over a serial
  interface.

  
serial
  interface.

  
After some time of guessing and experimenting I found out that
  
that
  
apparently named messed with the process of registration nfsd and
  
and
  
mountd have to carry out with the portmapper upon startup (I start
start
  these daemons at boot time as usual). Starting named after nfsd and
  
and
  
mountd eliminated this problem completely.

  
completely.

  
As there are no disadvantages to expect from such a modified boot
  
boot
  
sequence I'd advise everybody to do it that way to prevent potential
  trouble.



potential
  trouble.



  7. Where does the caching name server store its cache? Is there any
     
any
     
way I can control the size of the cache?


     
cache?


     
The cache is completely stored in memory, it is not written to disk
disk
     at any time.  Every time you kill named the cache is lost.  The
The
     cache is not controllable in any way.  named manages it according
according
     to some simple rules and that is it.  You cannot control the cache
cache
     or the cache size in any way for any reason. If you want to you can
can
     ``fix'' this by hacking named.  This is however not recommended.


recommended.


  8. Does named save the cache between restarts?  Can I make it save it?


it?


     No, named does not save the cache when it dies.  That means that
     
that
     
the cache must be built anew each time you kill and restart named.
named.
     There is no way to make named save the cache in a file.  If you
you
     want you can ``fix'' this by hacking named.  This is however not
     recommended.


not
     recommended.


  9. How can I get a domain? I want to set up my own domain called (for
(for
     example) linux-rules.net.  How can I get the domain I want assigned
     
assigned
     
to me?


me?


     Please contact your network service provider.  They will be able to
to
     help you with this.  Please note that in most parts of the world
     
world
     
you need to pay money to get a domain.


  10.
     
domain.


  10.
     
How can I secure my DNS server?  How do I set up split DNS?


DNS?


     Both of these are advanced topics.  They are both covered in
     <http://www.
in
     &lt;http://www.
etherboy.com/dns/chrootdns.html>.  html&gt;.  I will not explain
     
explain
     
the topics further here.
here.
  11.  How to become a bigger time DNS admin.

  
admin.

  
Documentation and tools.


tools.


  Real Documentation exists.  Online and in print.  The reading of
  
of
  
several of these is required to make the step from small time DNS
  
DNS
  
admin to a big time one.


  
one.


  
I have written The Concise Guide to DNS and BIND (by Nicolai
Nicolai
  Langfeldt, me), published by Que (ISBN 0-7897-2273-9).  The book is
  
is
  
much like this HOWTO, just more details, and a lot more of everything.
  
everything.
  
It has also been translated to Polish and published as DNS i BIND by
  
by
  
Helion ( <http://helion.&lt;http://helion.pl/ksiazki/dnsbin.htm>, htm&gt;, ISBN 83-7197-446-9).
83-7197-446-9).
  Now in 4th edition is DNS and BIND by Cricket Liu and P. Albitz from
  
from
  
O'Reilly &amp; Associates (ISBN 0-937175-82-X, affectionately known as the
the
  Cricket book).  Another book is Linux DNS Server Administration, by
  
by
  
Craig Hunt, published by Sybex (ISBN 0782127363), I have not read it
it
  yet.  Another must for good DNS administration (or good anything for
  
for
  
that matter) is Zen and the Art of Motorcycle Maintenance by Robert M.
  Pirsig.


  
M.
  Pirsig.


  
Online you will find my book, along with tons of other books,
  
books,
  
available electronically as a subscription service at
  <http://safari.
at
  &lt;http://safari.
informit.com/>.  com/&gt;.  There is stuff on
  <http://www.
on
  &lt;http://www.
dns.net/dnsrd/> net/dnsrd/&gt; (DNS Resources Directory),
  <http://www.
Directory),
  &lt;http://www.
isc.org/bind.html>; html&gt;; A FAQ, a reference manual (the ARM
  
ARM
  
should be enclosed in the BIND distribution as well) as well as papers
  
papers
  
and protocol definitions and DNS hacks (these, and most, if not all,
  
all,
  
of the RFCs mentioned below, are also contained in the BIND
BIND
  distribution).  I have not read most of these.  The newsgroup
  <news:comp.
newsgroup
  &lt;news:comp.
protocols.tcp-ip.domains> domains&gt; is about DNS.  In addition there
  
there
  
are a number of RFCs about DNS, the most important are probably the
the
  ones listed here.  Those that have BCP (Best Current Practice) numbers
  
numbers
  
are highly recommended.



     
recommended.



     
RFC 2671
2671
        P. Vixie, Extension Mechanisms for DNS (EDNS0) August 1999.


     
1999.


     
RFC 2317
2317
        BCP 20, H. Eidnes et. al. Classless IN-ADDR.ARPA delegation,
delegation,
        March 1998. This is about CIDR, or classless subnet reverse
        lookups.


     
reverse
        lookups.


     
RFC 2308
2308
        M. Andrews, Negative Caching of DNS Queries, March 1998.  About
        
About
        
negative caching and the $TTL zone file directive.


     
directive.


     
RFC 2219
2219
        BCP 17, M. Hamilton and R. Wright, Use of DNS Aliases for
for
        Network Services, October 1997.  About CNAME usage.


     
usage.


     
RFC 2182
2182
        BCP 16, R. Elz et. al., Selection and Operation of Secondary DNS
        
DNS
        
Servers, July 1997.



     
1997.



     
RFC 2052
2052
        A. Gulbrandsen, P. Vixie, A DNS RR for specifying the location
        
location
        
of services (DNS SRV), October 1996


     
1996


     
RFC 1918
1918
        Y. Rekhter, R. Moskowitz, D. Karrenberg, G. de Groot, E. Lear,
        
Lear,
        
Address Allocation for Private Internets, 02/29/1996.


     
02/29/1996.


     
RFC 1912
1912
        D. Barr, Common DNS Operational and Configuration Errors,
        02/28/1996.


     
Errors,
        02/28/1996.


     
RFC 1912 Errors
Errors
        B. Barr Errors in RFC 1912.  Only available at
        <http://www.
at
        &lt;http://www.
cis.ohio-state.edu/~barr/rfc1912-errors.html>


     
html&gt;


     
RFC 1713
1713
        A. Romao, Tools for DNS debugging, 11/03/1994.


     
11/03/1994.


     
RFC 1712
1712
        C. Farrell, M. Schulze, S. Pleitner, D. Baldoni, DNS Encoding of
        
of
        
Geographical Location, 11/01/1994.


     
11/01/1994.


     
RFC 1183
1183
        R. Ullmann, P. Mockapetris, L. Mamakos, C. Everhart, New DNS RR
        
RR
        
Definitions, 10/08/1990.


     
10/08/1990.


     
RFC 1035
1035
        P. Mockapetris, Domain names - implementation and specification,
        11/01/1987.


     
specification,
        11/01/1987.


     
RFC 1034
1034
        P. Mockapetris, Domain names - concepts and facilities,
        11/01/1987.


     
facilities,
        11/01/1987.


     
RFC 1033
1033
        M. Lottor, Domain administrators operations guide, 11/01/1987.


     
11/01/1987.


     
RFC 1032
1032
        M. Stahl, Domain administrators guide, 11/01/1987.


     
11/01/1987.


     
RFC 974
974
        C. Partridge, Mail routing and the domain system, 01/01/1986.

01/01/1986.