From Gentle Sloth, 13 Years ago, written in Plain Text.
Embed
  1.   DNS HOWTO
  2.   Nicolai Langfeldt (dns-howto(at)langfeldt.net), Jamie Nor­
  3.   rish and others
  4.   v9.0, 2001-12-20
  5.  
  6.   HOWTO become a totally small time DNS admin.
  7.   ______________________________________________________________________
  8.  
  9.   Table of Contents
  10.  
  11.  
  12.   1. Preamble
  13.  
  14.      1.1 Legal stuff
  15.      1.2 Credits and request for help.
  16.      1.3 Dedication
  17.      1.4 Updated versions
  18.  
  19.   2. Introduction.
  20.  
  21.      2.1 Other nameserver implementations.
  22.  
  23.   3. A resolving, caching name server.
  24.  
  25.      3.1 Starting named
  26.      3.2 Resolvers
  27.      3.3 Congratulations
  28.  
  29.   4. Forwarding
  30.  
  31.   5. A
  32.  
  33.      5.1 But first some dry theory
  34.      5.2 Our own domain
  35.      5.3 The reverse zone
  36.      5.4 Words of caution
  37.      5.5 Why reverse lookups don't work.
  38.         5.5.1 The reverse zone isn't delegated.
  39.         5.5.2 You've got a classless subnet
  40.      5.6 Slave servers
  41.  
  42.   6. Basic security options.
  43.  
  44.      6.1 Restricting zone transfers
  45.      6.2 Protecting against spoofing
  46.      6.3 Running named as non-root
  47.  
  48.   7. A real domain example
  49.  
  50.      7.1 /etc/named.conf (or /var/named/named.conf)
  51.      7.2 /var/named/root.hints
  52.      7.3 /var/named/zone/127.0.0
  53.      7.4 /var/named/zone/land-5.com
  54.      7.5 /var/named/zone/206.6.177
  55.  
  56.   8. Maintenance
  57.  
  58.   9. Migrating to BIND 9
  59.  
  60.   10. Questions and Answers
  61.  
  62.   11. How to become a bigger time DNS admin.
  63.  
  64.  
  65.  
  66.   ______________________________________________________________________
  67.  
  68.   1.  Preamble
  69.  
  70.   Keywords: DNS, BIND, BIND 4, BIND 8, BIND 9, named, dialup, PPP, slip,
  71.   ISDN, Internet, domain, name, resolution, hosts, caching.
  72.  
  73.  
  74.   This document is part of the Linux Documentation Project.
  75.  
  76.  
  77.   1.1.  Legal stuff
  78.  
  79.   (C)opyright 1995-2001 Nicolai Langfeldt, Jamie Norrish & Co. Do not
  80.   modify without amending copyright, distribute freely but retain
  81.   copyright message.
  82.  
  83.  
  84.   1.2.  Credits and request for help.
  85.  
  86.   I want to thank all the people that I have bothered with reading this
  87.   HOWTO (you know who you are) and all the readers that have e-mailed
  88.   suggestions and notes.
  89.  
  90.  
  91.   This will never be a finished document; please send me mail about your
  92.   problems and successes.  You can help make this a better HOWTO.  So
  93.   please send comments and/or questions or money to
  94.   janl(at)langfeldt.net.  Or buy my DNS book (it's titled "The Concise
  95.   Guide to DNS and BIND, the bibliography has ISBNs).  If you send e-
  96.   mail and want an answer please show the simple courtesy of making sure
  97.   that the return address is correct and working.  Also, please read the
  98.   ``qanda'' section before mailing me.  Another thing, I can only
  99.   understand Norwegian and English.
  100.  
  101.  
  102.   This is a HOWTO.  I have maintained it as part of the LDP since 1995.
  103.   I have, during 2000, written a book on the same subject.  I want to
  104.   say that, though this HOWTO is in many ways much like the book it is
  105.   not a watered down version concocted to market the book.  The readers
  106.   of this HOWTO have helped me understand what is difficult to
  107.   understand about DNS.  This has helped the book, but the book has also
  108.   helped me to think more about what this HOWTO needs.  The HOWTO begot
  109.   the book.  The book begot version 3 of this HOWTO.  My thanks to the
  110.   book publisher, Que, that took a chance on me :-)
  111.  
  112.  
  113.  
  114.   1.3.  Dedication
  115.  
  116.   This HOWTO is dedicated to Anne Line Norheim Langfeldt.  Though she
  117.   will probably never read it since she's not that kind of girl.
  118.  
  119.  
  120.   1.4.  Updated versions
  121.  
  122.   You should be able to find updated versions of this HOWTO both at
  123.   <http://langfeldt.net/DNS-HOWTO/> and on  <http://www.linuxdoc.org/>.
  124.   Go there if this document is dated more than 9 months ago.
  125.  
  126.  
  127.   2.  Introduction.
  128.  
  129.   What this is and isn't.
  130.  
  131.  
  132.   DNS is the Domain Name System.  DNS converts machine names to the IP
  133.   addresses that all machines on the net have.  It translates (or "maps"
  134.   as the jargon would have it) from name to address and from address to
  135.   name, and some other things.  This HOWTO documents how to define such
  136.   mappings using Unix system, with a few things specific to Linux.
  137.  
  138.  
  139.   A mapping is simply an association between two things, in this case a
  140.   machine name, like ftp.linux.org, and the machine's IP number (or
  141.   address) 199.249.150.4.  DNS also contains mappings the other way,
  142.   from the IP number to the machine name; this is called a "reverse
  143.   mapping".
  144.  
  145.  
  146.   DNS is, to the uninitiated (you ;-), one of the more opaque areas of
  147.   network administration.  Fortunately DNS isn't really that hard.  This
  148.   HOWTO will try to make a few things clearer.  It describes how to set
  149.   up a simple DNS name server, starting with a caching only server and
  150.   going on to setting up a primary DNS server for a domain.  For more
  151.   complex setups you can check the ``qanda'' section of this document.
  152.   If it's not described there you will need to read the Real
  153.   Documentation.  I'll get back to what this Real Documentation consists
  154.   of in ``the last chapter''.
  155.  
  156.  
  157.   Before you start on this you should configure your machine so that you
  158.   can telnet in and out of it, and successfully make all kinds of
  159.   connections to the net, and you should especially be able to do telnet
  160.   127.0.0.1 and get your own machine (test it now!).  You also need good
  161.   /etc/nsswitch.conf, /etc/resolv.conf and /etc/hosts files as a
  162.   starting point, since I will not explain their function here.  If you
  163.   don't already have all this set up and working the Networking-HOWTO
  164.   and/or the Networking-Overview-HOWTO explains how to set it up.  Read
  165.   them.
  166.  
  167.  
  168.   When I say `your machine' I mean the machine you are trying to set up
  169.   DNS on, not any other machine you might have that's involved in your
  170.   networking effort.
  171.  
  172.  
  173.   I assume you're not behind any kind of firewall that blocks name
  174.   queries.  If you are you will need a special configuration --- see the
  175.   section on ``qanda''.
  176.  
  177.  
  178.   Name serving on Unix is done by a program called named.  This is a
  179.   part of the ``BIND'' package which is coordinated by The Internet
  180.   Software Consortium.  Named is included in most Linux distributions
  181.   and is usually installed as /usr/sbin/named, usually from a package
  182.   called BIND, in upper or lower case depending on the whim of the
  183.   packager.
  184.  
  185.  
  186.   If you have a named you can probably use it; if you don't have one you
  187.   can get a binary off a Linux ftp site, or get the latest and greatest
  188.   source from  <ftp://ftp.isc.org/isc/bind9/>.  This HOWTO is about BIND
  189.   version 9.  The old versions of the HOWTO, about BIND 4 and 8, is
  190.   still available at  <http://langfeldt.net/DNS-HOWTO/> in case you use
  191.   BIND 4 or 8 (incidentally, you will find this HOWTO there too).  If
  192.   the named man page talks about (at the very end, in the FILES section)
  193.   named.conf you have BIND 8; if it talks about named.boot you have BIND
  194.   4.  If you have 4 and are security conscious you really ought to
  195.   upgrade to the latest version of BIND 8.  Now.
  196.  
  197.  
  198.   DNS is a net-wide database.  Take care about what you put into it.  If
  199.   you put junk into it, you, and others, will get junk out of it.  Keep
  200.   your DNS tidy and consistent and you will get good service from it.
  201.   Learn to use it, admin it, debug it and you will be another good admin
  202.   keeping the net from falling to its knees by mismanagement.
  203.  
  204.  
  205.   Tip: Make backup copies of all the files I instruct you to change if
  206.   you already have them, so that if after going through this nothing
  207.   works you can get it back to your old, working state.
  208.  
  209.  
  210.   2.1.  Other nameserver implementations.
  211.  
  212.   This section was written by Joost van Baal.
  213.  
  214.  
  215.   Various packages exist for getting a DNS server on your box.  There is
  216.   the BIND package ( <http://www.isc.org/products/BIND/>); the
  217.   implementation this HOWTO is about.  It's the most popular nameserver
  218.   around and it's used on the vast majority of name serving machines on
  219.   the Internet, around and being deployed since the 1980's.  It's
  220.   available under a BSD license.  Since it's the most popular package,
  221.   loads of documentation and knowledge about BIND is around.  However,
  222.   there have been security problems with BIND.
  223.  
  224.  
  225.   Then there is djbdns ( <http://djbdns.org/>), a relatively new DNS
  226.   package written by Daniel J. Bernstein, who also wrote qmail.  It's a
  227.   very modular suite: various small programs take care of the different
  228.   jobs a nameserver is supposed to handle.  It's designed with security
  229.   in mind.  It uses a simpler zone-file format, and is generally easier
  230.   to configure.  However, since it's less well known, your local guru
  231.   might not be able to help you with this.  Unfortunately, this software
  232.   is not Open Source.  The author's advertisement is on
  233.   <http://cr.yp.to/djbdns/ad.html>.
  234.  
  235.  
  236.   Whether DJBs software is really an improvement over the older
  237.   alternatives is a subject of much debate.  A discussion (or is it a
  238.   flame-war?) of BIND vs djbdns, joined by ISC people, is on
  239.   <http://www.isc.org/ml-archives/bind-users/2000/08/msg01075.html>
  240.  
  241.  
  242.   3.  A resolving, caching name server.
  243.  
  244.   A first stab at DNS config, very useful for dialup, cable-modem, ADSL
  245.   and similar users.
  246.  
  247.  
  248.   On Red Hat and Red Hat related distributions you can achieve the same
  249.   practical result as this HOWTO's first section by installing the
  250.   packages bind, bind-utils and caching-nameserver.  If you use Debian
  251.   simply install bind (or bind9, as of this writing, BIND 9 is not
  252.   supported by Debian Stable (potato)) and bind-doc.  Of course just
  253.   installing those packages won't teach you as much as reading this
  254.   HOWTO.  So install the packages, and then read along verifying the
  255.   files they installed.
  256.  
  257.  
  258.   A caching only name server will find the answer to name queries and
  259.   remember the answer the next time you need it.  This will shorten the
  260.   waiting time the next time significantly, especially if you're on a
  261.   slow connection.
  262.  
  263.  
  264.   First you need a file called /etc/named.conf (Debian:
  265.   /etc/bind/named.conf).  This is read when named starts.  For now it
  266.   should simply contain:
  267.  
  268.  
  269.   ______________________________________________________________________
  270.   // Config file for caching only name server
  271.   //
  272.   // The version of the HOWTO you read may contain leading spaces
  273.   // (spaces in front of the characters on these lines ) in this and
  274.   // other files.  You must remove them for things to work.
  275.   //
  276.   // Note that the filenames and directory names may differ, the
  277.   // ultimate contents of should be quite similar though.
  278.  
  279.   options {
  280.           directory "/var/named";
  281.  
  282.           // Uncommenting this might help if you have to go through a
  283.           // firewall and things are not working out.  But you probably
  284.           // need to talk to your firewall admin.
  285.  
  286.           // query-source port 53;
  287.   };
  288.  
  289.   controls {
  290.           inet 127.0.0.1 allow { localhost; } keys { rndc_key; };
  291.   };
  292.  
  293.   key "rndc_key" {
  294.           algorithm hmac-md5;
  295.           secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
  296.   };
  297.  
  298.   zone "." {
  299.           type hint;
  300.           file "root.hints";
  301.   };
  302.  
  303.   zone "0.0.127.in-addr.arpa" {
  304.           type master;
  305.           file "pz/127.0.0";
  306.   };
  307.   ______________________________________________________________________
  308.  
  309.  
  310.  
  311.   The Linux distribution packages may use different file names for each
  312.   kind of file mentioned here; they will still contain about the same
  313.   things.
  314.  
  315.  
  316.   The `directory' line tells named where to look for files.  All files
  317.   named subsequently will be relative to this.  Thus pz is a directory
  318.   under /var/named, i.e., /var/named/pz.  /var/named is the right
  319.   directory according to the Linux File system Standard.
  320.  
  321.  
  322.   The file named /var/named/root.hints is named in this.
  323.   /var/named/root.hints should contain this:
  324.  
  325.  
  326.  
  327.   ______________________________________________________________________
  328.   ;
  329.   ; There might be opening comments here if you already have this file.
  330.   ; If not don't worry.
  331.   ;
  332.   ; About any leading spaces in front of the lines here: remove them!
  333.   ; Lines should start in a ;, . or character, not blanks.
  334.   ;
  335.   .                       6D  IN      NS      A.ROOT-SERVERS.NET.
  336.   .                       6D  IN      NS      B.ROOT-SERVERS.NET.
  337.   .                       6D  IN      NS      C.ROOT-SERVERS.NET.
  338.   .                       6D  IN      NS      D.ROOT-SERVERS.NET.
  339.   .                       6D  IN      NS      E.ROOT-SERVERS.NET.
  340.   .                       6D  IN      NS      F.ROOT-SERVERS.NET.
  341.   .                       6D  IN      NS      G.ROOT-SERVERS.NET.
  342.   .                       6D  IN      NS      H.ROOT-SERVERS.NET.
  343.   .                       6D  IN      NS      I.ROOT-SERVERS.NET.
  344.   .                       6D  IN      NS      J.ROOT-SERVERS.NET.
  345.   .                       6D  IN      NS      K.ROOT-SERVERS.NET.
  346.   .                       6D  IN      NS      L.ROOT-SERVERS.NET.
  347.   .                       6D  IN      NS      M.ROOT-SERVERS.NET.
  348.   A.ROOT-SERVERS.NET.     6D  IN      A       198.41.0.4
  349.   B.ROOT-SERVERS.NET.     6D  IN      A       128.9.0.107
  350.   C.ROOT-SERVERS.NET.     6D  IN      A       192.33.4.12
  351.   D.ROOT-SERVERS.NET.     6D  IN      A       128.8.10.90
  352.   E.ROOT-SERVERS.NET.     6D  IN      A       192.203.230.10
  353.   F.ROOT-SERVERS.NET.     6D  IN      A       192.5.5.241
  354.   G.ROOT-SERVERS.NET.     6D  IN      A       192.112.36.4
  355.   H.ROOT-SERVERS.NET.     6D  IN      A       128.63.2.53
  356.   I.ROOT-SERVERS.NET.     6D  IN      A       192.36.148.17
  357.   J.ROOT-SERVERS.NET.     6D  IN      A       198.41.0.10
  358.   K.ROOT-SERVERS.NET.     6D  IN      A       193.0.14.129
  359.   L.ROOT-SERVERS.NET.     6D  IN      A       198.32.64.12
  360.   M.ROOT-SERVERS.NET.     6D  IN      A       202.12.27.33
  361.   ______________________________________________________________________
  362.  
  363.  
  364.  
  365.   The file describes the root name servers in the world.  The servers
  366.   change over time and must be maintained now and then.  See the
  367.   ``maintenance section'' for how to keep it up to date.
  368.  
  369.  
  370.   The next section in named.conf is the last zone.  I will explain its
  371.   use in a later chapter; for now just make this a file named 127.0.0 in
  372.   the subdirectory pz: (Again, please remove leading spaces if you cut
  373.   and paste this)
  374.  
  375.  
  376.   ______________________________________________________________________
  377.   $TTL 3D
  378.   @               IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
  379.                                   1       ; Serial
  380.                                   8H      ; Refresh
  381.                                   2H      ; Retry
  382.                                   4W      ; Expire
  383.                                   1D)     ; Minimum TTL
  384.                           NS      ns.linux.bogus.
  385.   1                       PTR     localhost.
  386.   ______________________________________________________________________
  387.  
  388.  
  389.  
  390.   The sections called key and controls together specify that your named
  391.   can be remotely controlled by a program called rndc if it connects
  392.   from the local host, and identifis itself with the encoded secret key.
  393.   This key is like a password.  For rndc to work you need /etc/rndc.conf
  394.   to match this:
  395.  
  396.  
  397.   ______________________________________________________________________
  398.   key rndc_key {
  399.       algorithm "hmac-md5";
  400.       secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
  401.   };
  402.  
  403.   options {
  404.       default-server localhost;
  405.       default-key    rndc_key;
  406.   };
  407.   ______________________________________________________________________
  408.  
  409.  
  410.  
  411.   As you see the secret is identical.  If you want to use rndc from
  412.   other machines their times need to be within 5 minutes of eachother.
  413.   I recommend using the ntp (xntpd and ntpdate) software to do this.
  414.  
  415.  
  416.   Next, you need a /etc/resolv.conf looking something like this: (Again:
  417.   Remove spaces!)
  418.  
  419.  
  420.   ______________________________________________________________________
  421.   search subdomain.your-domain.edu your-domain.edu
  422.   nameserver 127.0.0.1
  423.   ______________________________________________________________________
  424.  
  425.  
  426.  
  427.   The `search' line specifies what domains should be searched for any
  428.   host names you want to connect to.  The `nameserver' line specifies
  429.   the address of your nameserver, in this case your own machine since
  430.   that is where your named runs (127.0.0.1 is right, no matter if your
  431.   machine has another address too).  If you want to list several name
  432.   servers put in one `nameserver' line for each. (Note: Named never
  433.   reads this file, the resolver that uses named does. Note 2: In some
  434.   resolv.conf files you find a line saying "domain".  That's fine, but
  435.   don't use both "search" and "domain", only one of them will work).
  436.  
  437.  
  438.   To illustrate what this file does: If a client tries to look up foo,
  439.   then foo.subdomain.your-domain.edu is tried first, then foo.your-
  440.   domain.edu, and finally foo.  You may not want to put in too many
  441.   domains in the search line, as it takes time to search them all.
  442.  
  443.  
  444.   The example assumes you belong in the domain subdomain.your-
  445.   domain.edu; your machine, then, is probably called your-
  446.   machine.subdomain.your-domain.edu.  The search line should not contain
  447.   your TLD (Top Level Domain, `edu' in this case).  If you frequently
  448.   need to connect to hosts in another domain you can add that domain to
  449.   the search line like this: (Remember to remove the leading spaces, if
  450.   any)
  451.  
  452.  
  453.  
  454.   ______________________________________________________________________
  455.   search subdomain.your-domain.edu your-domain.edu other-domain.com
  456.   ______________________________________________________________________
  457.  
  458.  
  459.  
  460.   and so on. Obviously you need to put real domain names in instead.
  461.   Please note the lack of periods at the end of the domain names.  This
  462.   is important; please note the lack of periods at the end of the domain
  463.   names.
  464.  
  465.  
  466.   3.1.  Starting named
  467.  
  468.   After all this it's time to start named.  If you're using a dialup
  469.   connection connect first.  Now run named, either by running the boot
  470.   script: /etc/init.d/named start or named directly: /usr/sbin/named.
  471.   If you have tried previous versions of BIND you're probably used to
  472.   ndc.  I BIND 9 it has been replaced with rndc, which can controll your
  473.   named remotely, but it can't start named anymore. If you view your
  474.   syslog message file (usually called /var/log/messages, Debian calls it
  475.   /var/log/daemon, another directory to look is the other files
  476.   /var/log) while starting named (do tail -f /var/log/messages) you
  477.   should see something like:
  478.  
  479.  
  480.   (the lines ending in \ continues on the next line)
  481.  
  482.  
  483.  
  484.        Dec 23 02:21:12 lookfar named[11031]: starting BIND 9.1.3
  485.        Dec 23 02:21:12 lookfar named[11031]: using 1 CPU
  486.        Dec 23 02:21:12 lookfar named[11034]: loading configuration from \
  487.            '/etc/named.conf'
  488.        Dec 23 02:21:12 lookfar named[11034]: the default for the \
  489.            'auth-nxdomain' option is now 'no'
  490.        Dec 23 02:21:12 lookfar named[11034]: no IPv6 interfaces found
  491.        Dec 23 02:21:12 lookfar named[11034]: listening on IPv4 interface lo, \
  492.            127.0.0.1#53
  493.        Dec 23 02:21:12 lookfar named[11034]: listening on IPv4 interface eth0, \
  494.            10.0.0.129#53
  495.        Dec 23 02:21:12 lookfar named[11034]: command channel listening on \
  496.            127.0.0.1#953
  497.        Dec 23 02:21:13 lookfar named[11034]: running
  498.  
  499.  
  500.  
  501.   If there are any messages about errors then there is a mistake.  Named
  502.   will name the file it is reading.  Go back and check the file.  Start
  503.   named over when it is fixed.
  504.  
  505.  
  506.   Now you can test your setup.  Traditionally a program called nslookup
  507.   is used for this.  These days dig is recommended:
  508.  
  509.  
  510.  
  511.   $ dig -x 127.0.0.1
  512.   ;; Got answer:
  513.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 26669
  514.   ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
  515.  
  516.   ;; QUESTION SECTION:
  517.   ;1.0.0.127.in-addr.arpa.                IN      PTR
  518.  
  519.   ;; ANSWER SECTION:
  520.   1.0.0.127.in-addr.arpa. 259200  IN      PTR     localhost.
  521.  
  522.   ;; AUTHORITY SECTION:
  523.   0.0.127.in-addr.arpa.   259200  IN      NS      ns.linux.bogus.
  524.  
  525.   ;; Query time: 3 msec
  526.   ;; SERVER: 127.0.0.1#53(127.0.0.1)
  527.   ;; WHEN: Sun Dec 23 02:26:17 2001
  528.   ;; MSG SIZE  rcvd: 91
  529.  
  530.  
  531.  
  532.   If that's what you get it's working.  We hope.  Anything very
  533.   different, go back and check everything.  Each time you change a file
  534.   you need to run rndc reload.
  535.  
  536.  
  537.   Now you can enter a query.  Try looking up some machine close to you.
  538.   pat.uio.no is close to me, at the University of Oslo:
  539.  
  540.  
  541.  
  542.        $ dig pat.uio.no
  543.        ; <<>> DiG 9.1.3 <<>> pat.uio.no
  544.        ;; global options:  printcmd
  545.        ;; Got answer:
  546.        ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15574
  547.        ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 0
  548.  
  549.        ;; QUESTION SECTION:
  550.        ;pat.uio.no.                    IN      A
  551.  
  552.        ;; ANSWER SECTION:
  553.        pat.uio.no.             86400   IN      A       129.240.130.16
  554.  
  555.        ;; AUTHORITY SECTION:
  556.        uio.no.                 86400   IN      NS      nissen.uio.no.
  557.        uio.no.                 86400   IN      NS      nn.uninett.no.
  558.        uio.no.                 86400   IN      NS      ifi.uio.no.
  559.  
  560.        ;; Query time: 651 msec
  561.        ;; SERVER: 127.0.0.1#53(127.0.0.1)
  562.        ;; WHEN: Sun Dec 23 02:28:35 2001
  563.        ;; MSG SIZE  rcvd: 108
  564.  
  565.  
  566.  
  567.   This time dig asked your named to look for the machine pat.uio.no.  It
  568.   then contacted one of the name server machines named in your
  569.   root.hints file, and asked its way from there.  It might take tiny
  570.   while before you get the result as it may need to search all the
  571.   domains you named in /etc/resolv.conf.
  572.  
  573.   If you ask the same again you get this:
  574.  
  575.  
  576.  
  577.        $ dig pat.uio.no
  578.  
  579.        ; <<>> DiG 8.2 <<>> pat.uio.no
  580.        ;; res options: init recurs defnam dnsrch
  581.        ;; got answer:
  582.        ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4
  583.        ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 3, ADDITIONAL: 3
  584.        ;; QUERY SECTION:
  585.        ;;      pat.uio.no, type = A, class = IN
  586.  
  587.        ;; ANSWER SECTION:
  588.        pat.uio.no.             23h59m58s IN A  129.240.130.16
  589.  
  590.        ;; AUTHORITY SECTION:
  591.        UIO.NO.                 23h59m58s IN NS  nissen.UIO.NO.
  592.        UIO.NO.                 23h59m58s IN NS  ifi.UIO.NO.
  593.        UIO.NO.                 23h59m58s IN NS  nn.uninett.NO.
  594.  
  595.        ;; ADDITIONAL SECTION:
  596.        nissen.UIO.NO.          23h59m58s IN A  129.240.2.3
  597.        ifi.UIO.NO.             1d23h59m58s IN A  129.240.64.2
  598.        nn.uninett.NO.          1d23h59m58s IN A  158.38.0.181
  599.  
  600.        ;; Total query time: 4 msec
  601.        ;; FROM: lookfar to SERVER: default -- 127.0.0.1
  602.        ;; WHEN: Sat Dec 16 00:23:09 2000
  603.        ;; MSG SIZE  sent: 28  rcvd: 162
  604.  
  605.  
  606.  
  607.   As you can plainly see this time it was much faster, 4ms versus more
  608.   than half a second earlier.  The answer was cached.  With cached
  609.   answers there is the possibility that the answer is out of date, but
  610.   the origin servers can control the time cached answers should be
  611.   considered valid, so there is a high probability that the answer you
  612.   get is valid.
  613.  
  614.  
  615.   3.2.  Resolvers
  616.  
  617.   All OSes implementing the standard C API has the calls gethostbyname
  618.   and gethostbyaddr.  These can get information from several different
  619.   sources.  Which sources it gets it from is configured in
  620.   /etc/nsswitch.conf on Linux (and some other Unixes).  This is a long
  621.   file specifying from which file or database to get different kinds of
  622.   data types.  It usually contains helpful comments at the top, which
  623.   you should consider reading.  After that find the line starting with
  624.   `hosts:'; it should read:
  625.  
  626.  
  627.   ______________________________________________________________________
  628.   hosts:      files dns
  629.   ______________________________________________________________________
  630.  
  631.  
  632.  
  633.   (You remembered about the leading spaces, right? I won't mention them
  634.   again.)
  635.  
  636.   If there is no line starting with `hosts:' then put in the one above.
  637.   It says that programs should first look in the /etc/hosts file, then
  638.   check DNS according to resolv.conf.
  639.  
  640.  
  641.  
  642.   3.3.  Congratulations
  643.  
  644.   Now you know how to set up a caching named.  Take a beer, milk, or
  645.   whatever you prefer to celebrate it.
  646.  
  647.  
  648.  
  649.   4.  Forwarding
  650.  
  651.   In large, well organized, academic or ISP (Internet Service Provider)
  652.   networks you will sometimes find that the network people have set up a
  653.   forwarder hierarchy of DNS servers which helps lighten the internal
  654.   network load and the load on the outside servers as well.  It's not
  655.   easy to know if you're inside such a network or not.  But by using the
  656.   DNS server of your network provider as a ``forwarder'' you can make
  657.   the responses to queries faster and less of a load on your network.
  658.   This works by your nameserver forwarding queries to your ISP
  659.   nameserver.  Each time this happens you will dip into the big cache of
  660.   your ISPs nameserver, thus speeding your queries up, your nameserver
  661.   does not have to do all the work itself.  If you use a modem this can
  662.   be quite a win.  For the sake of this example we assume that your
  663.   network provider has two name servers they want you to use, with IP
  664.   numbers 10.0.0.1 and 10.1.0.1.  Then, in your named.conf file, inside
  665.   the opening section called ``options'', insert these lines:
  666.  
  667.  
  668.   ______________________________________________________________________
  669.              forward first;
  670.              forwarders {
  671.                   10.0.0.1;
  672.                   10.1.0.1;
  673.               };
  674.   ______________________________________________________________________
  675.  
  676.  
  677.  
  678.   There is also a nice trick for dialup machines using forwarders, it is
  679.   described in the ``qanda'' section.
  680.  
  681.  
  682.   Restart your nameserver and test it with dig.  Should still work fine.
  683.  
  684.  
  685.   5.  A simple  domain.
  686.  
  687.   How to set up your own domain.
  688.  
  689.  
  690.   5.1.  But first some dry theory
  691.  
  692.   First of all: you read all the stuff before here right? You have to.
  693.  
  694.  
  695.   Before we really start this section I'm going to serve you some theory
  696.   on and an example of how DNS works.  And you're going to read it
  697.   because it's good for you.  If you don't want to you should at least
  698.   skim it very quickly.  Stop skimming when you get to what should go in
  699.   your named.conf file.
  700.  
  701.   DNS is a hierarchical, tree structured system.  The top is written `.'
  702.   and pronounced `root', as is usual for tree data-structures.  Under .
  703.   there are a number of Top Level Domains (TLDs); the best known ones
  704.   are ORG, COM, EDU and NET, but there are many more.  Just like a tree
  705.   it has a root and it branches out.  If you have any computer science
  706.   background you will recognize DNS as a search tree, and you will be
  707.   able to find nodes, leaf nodes and edges.  The dots are nodes, the
  708.   edges are on the names.
  709.  
  710.  
  711.   When looking for a machine the query proceeds recursively into the
  712.   hierarchy starting at the root.  If you want to find the address of
  713.   prep.ai.mit.edu., your nameserver has to start asking somewhere.  It
  714.   starts by looking it its cache.  If it knows the answer, having cached
  715.   it before, it will answer right away as we saw in the last section.
  716.   If it does not know it will see how closely it can match the requested
  717.   name and use whatever information it has cached.  In the worst case
  718.   there is no match but the `.' (root) of the name, and the root servers
  719.   have to be consulted.  It will remove the leftmost parts one at a
  720.   time, checking if it knows anything about ai.mit.edu., then mit.edu.,
  721.   then edu., and if not that it does know about . because that was in
  722.   the hints file.  It will then ask a .  server about prep.ai.mit.edu.
  723.   This . server will not know the answer, but it will help your server
  724.   on its way by giving a referral, telling it where to look instead.
  725.   These referrals will eventually lead your server to a nameserver that
  726.   knows the answer.  I will illustrate that now.  +norec means that dig
  727.   is asking non-recursive questions so that we get to do the recursion
  728.   ourselves.  The other options are to reduce the amount of dig produces
  729.   so this won't go on for too many pages:
  730.  
  731.  
  732.  
  733.        $ ;; Got answer:
  734.        ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 980
  735.        ;; flags: qr ra; QUERY: 1, ANSWER: 0, AUTHORITY: 13, ADDITIONAL: 0
  736.  
  737.        ;; AUTHORITY SECTION:
  738.        .                       518400  IN      NS      J.ROOT-SERVERS.NET.
  739.        .                       518400  IN      NS      K.ROOT-SERVERS.NET.
  740.        .                       518400  IN      NS      L.ROOT-SERVERS.NET.
  741.        .                       518400  IN      NS      M.ROOT-SERVERS.NET.
  742.        .                       518400  IN      NS      A.ROOT-SERVERS.NET.
  743.        .                       518400  IN      NS      B.ROOT-SERVERS.NET.
  744.        .                       518400  IN      NS      C.ROOT-SERVERS.NET.
  745.        .                       518400  IN      NS      D.ROOT-SERVERS.NET.
  746.        .                       518400  IN      NS      E.ROOT-SERVERS.NET.
  747.        .                       518400  IN      NS      F.ROOT-SERVERS.NET.
  748.        .                       518400  IN      NS      G.ROOT-SERVERS.NET.
  749.        .                       518400  IN      NS      H.ROOT-SERVERS.NET.
  750.        .                       518400  IN      NS      I.ROOT-SERVERS.NET.
  751.  
  752.  
  753.  
  754.   This is a referral. It is giving us an "Authority section" only, no
  755.   "Answer section". Our own nameserver refers us to a nameserver.  Pick
  756.   one at random:
  757.  
  758.  
  759.  
  760.   $ dig +norec +noques +nostats +nocmd prep.ai.mit.edu. @D.ROOT-SERVERS.NET.
  761.   ;; Got answer:
  762.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58260
  763.   ;; flags: qr; QUERY: 1, ANSWER: 0, AUTHORITY: 3, ADDITIONAL: 3
  764.  
  765.   ;; AUTHORITY SECTION:
  766.   mit.edu.                172800  IN      NS      BITSY.mit.edu.
  767.   mit.edu.                172800  IN      NS      STRAWB.mit.edu.
  768.   mit.edu.                172800  IN      NS      W20NS.mit.edu.
  769.  
  770.   ;; ADDITIONAL SECTION:
  771.   BITSY.mit.edu.          172800  IN      A       18.72.0.3
  772.   STRAWB.mit.edu.         172800  IN      A       18.71.0.151
  773.   W20NS.mit.edu.          172800  IN      A       18.70.0.160
  774.  
  775.  
  776.  
  777.   It refers us to MIT.EDU servers at once.  Again pick one at random:
  778.  
  779.  
  780.  
  781.        $ dig +norec +noques +nostats +nocmd prep.ai.mit.edu. @BITSY.mit.edu.
  782.        ;; Got answer:
  783.        ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 29227
  784.        ;; flags: qr ra; QUERY: 1, ANSWER: 1, AUTHORITY: 4, ADDITIONAL: 4
  785.  
  786.        ;; ANSWER SECTION:
  787.        prep.ai.mit.edu.        10562   IN      A       198.186.203.77
  788.  
  789.        ;; AUTHORITY SECTION:
  790.        ai.mit.edu.             21600   IN      NS      FEDEX.ai.mit.edu.
  791.        ai.mit.edu.             21600   IN      NS      LIFE.ai.mit.edu.
  792.        ai.mit.edu.             21600   IN      NS      ALPHA-BITS.ai.mit.edu.
  793.        ai.mit.edu.             21600   IN      NS      BEET-CHEX.ai.mit.edu.
  794.  
  795.        ;; ADDITIONAL SECTION:
  796.        FEDEX.ai.mit.edu.       21600   IN      A       192.148.252.43
  797.        LIFE.ai.mit.edu.        21600   IN      A       128.52.32.80
  798.        ALPHA-BITS.ai.mit.edu.  21600   IN      A       128.52.32.5
  799.        BEET-CHEX.ai.mit.edu.   21600   IN      A       128.52.32.22
  800.  
  801.  
  802.  
  803.   This time we got a "ANSWER SECTION", and an answer for our question.
  804.   The "AUTHORITY SECTION" contains information about which servers to
  805.   ask about ai.mit.edu the next time.  So you can ask them directly the
  806.   next time you wonder about ai.mit.edu names.  Named also gathered
  807.   information about mit.edu, so of www.mit.edu is requested it is much
  808.   closer to being able to answer the question.
  809.  
  810.  
  811.   So starting at . we found the successive name servers for each level
  812.   in the domain name by referral.  If you had used your own DNS server
  813.   instead of using all those other servers, your named would of-course
  814.   cache all the information it found while digging this out for you, and
  815.   it would not have to ask again for a while.
  816.  
  817.  
  818.   In the tree analogue each ``.'' in the name is a branching point.  And
  819.   each part between the ``.''s are the names of individual branches in
  820.   the tree.  One climbs the tree by taking the name we want
  821.   (prep.ai.mit.edu) asking the root (.) or whatever servers father from
  822.   the root toward prep.ai.mit.edu we have information about in the
  823.   cache.  Once the cache limits are reached the recursive resolver goes
  824.   out asking servers, pursuing referrals (edges) further into the name.
  825.  
  826.  
  827.   A much less talked about, but just as important domain is in-
  828.   addr.arpa.  It too is nested like the `normal' domains.  in-addr.arpa
  829.   allows us to get the host's name when we have its address.  A
  830.   important thing to note here is that the IP addresses are written in
  831.   reverse order in the in-addr.arpa domain.  If you have the address of
  832.   a machine: 198.186.203.77 named proceeds to find the named
  833.   77.203.168.198.in-addr.arpa/ just like it did for prep.ai.mit.edu.
  834.   Example: Finding no cache entry for any match but `.', ask a root
  835.   server, m.root-servers.net refers you to some other root servers.
  836.   b.root-servers.net refers you directly to bitsy.mit.edu/.  You should
  837.   be able to take it from there.
  838.  
  839.  
  840.  
  841.   5.2.  Our own domain
  842.  
  843.   Now to define our own domain.  We're going to make the domain
  844.   linux.bogus and define machines in it.  I use a totally bogus domain
  845.   name to make sure we disturb no-one Out There.
  846.  
  847.  
  848.   One more thing before we start: Not all characters are allowed in host
  849.   names.  We're restricted to the characters of the English alphabet: a-
  850.   z, and numbers 0-9 and the character '-' (dash).  Keep to those
  851.   characters (BIND 9 will not bug you if you break this rule, BIND 8
  852.   will). Upper and lower-case characters are the same for DNS, so
  853.   pat.uio.no is identical to Pat.UiO.No.
  854.  
  855.  
  856.   We've already started this part with this line in named.conf:
  857.  
  858.  
  859.   ______________________________________________________________________
  860.   zone "0.0.127.in-addr.arpa" {
  861.           type master;
  862.           file "pz/127.0.0";
  863.   };
  864.   ______________________________________________________________________
  865.  
  866.  
  867.  
  868.   Please note the lack of `.' at the end of the domain names in this
  869.   file.  This says that now we will define the zone 0.0.127.in-
  870.   addr.arpa, that we're the master server for it and that it is stored
  871.   in a file called pz/127.0.0.  We've already set up this file, it
  872.   reads:
  873.  
  874.  
  875.   ______________________________________________________________________
  876.   $TTL 3D
  877.   @               IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
  878.                                   1       ; Serial
  879.                                   8H      ; Refresh
  880.                                   2H      ; Retry
  881.                                   4W      ; Expire
  882.                                   1D)     ; Minimum TTL
  883.                           NS      ns.linux.bogus.
  884.   1                       PTR     localhost.
  885.   ______________________________________________________________________
  886.  
  887.   Please note the `.' at the end of all the full domain names in this
  888.   file, in contrast to the named.conf file above. Some people like to
  889.   start each zone file with a $ORIGIN directive, but this is
  890.   superfluous.  The origin (where in the DNS hierarchy it belongs) of a
  891.   zone file is specified in the zone section of the named.conf file; in
  892.   this case it's 0.0.127.in-addr.arpa.
  893.  
  894.  
  895.   This `zone file' contains 3 `resource records' (RRs): A SOA RR.  A NS
  896.   RR and a PTR RR.  SOA is short for Start Of Authority.  The `@' is a
  897.   special notation meaning the origin, and since the `domain' column for
  898.   this file says 0.0.127.in-addr.arpa the first line really means
  899.  
  900.  
  901.  
  902.        0.0.127.in-addr.arpa.   IN      SOA ...
  903.  
  904.  
  905.  
  906.   NS is the Name Server RR.  There is no '@' at the start of this line;
  907.   it is implicit since the previous line started with a '@'.  Saves some
  908.   typing that.  So the NS line could also be written
  909.  
  910.  
  911.  
  912.        0.0.127.in-addr.arpa.   IN      NS      ns.linux.bogus
  913.  
  914.  
  915.  
  916.   It tells DNS what machine is the name server of the domain 0.0.127.in-
  917.   addr.arpa, it is ns.linux.bogus.  'ns' is a customary name for name-
  918.   servers, but as with web servers who are customarily named
  919.   www.something. The name may be anything.
  920.  
  921.  
  922.   And finally the PTR (Domain Name Pointer) record says that the host at
  923.   address 1 in the subnet 0.0.127.in-addr.arpa, i.e., 127.0.0.1 is named
  924.   localhost.
  925.  
  926.  
  927.   The SOA record is the preamble to all zone files, and there should be
  928.   exactly one in each zone file, at the top (but after the $TTL
  929.   directive).  It describes the zone, where it comes from (a machine
  930.   called ns.linux.bogus), who is responsible for its contents
  931.   (hostmaster@linux.bogus; you should insert your e-mail address here),
  932.   what version of the zone file this is (serial: 1), and other things
  933.   having to do with caching and secondary DNS servers.  For the rest of
  934.   the fields (refresh, retry, expire and minimum) use the numbers used
  935.   in this HOWTO and you should be safe.  Before the SOA comes a
  936.   mandatory line, the $TTL 3D line.  Put it in all your zone files.
  937.  
  938.  
  939.   Now restart your named (rndc stop; named) and use dig to examine your
  940.   handy work.  -x asks for the inverse query:
  941.  
  942.  
  943.  
  944.   $ dig -x 127.0.0.1
  945.   ;; Got answer:
  946.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 30944
  947.   ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0
  948.  
  949.   ;; QUESTION SECTION:
  950.   ;1.0.0.127.in-addr.arpa.                IN      PTR
  951.  
  952.   ;; ANSWER SECTION:
  953.   1.0.0.127.in-addr.arpa. 259200  IN      PTR     localhost.
  954.  
  955.   ;; AUTHORITY SECTION:
  956.   0.0.127.in-addr.arpa.   259200  IN      NS      ns.linux.bogus.
  957.  
  958.   ;; Query time: 3 msec
  959.   ;; SERVER: 127.0.0.1#53(127.0.0.1)
  960.   ;; WHEN: Sun Dec 23 03:02:39 2001
  961.   ;; MSG SIZE  rcvd: 91
  962.  
  963.  
  964.  
  965.   So it manages to get localhost from 127.0.0.1, good.  Now for our main
  966.   task, the linux.bogus domain, insert a new 'zone' section in
  967.   named.conf:
  968.  
  969.  
  970.   ______________________________________________________________________
  971.   zone "linux.bogus" {
  972.           type master;
  973.           notify no;
  974.           file "pz/linux.bogus";
  975.   };
  976.   ______________________________________________________________________
  977.  
  978.  
  979.  
  980.   Note again the lack of ending `.' on the domain name in the named.conf
  981.   file.
  982.  
  983.  
  984.   In the linux.bogus zone file we'll put some totally bogus data:
  985.  
  986.  
  987.  
  988.   ______________________________________________________________________
  989.   ;
  990.   ; Zone file for linux.bogus
  991.   ;
  992.   ; The full zone file
  993.   ;
  994.   $TTL 3D
  995.   @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
  996.                           199802151       ; serial, todays date + todays serial #
  997.                           8H              ; refresh, seconds
  998.                           2H              ; retry, seconds
  999.                           4W              ; expire, seconds
  1000.                           1D )            ; minimum, seconds
  1001.   ;
  1002.                   NS      ns              ; Inet Address of name server
  1003.                   MX      10 mail.linux.bogus     ; Primary Mail Exchanger
  1004.                   MX      20 mail.friend.bogus.   ; Secondary Mail Exchanger
  1005.   ;
  1006.   localhost       A       127.0.0.1
  1007.   ns              A       192.168.196.2
  1008.   mail            A       192.168.196.4
  1009.   ______________________________________________________________________
  1010.  
  1011.  
  1012.  
  1013.   Two things must be noted about the SOA record.  ns.linux.bogus must be
  1014.   a actual machine with a A record.  It is not legal to have a CNAME
  1015.   record for the machine mentioned in the SOA record.  Its name need not
  1016.   be `ns', it could be any legal host name.  Next,
  1017.   hostmaster.linux.bogus should be read as hostmaster@linux.bogus.  This
  1018.   should be a mail alias, or a mailbox, where the person(s) maintaining
  1019.   DNS should read mail frequently.  Any mail regarding the domain will
  1020.   be sent to the address listed here.  The name need not be
  1021.   `hostmaster', it can be your normal e-mail address, but the e-mail
  1022.   address `hostmaster' is often expected to work as well.
  1023.  
  1024.  
  1025.   There is one new RR type in this file, the MX, or Mail eXchanger RR.
  1026.   It tells mail systems where to send mail that is addressed to
  1027.   someone@linux.bogus, namely to mail.linux.bogus or mail.friend.bogus.
  1028.   The number before each machine name is that MX RR's priority.  The RR
  1029.   with the lowest number (10) is the one mail should be sent to if
  1030.   possible.  If that fails the mail can be sent to one with a higher
  1031.   number, a secondary mail handler, i.e., mail.friend.bogus which has
  1032.   priority 20 here.
  1033.  
  1034.  
  1035.   Reload named by running rndc reload.  Examine the results with dig:
  1036.  
  1037.  
  1038.  
  1039.   $ dig any linux.bogus
  1040.   ; <<>> DiG 9.1.3 <<>> any linux.bogus
  1041.   ;; global options:  printcmd
  1042.   ;; Got answer:
  1043.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 55239
  1044.   ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 1, ADDITIONAL: 1
  1045.  
  1046.   ;; QUESTION SECTION:
  1047.   ;linux.bogus.               IN      ANY
  1048.  
  1049.   ;; ANSWER SECTION:
  1050.   linux.bogus.        259200  IN      SOA     ns.linux.bogus. \
  1051.         hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
  1052.   linux.bogus.        259200  IN      NS      ns.linux.bogus.
  1053.   linux.bogus.        259200  IN      MX      20 mail.friend.bogus.
  1054.   linux.bogus.        259200  IN      MX      10 mail.linux.bogus.linux.bogus.
  1055.  
  1056.   ;; AUTHORITY SECTION:
  1057.   linux.bogus.        259200  IN      NS      ns.linux.bogus.
  1058.  
  1059.   ;; ADDITIONAL SECTION:
  1060.   ns.linux.bogus.     259200  IN      A       192.168.196.2
  1061.  
  1062.   ;; Query time: 4 msec
  1063.   ;; SERVER: 127.0.0.1#53(127.0.0.1)
  1064.   ;; WHEN: Sun Dec 23 03:06:45 2001
  1065.   ;; MSG SIZE  rcvd: 184
  1066.  
  1067.  
  1068.  
  1069.   Upon careful examination you will discover a bug.  The line
  1070.  
  1071.  
  1072.  
  1073.        linux.bogus.        259200  IN MX        10 mail.linux.bogus.linux.bogus.
  1074.  
  1075.  
  1076.  
  1077.   is all wrong.  It should be
  1078.  
  1079.  
  1080.  
  1081.        linux.bogus.        259200  IN MX        10 mail.linux.bogus.
  1082.  
  1083.  
  1084.  
  1085.   I deliberately made a mistake so you could learn from it :-) Looking
  1086.   in the zone file we find this line:
  1087.  
  1088.  
  1089.  
  1090.                        MX      10 mail.linux.bogus     ; Primary Mail Exchanger
  1091.  
  1092.  
  1093.  
  1094.   It is missing a period.  Or has a 'linux.bogus' too many.  If a
  1095.   machine name does not end in a period in a zone file the origin is
  1096.   added to its end causing the double linux.bogus.linux.bogus.  So
  1097.   either
  1098.  
  1099.  
  1100.   ______________________________________________________________________
  1101.                   MX      10 mail.linux.bogus.    ; Primary Mail Exchanger
  1102.   ______________________________________________________________________
  1103.  
  1104.  
  1105.  
  1106.   or
  1107.  
  1108.  
  1109.   ______________________________________________________________________
  1110.                   MX      10 mail                 ; Primary Mail Exchanger
  1111.   ______________________________________________________________________
  1112.  
  1113.  
  1114.  
  1115.   is correct.  I prefer the latter form, it's less to type.  There are
  1116.   some BIND experts that disagree, and some that agree with this.  In a
  1117.   zone file the domain should either be written out and ended with a `.'
  1118.   or it should not be included at all, in which case it defaults to the
  1119.   origin.
  1120.  
  1121.  
  1122.   I must stress that in the named.conf file there should not be `.'s
  1123.   after the domain names.  You have no idea how many times a `.' too
  1124.   many or few have fouled up things and confused the h*ll out of people.
  1125.  
  1126.  
  1127.   So having made my point here is the new zone file, with some extra
  1128.   information in it as well:
  1129.  
  1130.  
  1131.  
  1132.   ______________________________________________________________________
  1133.   ;
  1134.   ; Zone file for linux.bogus
  1135.   ;
  1136.   ; The full zone file
  1137.   ;
  1138.   $TTL 3D
  1139.   @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
  1140.                           199802151       ; serial, todays date + todays serial #
  1141.                           8H              ; refresh, seconds
  1142.                           2H              ; retry, seconds
  1143.                           4W              ; expire, seconds
  1144.                           1D )            ; minimum, seconds
  1145.   ;
  1146.                   TXT     "Linux.Bogus, your DNS consultants"
  1147.                   NS      ns              ; Inet Address of name server
  1148.                   NS      ns.friend.bogus.
  1149.                   MX      10 mail         ; Primary Mail Exchanger
  1150.                   MX      20 mail.friend.bogus. ; Secondary Mail Exchanger
  1151.  
  1152.   localhost       A       127.0.0.1
  1153.  
  1154.   gw              A       192.168.196.1
  1155.                   TXT     "The router"
  1156.  
  1157.   ns              A       192.168.196.2
  1158.                   MX      10 mail
  1159.                   MX      20 mail.friend.bogus.
  1160.   www             CNAME   ns
  1161.  
  1162.   donald          A       192.168.196.3
  1163.                   MX      10 mail
  1164.                   MX      20 mail.friend.bogus.
  1165.                   TXT     "DEK"
  1166.  
  1167.   mail            A       192.168.196.4
  1168.                   MX      10 mail
  1169.                   MX      20 mail.friend.bogus.
  1170.  
  1171.   ftp             A       192.168.196.5
  1172.                   MX      10 mail
  1173.                   MX      20 mail.friend.bogus.
  1174.   ______________________________________________________________________
  1175.  
  1176.  
  1177.  
  1178.   CNAME (Canonical NAME) is a way to give each machine several names.
  1179.   So www is an alias for ns.  CNAME record usage is a bit controversial.
  1180.   But it's safe to follow the rule that a MX, CNAME or SOA record should
  1181.   never refer to a CNAME record, they should only refer to something
  1182.   with an A record, so it is inadvisable to have
  1183.  
  1184.  
  1185.   ______________________________________________________________________
  1186.   foobar          CNAME   www                     ; NO!
  1187.   ______________________________________________________________________
  1188.  
  1189.  
  1190.  
  1191.   but correct to have
  1192.  
  1193.  
  1194.  
  1195.   ______________________________________________________________________
  1196.   foobar          CNAME   ns                      ; Yes!
  1197.   ______________________________________________________________________
  1198.  
  1199.  
  1200.  
  1201.   Load the new database by running rndc reload, which causes named to
  1202.   read its files again.
  1203.  
  1204.  
  1205.  
  1206.        $ dig linux.bogus axfr
  1207.  
  1208.        ; <<>> DiG 9.1.3 <<>> linux.bogus axfr
  1209.        ;; global options:  printcmd
  1210.        linux.bogus.            259200  IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
  1211.        linux.bogus.            259200  IN      NS      ns.linux.bogus.
  1212.        linux.bogus.            259200  IN      MX      10 mail.linux.bogus.
  1213.        linux.bogus.            259200  IN      MX      20 mail.friend.bogus.
  1214.        donald.linux.bogus.     259200  IN      A       192.168.196.3
  1215.        donald.linux.bogus.     259200  IN      MX      10 mail.linux.bogus.
  1216.        donald.linux.bogus.     259200  IN      MX      20 mail.friend.bogus.
  1217.        donald.linux.bogus.     259200  IN      TXT     "DEK"
  1218.        ftp.linux.bogus.        259200  IN      A       192.168.196.5
  1219.        ftp.linux.bogus.        259200  IN      MX      10 mail.linux.bogus.
  1220.        ftp.linux.bogus.        259200  IN      MX      20 mail.friend.bogus.
  1221.        gw.linux.bogus.         259200  IN      A       192.168.196.1
  1222.        gw.linux.bogus.         259200  IN      TXT     "The router"
  1223.        localhost.linux.bogus.  259200  IN      A       127.0.0.1
  1224.        mail.linux.bogus.       259200  IN      A       192.168.196.4
  1225.        mail.linux.bogus.       259200  IN      MX      10 mail.linux.bogus.
  1226.        mail.linux.bogus.       259200  IN      MX      20 mail.friend.bogus.
  1227.        ns.linux.bogus.         259200  IN      MX      10 mail.linux.bogus.
  1228.        ns.linux.bogus.         259200  IN      MX      20 mail.friend.bogus.
  1229.        ns.linux.bogus.         259200  IN      A       192.168.196.2
  1230.        www.linux.bogus.        259200  IN      CNAME   ns.linux.bogus.
  1231.        linux.bogus.            259200  IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
  1232.        ;; Query time: 41 msec
  1233.        ;; SERVER: 127.0.0.1#53(127.0.0.1)
  1234.        ;; WHEN: Sun Dec 23 03:12:31 2001
  1235.        ;; XFR size: 23 records
  1236.  
  1237.  
  1238.  
  1239.   That's good.  As you see it looks a bit like the zone file itself.
  1240.   Let's check what it says for www alone:
  1241.  
  1242.  
  1243.  
  1244.   $ dig www.linux.bogus
  1245.  
  1246.   ; <<>> DiG 9.1.3 <<>> www.linux.bogus
  1247.   ;; global options:  printcmd
  1248.   ;; Got answer:
  1249.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 16633
  1250.   ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 1, ADDITIONAL: 0
  1251.  
  1252.   ;; QUESTION SECTION:
  1253.   ;www.linux.bogus.               IN      A
  1254.  
  1255.   ;; ANSWER SECTION:
  1256.   www.linux.bogus.        259200  IN      CNAME   ns.linux.bogus.
  1257.   ns.linux.bogus.         259200  IN      A       192.168.196.2
  1258.  
  1259.   ;; AUTHORITY SECTION:
  1260.   linux.bogus.            259200  IN      NS      ns.linux.bogus.
  1261.  
  1262.   ;; Query time: 5 msec
  1263.   ;; SERVER: 127.0.0.1#53(127.0.0.1)
  1264.   ;; WHEN: Sun Dec 23 03:14:14 2001
  1265.   ;; MSG SIZE  rcvd: 80
  1266.  
  1267.  
  1268.  
  1269.   In other words, the real name of www.linux.bogus is ns.linux.bogus,
  1270.   and it gives you some of the information it has about ns as well,
  1271.   enough to connect to it if you were a program.
  1272.  
  1273.  
  1274.   Now we're halfway.
  1275.  
  1276.  
  1277.   5.3.  The reverse zone
  1278.  
  1279.   Now programs can convert the names in linux.bogus to addresses which
  1280.   they can connect to. But also required is a reverse zone, one making
  1281.   DNS able to convert from an address to a name. This name is used by a
  1282.   lot of servers of different kinds (FTP, IRC, WWW and others) to decide
  1283.   if they want to talk to you or not, and if so, maybe even how much
  1284.   priority you should be given. For full access to all services on the
  1285.   Internet a reverse zone is required.
  1286.  
  1287.  
  1288.   Put this in named.conf:
  1289.  
  1290.  
  1291.   ______________________________________________________________________
  1292.   zone "196.168.192.in-addr.arpa" {
  1293.           type master;
  1294.           notify no;
  1295.           file "pz/192.168.196";
  1296.   };
  1297.   ______________________________________________________________________
  1298.  
  1299.  
  1300.  
  1301.   This is exactly as with the 0.0.127.in-addr.arpa, and the contents are
  1302.   similar:
  1303.  
  1304.  
  1305.  
  1306.   ______________________________________________________________________
  1307.   $TTL 3D
  1308.   @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
  1309.                           199802151 ; Serial, todays date + todays serial
  1310.                           8H      ; Refresh
  1311.                           2H      ; Retry
  1312.                           4W      ; Expire
  1313.                           1D)     ; Minimum TTL
  1314.                   NS      ns.linux.bogus.
  1315.  
  1316.   1               PTR     gw.linux.bogus.
  1317.   2               PTR     ns.linux.bogus.
  1318.   3               PTR     donald.linux.bogus.
  1319.   4               PTR     mail.linux.bogus.
  1320.   5               PTR     ftp.linux.bogus.
  1321.   ______________________________________________________________________
  1322.  
  1323.  
  1324.  
  1325.   Now you reload your named (rndc reload) and examine your work with dig
  1326.   again:
  1327.  
  1328.  
  1329.   ______________________________________________________________________
  1330.   $ dig -x 192.168.196.4
  1331.   ;; Got answer:
  1332.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58451
  1333.   ;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
  1334.  
  1335.   ;; QUESTION SECTION:
  1336.   ;4.196.168.192.in-addr.arpa.    IN      PTR
  1337.  
  1338.   ;; ANSWER SECTION:
  1339.   4.196.168.192.in-addr.arpa. 259200 IN   PTR     mail.linux.bogus.
  1340.  
  1341.   ;; AUTHORITY SECTION:
  1342.   196.168.192.in-addr.arpa. 259200 IN     NS      ns.linux.bogus.
  1343.  
  1344.   ;; ADDITIONAL SECTION:
  1345.   ns.linux.bogus.         259200  IN      A       192.168.196.2
  1346.  
  1347.   ;; Query time: 4 msec
  1348.   ;; SERVER: 127.0.0.1#53(127.0.0.1)
  1349.   ;; WHEN: Sun Dec 23 03:16:05 2001
  1350.   ;; MSG SIZE  rcvd: 107
  1351.   ______________________________________________________________________
  1352.  
  1353.  
  1354.  
  1355.   so, it looks OK, dump the whole thing to examine that too:
  1356.  
  1357.  
  1358.  
  1359.   ______________________________________________________________________
  1360.   $ dig 196.168.192.in-addr.arpa. AXFR
  1361.  
  1362.   ; <<>> DiG 9.1.3 <<>> 196.168.192.in-addr.arpa. AXFR
  1363.   ;; global options:  printcmd
  1364.   196.168.192.in-addr.arpa. 259200 IN     SOA     ns.linux.bogus. \
  1365.           hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
  1366.   196.168.192.in-addr.arpa. 259200 IN     NS      ns.linux.bogus.
  1367.   1.196.168.192.in-addr.arpa. 259200 IN   PTR     gw.linux.bogus.
  1368.   2.196.168.192.in-addr.arpa. 259200 IN   PTR     ns.linux.bogus.
  1369.   3.196.168.192.in-addr.arpa. 259200 IN   PTR     donald.linux.bogus.
  1370.   4.196.168.192.in-addr.arpa. 259200 IN   PTR     mail.linux.bogus.
  1371.   5.196.168.192.in-addr.arpa. 259200 IN   PTR     ftp.linux.bogus.
  1372.   196.168.192.in-addr.arpa. 259200 IN     SOA     ns.linux.bogus. \
  1373.           hostmaster.linux.bogus. 199802151 28800 7200 2419200 86400
  1374.   ;; Query time: 6 msec
  1375.   ;; SERVER: 127.0.0.1#53(127.0.0.1)
  1376.   ;; WHEN: Sun Dec 23 03:16:58 2001
  1377.   ;; XFR size: 9 records
  1378.   ______________________________________________________________________
  1379.  
  1380.  
  1381.  
  1382.   Looks good!  If your output didn't look like that look for error-
  1383.   messages in your syslog, I explained how to do that in the first
  1384.   section under the heading ``Starting named''
  1385.  
  1386.  
  1387.   5.4.  Words of caution
  1388.  
  1389.   There are some things I should add here.  The IP numbers used in the
  1390.   examples above are taken from one of the blocks of 'private nets',
  1391.   i.e., they are not allowed to be used publicly on the Internet.  So
  1392.   they are safe to use in an example in a HOWTO.  The second thing is
  1393.   the notify no; line.  It tells named not to notify its secondary
  1394.   (slave) servers when it has gotten a update to one of its zone files.
  1395.   In BIND 8 and later the named can notify the other servers listed in
  1396.   NS records in the zone file when a zone is updated.  This is handy for
  1397.   ordinary use.  But for private experiments with zones this feature
  1398.   should be off --- we don't want the experiment to pollute the Internet
  1399.   do we?
  1400.  
  1401.  
  1402.   And, of course, this domain is highly bogus, and so are all the
  1403.   addresses in it.  For a real example of a real-life domain see the
  1404.   next main-section.
  1405.  
  1406.  
  1407.   5.5.  Why reverse lookups don't work.
  1408.  
  1409.   There are a couple of ``gotchas'' that normally are avoided with name
  1410.   lookups that are often seen when setting up reverse zones.  Before you
  1411.   go on you need reverse lookups of your machines working on your own
  1412.   nameserver.  If it isn't go back and fix it before continuing.
  1413.  
  1414.  
  1415.   I will discuss two failures of reverse lookups as seen from outside
  1416.   your network:
  1417.  
  1418.  
  1419.   5.5.1.  The reverse zone isn't delegated.
  1420.  
  1421.   When you ask a service provider for a network-address range and a
  1422.   domain name the domain name is normally delegated as a matter of
  1423.   course.  A delegation is the glue NS record that helps you get from
  1424.   one nameserver to another as explained in the dry theory section
  1425.   above.  You read that, right?  If your reverse zone doesn't work go
  1426.   back and read it.  Now.
  1427.  
  1428.  
  1429.   The reverse zone also needs to be delegated.  If you got the
  1430.   192.168.196 net with the linux.bogus domain from your provider they
  1431.   need to put NS records in for your reverse zone as well as for your
  1432.   forward zone.  If you follow the chain from in-addr.arpa and up to
  1433.   your net you will probably find a break in the chain, most probably at
  1434.   your service provider.  Having found the break in the chain contact
  1435.   your service-provider and ask them to correct the error.
  1436.  
  1437.  
  1438.   5.5.2.  You've got a classless subnet
  1439.  
  1440.   This is a somewhat advanced topic, but classless subnets are very
  1441.   common these days and you probably have one if you're a small company.
  1442.  
  1443.  
  1444.   A classless subnet is what keeps the Internet going these days.  Some
  1445.   years ago there was much ado about the shortage of IP numbers.  The
  1446.   smart people in IETF (the Internet Engineering Task Force, they keep
  1447.   the Internet working) stuck their heads together and solved the
  1448.   problem.  At a price.  The price is in part that you'll get less than
  1449.   a ``C'' subnet and some things may break.  Please see Ask Mr. DNS
  1450.   <http://www.acmebw.com/askmrdns/00007.htm> for an good explanation of
  1451.   this and how to handle it.
  1452.  
  1453.  
  1454.   Did you read it?  I'm not going to explain it so please read it.
  1455.  
  1456.  
  1457.   The first part of the problem is that your ISP must understand the
  1458.   technique described by Mr. DNS.  Not all small ISPs have a working
  1459.   understanding of this.  If so you might have to explain to them and be
  1460.   persistent.  But be sure you understand it first ;-).  They will then
  1461.   set up a nice reverse zone at their server which you can examine for
  1462.   correctness with dig.
  1463.  
  1464.  
  1465.   The second and last part of the problem is that you must understand
  1466.   the technique.  If you're unsure go back and read about it again.
  1467.   Then you can set up your own classless reverse zone as described by
  1468.   Mr. DNS.
  1469.  
  1470.  
  1471.   There is another trap lurking here.  (Very) Old resolvers will not be
  1472.   able to follow the CNAME trick in the resolving chain and will fail to
  1473.   reverse-resolve your machine.  This can result in the service
  1474.   assigning it an incorrect access class, deny access or something along
  1475.   those lines.  If you stumble into such a service the only solution
  1476.   (that I know of) is for your ISP to insert your PTR record directly
  1477.   into their trick classless zone file instead of the trick CNAME
  1478.   record.
  1479.  
  1480.  
  1481.   Some ISPs will offer other ways to handle this, like Web based forms
  1482.   for you to input your reverse-mappings in or other automagical
  1483.   systems.
  1484.  
  1485.  
  1486.   5.6.  Slave servers
  1487.  
  1488.   Once you have set up your zones correctly on the master servers you
  1489.   need to set up at least one slave server.  Slave servers are needed
  1490.   for robustness.  If your master goes down the people out there on the
  1491.   net will still be able to get information about your domain from the
  1492.   slave.  A slave should be as long away from you as possible.  Your
  1493.   master and slave should share as few as possible of these: Power
  1494.   supply, LAN, ISP, city and country.  If all of these things are
  1495.   different for your master and slave you've found a really good slave.
  1496.  
  1497.  
  1498.   A slave is simply a nameserver that copies zone files from a master.
  1499.   You set it up like this:
  1500.  
  1501.  
  1502.   ______________________________________________________________________
  1503.   zone "linux.bogus" {
  1504.           type slave;
  1505.           file "sz/linux.bogus";
  1506.           masters { 192.168.196.2; };
  1507.   };
  1508.   ______________________________________________________________________
  1509.  
  1510.  
  1511.  
  1512.   A mechanism called zone-transfer is used to copy the data.  The zone
  1513.   transfer is controlled by your SOA record:
  1514.  
  1515.  
  1516.   ______________________________________________________________________
  1517.   @       IN      SOA     ns.linux.bogus. hostmaster.linux.bogus. (
  1518.                           199802151       ; serial, todays date + todays serial #
  1519.                           8H              ; refresh, seconds
  1520.                           2H              ; retry, seconds
  1521.                           4W              ; expire, seconds
  1522.                           1D )            ; minimum, seconds
  1523.   ______________________________________________________________________
  1524.  
  1525.  
  1526.  
  1527.   A zone is only transferred if the serial number on the master is
  1528.   larger than on the slave.  Every refresh interval the slave will check
  1529.   if the master has been updated.  If the check fails (because the
  1530.   master is unavailable) it will retry the check every retry interval.
  1531.   If it continues to fail as long as the expire interval the slave will
  1532.   remove the zone from it's filesystem and no longer be a server for it.
  1533.  
  1534.  
  1535.  
  1536.   6.  Basic security options.
  1537.  
  1538.   By Jamie Norrish
  1539.  
  1540.  
  1541.   Setting configuration options to reduce the possibility of problems.
  1542.  
  1543.  
  1544.   There are a few simple steps that you can take which will both make
  1545.   your server more secure and potentially reduce its load. The material
  1546.   presented here is nothing more than a starting point; if you are
  1547.   concerned about security (and you should be), please consult other
  1548.   resources on the net (see ``the last chapter'').
  1549.  
  1550.  
  1551.   The following configuration directives occur in named.conf. If a
  1552.   directive occurs in the options section of the file, it applies to all
  1553.   zones listed in that file. If it occurs within a zone entry, it
  1554.   applies only to that zone. A zone entry overrides an options entry.
  1555.  
  1556.  
  1557.   6.1.  Restricting zone transfers
  1558.  
  1559.   In order for your slave server(s) to be able to answer queries about
  1560.   your domain, they must be able to transfer the zone information from
  1561.   your primary server.  Very few others have a need to do so.  Therefore
  1562.   restrict zone transfers using the allow-transfer option, assuming
  1563.   192.168.1.4 is the IP address of ns.friend.bogus and adding yourself
  1564.   for debugging purposes:
  1565.  
  1566.  
  1567.   ______________________________________________________________________
  1568.   zone "linux.bogus" {
  1569.         allow-transfer { 192.168.1.4; localhost; };
  1570.   };
  1571.   ______________________________________________________________________
  1572.  
  1573.  
  1574.  
  1575.   By restricting zone transfers you ensure that the only information
  1576.   available to people is that which they ask for directly - no one can
  1577.   just ask for all the details about your set-up.
  1578.  
  1579.  
  1580.   6.2.  Protecting against spoofing
  1581.  
  1582.   Firstly, disable any queries for domains you don't own, except from
  1583.   your internal/local machines. This not only helps prevent malicious
  1584.   use of your DNS server, but also reduces unnecessary use of your
  1585.   server.
  1586.  
  1587.  
  1588.   ______________________________________________________________________
  1589.   options {
  1590.         allow-query { 192.168.196.0/24; localhost; };
  1591.   };
  1592.  
  1593.   zone "linux.bogus" {
  1594.         allow-query { any; };
  1595.   };
  1596.  
  1597.   zone "196.168.192.in-addr.arpa" {
  1598.         allow-query { any; };
  1599.   };
  1600.   ______________________________________________________________________
  1601.  
  1602.  
  1603.  
  1604.   Further, disable recursive queries except from internal/local sources.
  1605.   This reduces the risk of cache poisoning attacks (where false data is
  1606.   fed to your server).
  1607.  
  1608.  
  1609.   ______________________________________________________________________
  1610.   options {
  1611.           allow-recursion { 192.168.196.0/24; localhost; };
  1612.   };
  1613.   ______________________________________________________________________
  1614.  
  1615.  
  1616.  
  1617.   6.3.  Running named as non-root
  1618.  
  1619.   It is a good idea to run named as a user other than root, so that if
  1620.   it is compromised the privileges gained by the cracker are as limited
  1621.   as possible. You first have to create a user for named to run under,
  1622.   and then modify whatever init script you use that starts named. Pass
  1623.   the new user name and group to named using the -u and -g flags.
  1624.  
  1625.  
  1626.   For example, in Debian GNU/Linux 2.2 you might modify your
  1627.   /etc/init.d/bind script to have the following line (where user named
  1628.   have been created):
  1629.  
  1630.  
  1631.   ______________________________________________________________________
  1632.   start-stop-daemon --start --quiet --exec /usr/sbin/named -- -u named
  1633.   ______________________________________________________________________
  1634.  
  1635.  
  1636.  
  1637.   The same can be done with Red Hat and the other distributions.
  1638.  
  1639.  
  1640.   Dave Lugo has described a secure dual chroot setup
  1641.   <http://www.etherboy.com/dns/chrootdns.html> which you may find
  1642.   interesting to read, it makes the host your run your named on even
  1643.   more secure.
  1644.  
  1645.  
  1646.   7.  A real domain example
  1647.  
  1648.   Where we list some real zone files
  1649.  
  1650.  
  1651.   Users have suggested that I include a real example of a working domain
  1652.   as well as the tutorial example.
  1653.  
  1654.  
  1655.   I use this example with permission from David Bullock of LAND-5.
  1656.   These files were current 24th of September 1996, and were then edited
  1657.   to fit BIND 8 restrictions and use extensions by me.  So, what you see
  1658.   here differs a bit from what you find if you query LAND-5's name
  1659.   servers now.
  1660.  
  1661.  
  1662.   7.1.  /etc/named.conf (or /var/named/named.conf)
  1663.  
  1664.   Here we find master zone sections for the two reverse zones needed:
  1665.   the 127.0.0 net, as well as LAND-5's 206.6.177 subnet, and a primary
  1666.   line for land-5's forward zone land-5.com. Also note that instead of
  1667.   stuffing the files in a directory called pz, as I do in this HOWTO, he
  1668.   puts them in a directory called zone.
  1669.  
  1670.  
  1671.  
  1672.   ______________________________________________________________________
  1673.   // Boot file for LAND-5 name server
  1674.  
  1675.   options {
  1676.           directory "/var/named";
  1677.   };
  1678.  
  1679.   controls {
  1680.           inet 127.0.0.1 allow { localhost; } keys { rndc_key; };
  1681.   };
  1682.  
  1683.   key "rndc_key" {
  1684.           algorithm hmac-md5;
  1685.           secret "c3Ryb25nIGVub3VnaCBmb3IgYSBtYW4gYnV0IG1hZGUgZm9yIGEgd29tYW4K";
  1686.   };
  1687.  
  1688.   zone "." {
  1689.           type hint;
  1690.           file "root.hints";
  1691.   };
  1692.  
  1693.   zone "0.0.127.in-addr.arpa" {
  1694.           type master;
  1695.           file "zone/127.0.0";
  1696.   };
  1697.  
  1698.   zone "land-5.com" {
  1699.           type master;
  1700.           file "zone/land-5.com";
  1701.   };
  1702.  
  1703.   zone "177.6.206.in-addr.arpa" {
  1704.           type master;
  1705.           file "zone/206.6.177";
  1706.   };
  1707.   ______________________________________________________________________
  1708.  
  1709.  
  1710.  
  1711.   If you put this in your named.conf file to play with PLEASE put
  1712.   ``notify no;'' in the zone sections for the two land-5 zones so as to
  1713.   avoid accidents.
  1714.  
  1715.  
  1716.   7.2.  /var/named/root.hints
  1717.  
  1718.   Keep in mind that this file is dynamic, and the one listed here is
  1719.   old.  You're better off using a new one as explained earlier.
  1720.  
  1721.  
  1722.  
  1723.   ______________________________________________________________________
  1724.   ; <<>> DiG 8.1 <<>> @A.ROOT-SERVERS.NET.
  1725.   ; (1 server found)
  1726.   ;; res options: init recurs defnam dnsrch
  1727.   ;; got answer:
  1728.   ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10
  1729.   ;; flags: qr aa rd; QUERY: 1, ANSWER: 13, AUTHORITY: 0, ADDITIONAL: 13
  1730.   ;; QUERY SECTION:
  1731.   ;;      ., type = NS, class = IN
  1732.  
  1733.   ;; ANSWER SECTION:
  1734.   .                     6D IN NS        G.ROOT-SERVERS.NET.
  1735.   .                     6D IN NS        J.ROOT-SERVERS.NET.
  1736.   .                     6D IN NS        K.ROOT-SERVERS.NET.
  1737.   .                     6D IN NS        L.ROOT-SERVERS.NET.
  1738.   .                     6D IN NS        M.ROOT-SERVERS.NET.
  1739.   .                     6D IN NS        A.ROOT-SERVERS.NET.
  1740.   .                     6D IN NS        H.ROOT-SERVERS.NET.
  1741.   .                     6D IN NS        B.ROOT-SERVERS.NET.
  1742.   .                     6D IN NS        C.ROOT-SERVERS.NET.
  1743.   .                     6D IN NS        D.ROOT-SERVERS.NET.
  1744.   .                     6D IN NS        E.ROOT-SERVERS.NET.
  1745.   .                     6D IN NS        I.ROOT-SERVERS.NET.
  1746.   .                     6D IN NS        F.ROOT-SERVERS.NET.
  1747.  
  1748.   ;; ADDITIONAL SECTION:
  1749.   G.ROOT-SERVERS.NET.     5w6d16h IN A    192.112.36.4
  1750.   J.ROOT-SERVERS.NET.     5w6d16h IN A    198.41.0.10
  1751.   K.ROOT-SERVERS.NET.     5w6d16h IN A    193.0.14.129
  1752.   L.ROOT-SERVERS.NET.     5w6d16h IN A    198.32.64.12
  1753.   M.ROOT-SERVERS.NET.     5w6d16h IN A    202.12.27.33
  1754.   A.ROOT-SERVERS.NET.     5w6d16h IN A    198.41.0.4
  1755.   H.ROOT-SERVERS.NET.     5w6d16h IN A    128.63.2.53
  1756.   B.ROOT-SERVERS.NET.     5w6d16h IN A    128.9.0.107
  1757.   C.ROOT-SERVERS.NET.     5w6d16h IN A    192.33.4.12
  1758.   D.ROOT-SERVERS.NET.     5w6d16h IN A    128.8.10.90
  1759.   E.ROOT-SERVERS.NET.     5w6d16h IN A    192.203.230.10
  1760.   I.ROOT-SERVERS.NET.     5w6d16h IN A    192.36.148.17
  1761.   F.ROOT-SERVERS.NET.     5w6d16h IN A    192.5.5.241
  1762.  
  1763.   ;; Total query time: 215 msec
  1764.   ;; FROM: roke.uio.no to SERVER: A.ROOT-SERVERS.NET.  198.41.0.4
  1765.   ;; WHEN: Sun Feb 15 01:22:51 1998
  1766.   ;; MSG SIZE  sent: 17  rcvd: 436
  1767.   ______________________________________________________________________
  1768.  
  1769.  
  1770.  
  1771.   7.3.  /var/named/zone/127.0.0
  1772.  
  1773.   Just the basics, the obligatory SOA record, and a record that maps
  1774.   127.0.0.1 to localhost.  Both are required.  No more should be in this
  1775.   file.  It will probably never need to be updated, unless your
  1776.   nameserver or hostmaster address changes.
  1777.  
  1778.  
  1779.  
  1780.   ______________________________________________________________________
  1781.   $TTL 3D
  1782.   @               IN      SOA     land-5.com. root.land-5.com. (
  1783.                                   199609203       ; Serial
  1784.                                   28800   ; Refresh
  1785.                                   7200    ; Retry
  1786.                                   604800  ; Expire
  1787.                                   86400)  ; Minimum TTL
  1788.                           NS      land-5.com.
  1789.  
  1790.   1                       PTR     localhost.
  1791.   ______________________________________________________________________
  1792.  
  1793.  
  1794.  
  1795.   If you look at a random BIND installation you will probably find that
  1796.   the $TTL line is missing as it is here.  It was not used before, and
  1797.   only version 8.2 of BIND has started to warn about its absence.  BIND
  1798.   9 requires the $TTL.
  1799.  
  1800.  
  1801.   7.4.  /var/named/zone/land-5.com
  1802.  
  1803.   Here we see the mandatory SOA record, the needed NS records.  We can
  1804.   see that he has a secondary name server at ns2.psi.net.  This is as it
  1805.   should be, always have a off site secondary server as backup.  We can
  1806.   also see that he has a master host called land-5 which takes care of
  1807.   many of the different Internet services, and that he's done it with
  1808.   CNAMEs (a alternative is using A records).
  1809.  
  1810.  
  1811.   As you see from the SOA record, the zone file originates at
  1812.   land-5.com, the contact person is root@land-5.com. hostmaster is
  1813.   another oft used address for the contact person.  The serial number is
  1814.   in the customary yyyymmdd format with todays serial number appended;
  1815.   this is probably the sixth version of zone file on the 20th of
  1816.   September 1996.  Remember that the serial number must increase
  1817.   monotonically, here there is only one digit for todays serial#, so
  1818.   after 9 edits he has to wait until tomorrow before he can edit the
  1819.   file again.  Consider using two digits.
  1820.  
  1821.  
  1822.  
  1823.   ______________________________________________________________________
  1824.   $TTL 3D
  1825.   @       IN      SOA     land-5.com. root.land-5.com. (
  1826.                           199609206       ; serial, todays date + todays serial #
  1827.                           8H              ; refresh, seconds
  1828.                           2H              ; retry, seconds
  1829.                           4W              ; expire, seconds
  1830.                           1D )            ; minimum, seconds
  1831.                   NS      land-5.com.
  1832.                   NS      ns2.psi.net.
  1833.                   MX      10 land-5.com.  ; Primary Mail Exchanger
  1834.                   TXT     "LAND-5 Corporation"
  1835.  
  1836.   localhost       A       127.0.0.1
  1837.  
  1838.   router          A       206.6.177.1
  1839.  
  1840.   land-5.com.     A       206.6.177.2
  1841.   ns              A       206.6.177.3
  1842.   www             A       207.159.141.192
  1843.  
  1844.   ftp             CNAME   land-5.com.
  1845.   mail            CNAME   land-5.com.
  1846.   news            CNAME   land-5.com.
  1847.  
  1848.   funn            A       206.6.177.2
  1849.  
  1850.   ;
  1851.   ;       Workstations
  1852.   ;
  1853.   ws-177200       A       206.6.177.200
  1854.                   MX      10 land-5.com.   ; Primary Mail Host
  1855.   ws-177201       A       206.6.177.201
  1856.                   MX      10 land-5.com.   ; Primary Mail Host
  1857.   ws-177202       A       206.6.177.202
  1858.                   MX      10 land-5.com.   ; Primary Mail Host
  1859.   ws-177203       A       206.6.177.203
  1860.                   MX      10 land-5.com.   ; Primary Mail Host
  1861.   ws-177204       A       206.6.177.204
  1862.                   MX      10 land-5.com.   ; Primary Mail Host
  1863.   ws-177205       A       206.6.177.205
  1864.                   MX      10 land-5.com.   ; Primary Mail Host
  1865.   ; {Many repetitive definitions deleted - SNIP}
  1866.   ws-177250       A       206.6.177.250
  1867.                   MX      10 land-5.com.   ; Primary Mail Host
  1868.   ws-177251       A       206.6.177.251
  1869.                   MX      10 land-5.com.   ; Primary Mail Host
  1870.   ws-177252       A       206.6.177.252
  1871.                   MX      10 land-5.com.   ; Primary Mail Host
  1872.   ws-177253       A       206.6.177.253
  1873.                   MX      10 land-5.com.   ; Primary Mail Host
  1874.   ws-177254       A       206.6.177.254
  1875.                   MX      10 land-5.com.   ; Primary Mail Host
  1876.   ______________________________________________________________________
  1877.  
  1878.  
  1879.  
  1880.   If you examine land-5s nameserver you will find that the host names
  1881.   are of the form ws_number.  As of late BIND 4 versions named started
  1882.   enforcing the restrictions on what characters may be used in host
  1883.   names.  So that does not work with BIND 8 at all, and I substituted
  1884.   '-' (dash) for '_' (underline) for use in this HOWTO.  But, as
  1885.   mentioned earlier, BIND 9 no longer enforces this restriction.
  1886.  
  1887.  
  1888.   Another thing to note is that the workstations don't have individual
  1889.   names, but rather a prefix followed by the two last parts of the IP
  1890.   numbers.  Using such a convention can simplify maintenance
  1891.   significantly, but can be a bit impersonal, and, in fact, be a source
  1892.   of irritation among your customers.
  1893.  
  1894.  
  1895.   We also see that funn.land-5.com is an alias for land-5.com, but using
  1896.   an A record, not a CNAME record.
  1897.  
  1898.  
  1899.   7.5.  /var/named/zone/206.6.177
  1900.  
  1901.   I'll comment on this file below
  1902.  
  1903.  
  1904.   ______________________________________________________________________
  1905.   $TTL 3D
  1906.   @               IN      SOA     land-5.com. root.land-5.com. (
  1907.                                   199609206       ; Serial
  1908.                                   28800   ; Refresh
  1909.                                   7200    ; Retry
  1910.                                   604800  ; Expire
  1911.                                   86400)  ; Minimum TTL
  1912.                           NS      land-5.com.
  1913.                           NS      ns2.psi.net.
  1914.   ;
  1915.   ;       Servers
  1916.   ;
  1917.   1       PTR     router.land-5.com.
  1918.   2       PTR     land-5.com.
  1919.   2       PTR     funn.land-5.com.
  1920.   ;
  1921.   ;       Workstations
  1922.   ;
  1923.   200     PTR     ws-177200.land-5.com.
  1924.   201     PTR     ws-177201.land-5.com.
  1925.   202     PTR     ws-177202.land-5.com.
  1926.   203     PTR     ws-177203.land-5.com.
  1927.   204     PTR     ws-177204.land-5.com.
  1928.   205     PTR     ws-177205.land-5.com.
  1929.   ; {Many repetitive definitions deleted - SNIP}
  1930.   250     PTR     ws-177250.land-5.com.
  1931.   251     PTR     ws-177251.land-5.com.
  1932.   252     PTR     ws-177252.land-5.com.
  1933.   253     PTR     ws-177253.land-5.com.
  1934.   254     PTR     ws-177254.land-5.com.
  1935.   ______________________________________________________________________
  1936.  
  1937.  
  1938.  
  1939.   The reverse zone is the bit of the setup that seems to cause the most
  1940.   grief.  It is used to find the host name if you have the IP number of
  1941.   a machine.  Example: you are an FTP server and accept connections from
  1942.   FTP clients.  As you are a Norwegian FTP server you want to accept
  1943.   more connections from clients in Norway and other Scandinavian
  1944.   countries and less from the rest of the world.  When you get a
  1945.   connection from a client the C library is able to tell you the IP
  1946.   number of the connecting machine because the IP number of the client
  1947.   is contained in all the packets that are passed over the network.  Now
  1948.   you can call a function called gethostbyaddr that looks up the name of
  1949.   a host given the IP number.  Gethostbyaddr will ask a DNS server,
  1950.   which will then traverse the DNS looking for the machine.  Supposing
  1951.   the client connection is from ws-177200.land-5.com.  The IP number the
  1952.   C library provides to the FTP server is 206.6.177.200.  To find out
  1953.   the name of that machine we need to find 200.177.6.206.in-addr.arpa.
  1954.   The DNS server will first find the arpa. servers, then find in-
  1955.   addr.arpa. servers, following the reverse trail through 206, then 6
  1956.   and at last finding the server for the 177.6.206.in-addr.arpa zone at
  1957.   LAND-5.  From which it will finally get the answer that for
  1958.   200.177.6.206.in-addr.arpa we have a ``PTR ws-177200.land-5.com''
  1959.   record, meaning that the name that goes with 206.6.177.200 is
  1960.   ws-177200.land-5.com.
  1961.  
  1962.  
  1963.   The FTP server prioritizes connections from the Scandinavian
  1964.   countries, i.e., *.no, *.se, *.dk, the name ws-177200.land-5.com
  1965.   clearly does not match any of those, and the server will put the
  1966.   connection in a connection class with less bandwidth and fewer clients
  1967.   allowed.  If there was no reverse mapping of 206.2.177.200 through the
  1968.   in-addr.arpa zone the server would have been unable to find the name
  1969.   at all and would have to settle to comparing 206.2.177.200 with *.no,
  1970.   *.se and *.dk, none of which will match at all, it may even deny the
  1971.   connection for lack of classification.
  1972.  
  1973.  
  1974.   Some people will tell you that reverse lookup mappings are only
  1975.   important for servers, or not important at all.  Not so: Many ftp,
  1976.   news, IRC and even some http (WWW) servers will not accept connections
  1977.   from machines of which they are not able to find the name.  So reverse
  1978.   mappings for machines are in fact mandatory.
  1979.  
  1980.  
  1981.   8.  Maintenance
  1982.  
  1983.   Keeping it working.
  1984.  
  1985.  
  1986.   There is one maintenance task you have to do on nameds, other than
  1987.   keeping them running.  That's keeping the root.hints file updated.
  1988.   The easiest way is using dig. First run dig with no arguments you will
  1989.   get the root.hints according to your own server.  Then ask one of the
  1990.   listed root servers with dig @rootserver.  You will note that the
  1991.   output looks terribly like a root.hints file.  Save it to a file (dig
  1992.   @e.root-servers.net . ns >root.hints.new) and replace the old
  1993.   root.hints with it.
  1994.  
  1995.  
  1996.   Remember to reload named after replacing the cache file.
  1997.  
  1998.  
  1999.   Al Longyear sent me this script that can be run automatically to
  2000.   update root.hints.  Install a crontab entry to run it once a month and
  2001.   forget it.  The script assumes you have mail working and that the
  2002.   mail-alias `hostmaster' is defined.  You must hack it to suit your
  2003.   setup.
  2004.  
  2005.  
  2006.  
  2007.   ______________________________________________________________________
  2008.   #!/bin/sh
  2009.   #
  2010.   # Update the nameserver cache information file once per month.
  2011.   # This is run automatically by a cron entry.
  2012.   #
  2013.   # Original by Al Longyear
  2014.   # Updated for BIND 8 by Nicolai Langfeldt
  2015.   # Miscelanious error-conditions reported by David A. Ranch
  2016.   # Ping test suggested by Martin Foster
  2017.   # named up-test suggested by Erik Bryer.
  2018.   #
  2019.   (
  2020.    echo "To: hostmaster <hostmaster>"
  2021.    echo "From: system <root>"
  2022.  
  2023.    # Is named up? Check the status of named.
  2024.    case `rndc status 2>&1` in
  2025.       *refused*)
  2026.           echo "named is DOWN. root.hints was NOT updated"
  2027.           echo
  2028.           exit 0
  2029.           ;;
  2030.    esac
  2031.  
  2032.    PATH=/sbin:/usr/sbin:/bin:/usr/bin:
  2033.    export PATH
  2034.    # NOTE: /var/named must be writable only by trusted users or this script
  2035.    # will cause root compromise/denial of service opportunities.
  2036.    cd /var/named 2>/dev/null || {
  2037.       echo "Subject: Cannot cd to /var/named, error $?"
  2038.       echo
  2039.       echo "The subject says it all"
  2040.       exit 1
  2041.    }
  2042.  
  2043.    # Are we online?  Ping a server at your ISP
  2044.    case `ping -qnc 1 some.machine.net 2>&1` in
  2045.      *'100% packet loss'*)
  2046.           echo "Subject: root.hints NOT updated.  The network is DOWN."
  2047.           echo
  2048.           echo "The subject says it all"
  2049.           exit 1
  2050.           ;;
  2051.    esac
  2052.  
  2053.    dig @e.root-servers.net . ns >root.hints.new 2> errors
  2054.  
  2055.    case `cat root.hints.new` in
  2056.      *NOERROR*)
  2057.           # It worked
  2058.           :;;
  2059.      *)
  2060.           echo "Subject: The root.hints file update has FAILED."
  2061.           echo
  2062.           echo "The root.hints update has failed"
  2063.           echo "This is the dig output reported:"
  2064.           echo
  2065.           cat root.hints.new errors
  2066.           exit 1
  2067.           ;;
  2068.    esac
  2069.  
  2070.    echo "Subject: The root.hints file has been updated"
  2071.    echo
  2072.    echo "The root.hints file has been updated to contain the following
  2073.   information:"
  2074.    echo
  2075.    cat root.hints.new
  2076.  
  2077.    chown root.root root.hints.new
  2078.    chmod 444 root.hints.new
  2079.    rm -f root.hints.old errors
  2080.    mv root.hints root.hints.old
  2081.    mv root.hints.new root.hints
  2082.    rndc restart
  2083.    echo
  2084.    echo "The nameserver has been restarted to ensure that the update is complete."
  2085.    echo "The previous root.hints file is now called
  2086.   /var/named/root.hints.old."
  2087.   ) 2>&1 | /usr/lib/sendmail -t
  2088.   exit 0
  2089.   ______________________________________________________________________
  2090.  
  2091.  
  2092.  
  2093.   Some of you might have picked up that the root.hints file is also
  2094.   available by ftp from Internic.  Please don't use ftp to update
  2095.   root.hints, the above method is much more friendly to the net, and
  2096.   Internic.
  2097.  
  2098.  
  2099.   9.  Migrating to BIND 9
  2100.  
  2101.   The BIND 9 distribution, and the prepackaged versions too, contains a
  2102.   document called migration that contains notes about how to migrate
  2103.   from BIND 8 to BIND 9.  The document is very straight forward.  If you
  2104.   installed binary packages it's likely stored in /usr/share/doc/bind*
  2105.   or /usr/doc/bind* somewhere.
  2106.  
  2107.  
  2108.   If you're running BIND 4, you may find a document called
  2109.   migration-4to9 in the same place.
  2110.  
  2111.  
  2112.   10.  Questions and Answers
  2113.  
  2114.   Please read this section before mailing me.
  2115.  
  2116.  
  2117.   1. My named wants a named.boot file
  2118.  
  2119.  
  2120.      You are reading the wrong HOWTO.  Please see the old version of
  2121.      this HOWTO, which covers BIND 4, at  <http://langfeldt.net/DNS-
  2122.      HOWTO/>
  2123.  
  2124.  
  2125.   2. How do use DNS from inside a firewall?
  2126.  
  2127.  
  2128.      A hint: forward only;.  You might also need
  2129.  
  2130.  
  2131.      ___________________________________________________________________
  2132.        query-source port 53;
  2133.  
  2134.      ___________________________________________________________________
  2135.  
  2136.  
  2137.  
  2138.   inside the ``options'' part of the named.conf file as suggested in the
  2139.   example ``caching'' section.
  2140.  
  2141.  
  2142.   3. How do I make DNS rotate through the available addresses for a
  2143.      service, say www.busy.site to obtain a load balancing effect, or
  2144.      similar?
  2145.  
  2146.  
  2147.      Make several A records for www.busy.site and use BIND 4.9.3 or
  2148.      later.  Then BIND will round-robin the answers.  It will not work
  2149.      with earlier versions of BIND.
  2150.  
  2151.  
  2152.   4. I want to set up DNS on a (closed) intranet.  What do I do?
  2153.  
  2154.  
  2155.      You drop the root.hints file and just do zone files.  That also
  2156.      means you don't have to get new hint files all the time.
  2157.  
  2158.  
  2159.   5. How do I set up a secondary (slave) name server?
  2160.  
  2161.  
  2162.      If the primary/master server has address 127.0.0.1 you put a line
  2163.      like this in the named.conf file of your secondary:
  2164.  
  2165.  
  2166.      ___________________________________________________________________
  2167.        zone "linux.bogus" {
  2168.              type slave;
  2169.              file "sz/linux.bogus";
  2170.              masters { 127.0.0.1; };
  2171.        };
  2172.  
  2173.      ___________________________________________________________________
  2174.  
  2175.  
  2176.  
  2177.   You may list several alternate master servers the zone can be copied
  2178.   from inside the masters list, separated by ';' (semicolon).
  2179.  
  2180.  
  2181.   6. I want BIND running when I'm disconnected from the net.
  2182.  
  2183.  
  2184.      There are four items regarding this:
  2185.  
  2186.  
  2187.   ·  Specific to BIND 8/9, Adam L Rice has sent me this e-mail, about
  2188.      how to run DNS painlessly on a dialup machine:
  2189.  
  2190.  
  2191.  
  2192.   I have discovered with newer versions of BIND that this
  2193.   [<em/shuffeling files, -ed/] is no longer necessary.  There is a
  2194.   "forward" directive in addition to the "forwarders" directive that
  2195.   controls how they are used.  The default setting is "forward first",
  2196.   which first asks each of the forwarders, and then tries the normal
  2197.   approach of doing the legwork itself if that fails.  This gives the
  2198.   familiar behaviour of gethostbyname() taking an inordinately long time
  2199.   when the link is not up.  But if "forward only" is set, then BIND
  2200.   gives up when it doesn't get a response from the forwarders, and
  2201.   gethostbyname() returns immediately.  Hence there is no need to
  2202.   perform sleight-of-hand with files in /etc and restart the server.
  2203.  
  2204.   In my case, I just added the lines
  2205.  
  2206.   forward only;
  2207.   forwarders { 193.133.58.5; };
  2208.  
  2209.   to the options { } section of my named.conf file. It works very
  2210.   nicely. The only disadvantage of this is that it reduces an incredibly
  2211.   sophisticated piece of DNS software to the status of a dumb cache. To
  2212.   some extent, I would just like to run a dumb cache for DNS instead,
  2213.   but there doesn't seem to be such a piece of software available for
  2214.   Linux.
  2215.  
  2216.  
  2217.  
  2218.   ·  I have received this mail from Ian Clark <ic@deakin.edu.au> where
  2219.      he explains his way of doing this:
  2220.  
  2221.  
  2222.  
  2223.        I run named on my 'Masquerading' machine here. I have
  2224.        two root.hints files, one called root.hints.real which contains
  2225.        the real root server names and the other called root.hints.fake
  2226.        which contains...
  2227.  
  2228.        ----
  2229.        ; root.hints.fake
  2230.        ; this file contains no information
  2231.        ----
  2232.  
  2233.        When I go off line I copy the root.hints.fake file to root.hints and
  2234.        restart named.
  2235.  
  2236.        When I go online I copy root.hints.real to root.hints and restart
  2237.        named.
  2238.  
  2239.        This is done from ip-down & ip-up respectively.
  2240.  
  2241.        The first time I do a query off line on a domain name named doesn't
  2242.        have details for it puts an entry like this in messages..
  2243.  
  2244.        Jan 28 20:10:11 hazchem named[10147]: No root nameserver for class IN
  2245.  
  2246.        which I can live with.
  2247.  
  2248.        It certainly seems to work for me. I can use the nameserver for
  2249.        local machines while off the 'net without the timeout delay for
  2250.        external domain names and I while on the 'net queries for external
  2251.        domains work normally
  2252.  
  2253.  
  2254.  
  2255.   Peter Denison thought that Ian does not go far enough though.  He
  2256.   writes:
  2257.  
  2258.  
  2259.  
  2260.        When connected) serve all cached (and local network) entries immediately
  2261.                        for non-cached entries, forward to my ISPs nameserver
  2262.        When off-line)  serve local network queries immediately
  2263.                        fail all other queries **immediately**
  2264.  
  2265.        The combination of changing the root cache file and forwarding queries
  2266.        doesn't work.
  2267.  
  2268.        So, I've set up (with some discussion of this on the local LUG) two nameds
  2269.        as follows:
  2270.  
  2271.        named-online:   forwards to ISPs nameserver
  2272.                        master for localnet zone
  2273.                        master for localnet reverse zone (1.168.192.in-addr.arpa)
  2274.                        master for 0.0.127.in-addr.arpa
  2275.                        listens on port 60053
  2276.  
  2277.        named-offline:  no forwarding
  2278.                        "fake" root cache file
  2279.                        slave for 3 local zones (master is 127.0.0.1:60053)
  2280.                        listens on port 61053
  2281.  
  2282.        And combined this with port forwarding, to send port 53 to 61053 when
  2283.        off-line, and to port 60053 when online. (I'm using the new netfilter
  2284.        package under 2.3.18, but the old (ipchains) mechanism should work.)
  2285.  
  2286.        Note that this won't quite work out-of-the-box, as there's a slight bug in
  2287.        BIND 8.2, which I have logged wth the developers, preventing a slave
  2288.        having a master on the same IP address (even if a different port). It's a
  2289.        trivial patch, and should go in soon I hope.
  2290.  
  2291.  
  2292.  
  2293.   ·  I have also received information about how BIND interacts with NFS
  2294.      and the portmapper on a mostly offline machine from Karl-Max
  2295.      Wanger:
  2296.  
  2297.  
  2298.  
  2299.   I use to run my own named on all my machines which are only
  2300.   occasionally connected to the Internet by modem. The nameserver only
  2301.   acts as a cache, it has no area of authority and asks back for
  2302.   everything at the name servers in the root.cache file. As is usual
  2303.   with Slackware, it is started before nfsd and mountd.
  2304.  
  2305.   With one of my machines (a Libretto 30 notebook) I had the problem
  2306.   that sometimes I could mount it from another system connected to my
  2307.   local LAN, but most of the time it didn't work.  I had the same effect
  2308.   regardless of using PLIP, a PCMCIA ethernet card or PPP over a serial
  2309.   interface.
  2310.  
  2311.   After some time of guessing and experimenting I found out that
  2312.   apparently named messed with the process of registration nfsd and
  2313.   mountd have to carry out with the portmapper upon startup (I start
  2314.   these daemons at boot time as usual). Starting named after nfsd and
  2315.   mountd eliminated this problem completely.
  2316.  
  2317.   As there are no disadvantages to expect from such a modified boot
  2318.   sequence I'd advise everybody to do it that way to prevent potential
  2319.   trouble.
  2320.  
  2321.  
  2322.  
  2323.   7. Where does the caching name server store its cache? Is there any
  2324.      way I can control the size of the cache?
  2325.  
  2326.  
  2327.      The cache is completely stored in memory, it is not written to disk
  2328.      at any time.  Every time you kill named the cache is lost.  The
  2329.      cache is not controllable in any way.  named manages it according
  2330.      to some simple rules and that is it.  You cannot control the cache
  2331.      or the cache size in any way for any reason. If you want to you can
  2332.      ``fix'' this by hacking named.  This is however not recommended.
  2333.  
  2334.  
  2335.   8. Does named save the cache between restarts?  Can I make it save it?
  2336.  
  2337.  
  2338.      No, named does not save the cache when it dies.  That means that
  2339.      the cache must be built anew each time you kill and restart named.
  2340.      There is no way to make named save the cache in a file.  If you
  2341.      want you can ``fix'' this by hacking named.  This is however not
  2342.      recommended.
  2343.  
  2344.  
  2345.   9. How can I get a domain? I want to set up my own domain called (for
  2346.      example) linux-rules.net.  How can I get the domain I want assigned
  2347.      to me?
  2348.  
  2349.  
  2350.      Please contact your network service provider.  They will be able to
  2351.      help you with this.  Please note that in most parts of the world
  2352.      you need to pay money to get a domain.
  2353.  
  2354.  
  2355.   10.
  2356.      How can I secure my DNS server?  How do I set up split DNS?
  2357.  
  2358.  
  2359.      Both of these are advanced topics.  They are both covered in
  2360.      <http://www.etherboy.com/dns/chrootdns.html>.  I will not explain
  2361.      the topics further here.
  2362.   11.  How to become a bigger time DNS admin.
  2363.  
  2364.   Documentation and tools.
  2365.  
  2366.  
  2367.   Real Documentation exists.  Online and in print.  The reading of
  2368.   several of these is required to make the step from small time DNS
  2369.   admin to a big time one.
  2370.  
  2371.  
  2372.   I have written The Concise Guide to DNS and BIND (by Nicolai
  2373.   Langfeldt, me), published by Que (ISBN 0-7897-2273-9).  The book is
  2374.   much like this HOWTO, just more details, and a lot more of everything.
  2375.   It has also been translated to Polish and published as DNS i BIND by
  2376.   Helion ( <http://helion.pl/ksiazki/dnsbin.htm>, ISBN 83-7197-446-9).
  2377.   Now in 4th edition is DNS and BIND by Cricket Liu and P. Albitz from
  2378.   O'Reilly & Associates (ISBN 0-937175-82-X, affectionately known as the
  2379.   Cricket book).  Another book is Linux DNS Server Administration, by
  2380.   Craig Hunt, published by Sybex (ISBN 0782127363), I have not read it
  2381.   yet.  Another must for good DNS administration (or good anything for
  2382.   that matter) is Zen and the Art of Motorcycle Maintenance by Robert M.
  2383.   Pirsig.
  2384.  
  2385.  
  2386.   Online you will find my book, along with tons of other books,
  2387.   available electronically as a subscription service at
  2388.   <http://safari.informit.com/>.  There is stuff on
  2389.   <http://www.dns.net/dnsrd/> (DNS Resources Directory),
  2390.   <http://www.isc.org/bind.html>; A FAQ, a reference manual (the ARM
  2391.   should be enclosed in the BIND distribution as well) as well as papers
  2392.   and protocol definitions and DNS hacks (these, and most, if not all,
  2393.   of the RFCs mentioned below, are also contained in the BIND
  2394.   distribution).  I have not read most of these.  The newsgroup
  2395.   <news:comp.protocols.tcp-ip.domains> is about DNS.  In addition there
  2396.   are a number of RFCs about DNS, the most important are probably the
  2397.   ones listed here.  Those that have BCP (Best Current Practice) numbers
  2398.   are highly recommended.
  2399.  
  2400.  
  2401.  
  2402.      RFC 2671
  2403.         P. Vixie, Extension Mechanisms for DNS (EDNS0) August 1999.
  2404.  
  2405.  
  2406.      RFC 2317
  2407.         BCP 20, H. Eidnes et. al. Classless IN-ADDR.ARPA delegation,
  2408.         March 1998. This is about CIDR, or classless subnet reverse
  2409.         lookups.
  2410.  
  2411.  
  2412.      RFC 2308
  2413.         M. Andrews, Negative Caching of DNS Queries, March 1998.  About
  2414.         negative caching and the $TTL zone file directive.
  2415.  
  2416.  
  2417.      RFC 2219
  2418.         BCP 17, M. Hamilton and R. Wright, Use of DNS Aliases for
  2419.         Network Services, October 1997.  About CNAME usage.
  2420.  
  2421.  
  2422.      RFC 2182
  2423.         BCP 16, R. Elz et. al., Selection and Operation of Secondary DNS
  2424.         Servers, July 1997.
  2425.  
  2426.  
  2427.  
  2428.      RFC 2052
  2429.         A. Gulbrandsen, P. Vixie, A DNS RR for specifying the location
  2430.         of services (DNS SRV), October 1996
  2431.  
  2432.  
  2433.      RFC 1918
  2434.         Y. Rekhter, R. Moskowitz, D. Karrenberg, G. de Groot, E. Lear,
  2435.         Address Allocation for Private Internets, 02/29/1996.
  2436.  
  2437.  
  2438.      RFC 1912
  2439.         D. Barr, Common DNS Operational and Configuration Errors,
  2440.         02/28/1996.
  2441.  
  2442.  
  2443.      RFC 1912 Errors
  2444.         B. Barr Errors in RFC 1912.  Only available at
  2445.         <http://www.cis.ohio-state.edu/~barr/rfc1912-errors.html>
  2446.  
  2447.  
  2448.      RFC 1713
  2449.         A. Romao, Tools for DNS debugging, 11/03/1994.
  2450.  
  2451.  
  2452.      RFC 1712
  2453.         C. Farrell, M. Schulze, S. Pleitner, D. Baldoni, DNS Encoding of
  2454.         Geographical Location, 11/01/1994.
  2455.  
  2456.  
  2457.      RFC 1183
  2458.         R. Ullmann, P. Mockapetris, L. Mamakos, C. Everhart, New DNS RR
  2459.         Definitions, 10/08/1990.
  2460.  
  2461.  
  2462.      RFC 1035
  2463.         P. Mockapetris, Domain names - implementation and specification,
  2464.         11/01/1987.
  2465.  
  2466.  
  2467.      RFC 1034
  2468.         P. Mockapetris, Domain names - concepts and facilities,
  2469.         11/01/1987.
  2470.  
  2471.  
  2472.      RFC 1033
  2473.         M. Lottor, Domain administrators operations guide, 11/01/1987.
  2474.  
  2475.  
  2476.      RFC 1032
  2477.         M. Stahl, Domain administrators guide, 11/01/1987.
  2478.  
  2479.  
  2480.      RFC 974
  2481.         C. Partridge, Mail routing and the domain system, 01/01/1986.
  2482.  
  2483.