home *** CD-ROM | disk | FTP | other *** search
/ CD Actual 8 / CDACTUAL8.iso / docs / dns-howt < prev    next >
Encoding:
Text File  |  1996-07-11  |  40.1 KB  |  981 lines

  1.   DNS HOWTO
  2.   Nicolai Langfeldt janl@math.uio.no
  3.   v1.0, 25 March 1996
  4.  
  5.   HOWTO become a totally small time DNS admin.
  6.  
  7.   Keywords: DNS, bind, named, dialup, ppp, slip, internet, domain, name,
  8.   hosts, resolving
  9.  
  10.   Legal mumbo-jumbo:
  11.  
  12.   (C)opyright 1995 Nicolai Langfeldt.  Do not modify without amending
  13.   copyright, distribute freely but retain copyright message.  The author
  14.   wishes to thank Arnt Gulbrandsen who read the drafts to this work
  15.   countless times and provided many useful suggestions.
  16.  
  17.   This will never be a finished document, please send me mail about your
  18.   problems and successes, it can make this a better HOWTO.  So please
  19.   send money, comments and/or questions to janl@ifi.uio.no.
  20.  
  21.   1.  Introduction.
  22.  
  23.   What this is and isn't.
  24.  
  25.   DNS is, to the uninitiated (you ;-), one of the more opaque areas of
  26.   network administration.  This HOWTO will try to make a few things
  27.   clearer.  It describes how to set up a simple DNS name server.  For
  28.   more complex setups you will need to read the Real Documentation.
  29.   I'll get back to what this Real Documentation consists in ``the last
  30.   chapter''.
  31.  
  32.   Before you start on this you should configure your machine so that you
  33.   can telnet in and out of it, and make successfuly make all kinds of
  34.   connections to the net, and you should be able to do telnet 127.0.0.1
  35.   and get your own machine.  You also need a good /etc/host.conf,
  36.   /etc/resolve.conf and /etc/hosts files as a starting point, since I
  37.   will not explain their function here.  If you don't already have all
  38.   this set up and working the networking/NET-2 HOWTO explains how to set
  39.   it up.  Read it.
  40.  
  41.   If you're using SLIP og PPP you need that working.  Read the PPP HOWTO
  42.   if it's not.
  43.  
  44.   When I say 'your machine' I mean the macine you are trying to set up
  45.   DNS on.  Not any other machine you might have that's involved in your
  46.   networking effort.
  47.  
  48.   I assume you're not behind any kind of firewall that blocks name
  49.   queries.  If you are you will need a special configuration, see the
  50.   section on ``firewalls and other peculiar net things''.
  51.  
  52.   Name serving on Unix is done by a program called named This is a part
  53.   of the bind package which is coordinated by Paul Vixie for The
  54.   Internet Software Consortium.  Named is included in most Linux
  55.   distributions and is usualy installed as /usr/sbin/named. If you have
  56.   a named you can probably use it; if you don't have one you can get a
  57.   binary off a Linix ftp site, or get the latest and greatest source
  58.   from ftp:ftp.vix.com/pub/bin in either the release or testing
  59.   subdirectory, whatever fits your lifestyle best.
  60.  
  61.   DNS is a net-wide database.  Take care about what you put into it.  If
  62.   you put junk into it, you, and others will get junk out of it.  Keep
  63.   your DNS tidy and consistent and you will get good service from it.
  64.   Learn to use it, admin it, debug it and you will be another good admin
  65.   keeping the net from falling to it's knees overloaded by
  66.   mismanagement.
  67.  
  68.   In this document I state flatly a couple of things that are not
  69.   completely true (they are at least half truths though).  All in the
  70.   interest of simplification.  Things will probably work if you belive
  71.   what I say.
  72.  
  73.   Tip: Make backup copies of all the files I instruct you to change if
  74.   you already have them, so if after going thru this nothing works you
  75.   can get it back to your old, working state.
  76.  
  77.   2.  A caching only name server.
  78.  
  79.   A first stab at DNS config, very useful for dialup users.
  80.  
  81.   A caching only name server will find the answer to name queries and
  82.   remember the answer the next time you need it.
  83.  
  84.   First you need a file called /etc/named.boot.  This is read when named
  85.   starts.  For now it should simply contain:
  86.  
  87.   ______________________________________________________________________
  88.   ;  Boot file for nicolais caching name server
  89.   ;
  90.   directory /var/named
  91.   ;
  92.   ; type          domain                          source file or host
  93.   cache           .                               root.cache
  94.   ______________________________________________________________________
  95.  
  96.   The `directory' line tells named where to look for files.  All files
  97.   named subsequently will be relative to this.  /var/named is the right
  98.   directory according to the Linux Filesystem Standard.
  99.  
  100.   The file named /var/named/root.cache is named in this.
  101.   /var/named/root.cache should contain this:
  102.  
  103.   ______________________________________________________________________
  104.   ; ---- Root hint cache dump ----
  105.   .    IN      NS      A.ROOT-SERVERS.NET
  106.   .    IN      NS      B.ROOT-SERVERS.NET
  107.   .    IN      NS      C.ROOT-SERVERS.NET
  108.   .    IN      NS      D.ROOT-SERVERS.NET
  109.   .    IN      NS      E.ROOT-SERVERS.NET
  110.   .    IN      NS      F.ROOT-SERVERS.NET
  111.   .    IN      NS      G.ROOT-SERVERS.NET
  112.   .    IN      NS      H.ROOT-SERVERS.NET
  113.   .    IN      NS      I.ROOT-SERVERS.NET
  114.   ;
  115.   ;  Prep the cache (hardwire the addresses).  Order does not matter
  116.   ;
  117.   A.ROOT-SERVERS.NET.  IN      A       198.41.0.4
  118.   B.ROOT-SERVERS.NET.  IN      A       128.9.0.107
  119.   C.ROOT-SERVERS.NET.  IN      A       192.33.4.12
  120.   D.ROOT-SERVERS.NET.  IN      A       128.8.10.90
  121.   E.ROOT-SERVERS.NET.  IN      A       192.203.230.10
  122.   F.ROOT-SERVERS.NET.  IN      A       39.13.229.241
  123.   G.ROOT-SERVERS.NET.  IN      A       192.112.36.4
  124.   H.ROOT-SERVERS.NET.  IN      A       128.63.2.53
  125.   I.ROOT-SERVERS.NET.  IN      A       192.36.148.17
  126.   ______________________________________________________________________
  127.  
  128.   The file describes the root name servers in the world.  This changes
  129.   over time, see the ``maintenance section'' for how to update it.  This
  130.   file is described in the named man page, but is, HMHO, best suited for
  131.   people that already understand named.
  132.  
  133.   Next, you need a /etc/resolv.conf looking something like this:
  134.  
  135.   ______________________________________________________________________
  136.   search subdomain.your-domain.edu your-domain.edu
  137.   nameserver 127.0.0.1
  138.   ______________________________________________________________________
  139.  
  140.   The `search' line specifies what domains should be searched for any
  141.   hostnames you want to connect to.  The `nameserver' line specifies
  142.   what address your machine can reach a nameserver at, in this case your
  143.   own machine since that is where your named runs. (Note: Named never
  144.   reads this file, the resolver that uses named does.)
  145.  
  146.   To illustrate what this file does: If a client tries to look up foo,
  147.   foo.subdomain.your-domain.edu is tried first, then foo.your-
  148.   fomain.edu, finally foo.  If a client tries to look up
  149.   sunsite.unc.edu, sunsite.unc.edu.subdomain.your-domain.edu is tried
  150.   first, then sunsite.unc.edu.your-domain.edu, and finally
  151.   sunsite.unc.edu.  You may not want to put in too many domains in the
  152.   search line, it takes time to search all the domains.
  153.  
  154.   The example assumes you belong in the domain subdomain.your-
  155.   domain.edu, your machine then, is probably called your-
  156.   machine.subdomain.your-domain.edu.  The search line should not contain
  157.   your TLD (Top Level Domain, `edu' in this case).  If you frequently
  158.   need to connect to hosts in another domain you can add that domain to
  159.   the search line like this:
  160.  
  161.   ______________________________________________________________________
  162.   search subdomain.your-domain.edu. your-domain.edu. other-domain.com.
  163.   ______________________________________________________________________
  164.  
  165.   and so on. Obviosly you need to put real domain names in instead.
  166.  
  167.   The last file you have to fix is /etc/host.conf.  It will probably
  168.   contain several lines, one should starting with order and it should
  169.   look like this:
  170.  
  171.   ______________________________________________________________________
  172.   order hosts,bind
  173.   ______________________________________________________________________
  174.  
  175.   If there is no `order' line you should stick one in.  It tells the
  176.   host name resolving routines to first look in /etc/hosts, then ask the
  177.   name server (which you in resolve.conf said is at 127.0.0.1) These two
  178.   latest files are documented in the resolv(8) manpage (do `man 8
  179.   resolv').  That man page is IMHO readable, and everyone, especially
  180.   DNS admins, should read it.  Do it now, if you say to yourself "I'll
  181.   do it later" you'll never get around to it.
  182.  
  183.   After all this it's time to start named.  Type `/usr/sbin/named', and
  184.   press return, no options.  If you're using a dialup connection connect
  185.   first.  Now you can test your setup.  If you view your syslog message
  186.   file (usualy called /var/adm/messages) while starting named (tail -f
  187.   /var/adm/messages) you should see something like:
  188.  
  189.        Mar  6 23:44:21 roke named[31426]: starting.  named 4.9.3-P1 Sat Jan 27 00:36:2
  190.        9 MET 1996       janl@roke.slip.ifi.uio.no:/home/janl/bind-4.9.3/named
  191.        Mar  6 23:44:21 roke named[31426]: cache zone "" loaded (serial 0)
  192.        Mar  6 23:44:21 roke named[31427]: Ready to answer queries.
  193.  
  194.   If there are any messages about errors then there is a mistake named
  195.   will name the file it is in (one of named.boot and root.cache I hope
  196.   :-) Kill named and go back and check the named file.
  197.  
  198.   At this point we're at a cross roads. If you're using a very recent
  199.   bind distribution the setup might not work entierly yet.  We'll find
  200.   out when we try to start query it.  The program designed for this is
  201.   nslookup.  Start it by giving linux the command `nslookup':
  202.  
  203.   $ nslookup
  204.   Default Server:  localhost
  205.   Address:  127.0.0.1
  206.  
  207.   >
  208.  
  209.   If that's what you get it's working.  If you get this instead:
  210.  
  211.        $ nslookup
  212.        *** Can't find server name for address 127.0.0.1: Non-existent host/domain
  213.        *** Default servers are not available
  214.  
  215.   you need to skip ahead to section the section called ```A Simple
  216.   domain.''' and read until you've got two `primary' lines in
  217.   named.boot, a file named pz/127.0.0 and a file pz/localhost.  Then
  218.   return here.
  219.  
  220.   Now you can enter a query.  Try looking up some machine close to you.
  221.   pat.uio.no is close to me, at the University of Oslo:
  222.  
  223.        > pat.uio.no
  224.        Server:  localhost
  225.        Address:  127.0.0.1
  226.  
  227.        Name:    pat.uio.no
  228.        Address:  129.240.2.50
  229.  
  230.   nslookup now asked your named to look for the machine pat.uio.no.  It
  231.   then contacted one of the name server machines named in your
  232.   root.cache file, and asked it's way from there.  It might take tiny
  233.   while before you get the result as it searches all the domains you
  234.   named in /etc/resolve.conf.  If you try again you get this:
  235.  
  236.        > pat.uio.no
  237.        Server:  localhost
  238.        Address:  127.0.0.1
  239.  
  240.        Non-authoritative answer:
  241.        Name:    pat.uio.no
  242.        Address:  129.240.2.50
  243.  
  244.   Note the 'Non-authoritative answer:' line we got this time around.
  245.   That means that named did not go out on the network to ask this time,
  246.   it instead looked in it's cache and found it there.  But the cached
  247.   information might be out of date (stale).  So you are informed of this
  248.   (very slight) danger by it saying `Non-authorative answer:'.  When
  249.   nslookup says this the second time you ask for a host it's a sign it
  250.   caches the information and that it's working.  You exit nslookup by
  251.   giving the command `exit'.
  252.  
  253.   If you're a dialup (ppp, slip) user please read the ``section on
  254.   dialup connections'', there is some advice there for you.
  255.  
  256.   Now you know how to set up minimal configuration files for named.
  257.  
  258.   3.  A Simple domain.
  259.  
  260.   How to set up your own domain.
  261.  
  262.   Before we really start this section I'm going to serve you some theory
  263.   on how DNS works.  And you're going to read it because it's good for
  264.   you.  If you don't `wanna' you should at least skim it very quickly.
  265.   Stop skiming when you get to what should go in your named.boot file.
  266.  
  267.   DNS is a hierarchical system.  The top is written `.' and pronounced
  268.   'root'.  Under . there are a number of Top Level Domains (TLDs), the
  269.   best known ones are ORG, COM, EDU and NET, but there are many.  When
  270.   you want to find out the address of prep.ai.mit.edu your name server
  271.   has to find a name server that serves edu.  It asks a root.cache file
  272.   is for), the . server gives a list of edu servers.  I'll illustrate
  273.   this here:
  274.  
  275.        $ nslookup
  276.        Default Server:  localhost
  277.        Address:  127.0.0.1
  278.  
  279.        > server c.root-servers.net.
  280.        Default Server:  c.root-servers.net
  281.        Address:  192.33.4.12
  282.  
  283.   Ask the root server.
  284.  
  285.        > set q=ns
  286.  
  287.   Set the Query type to NS (name server records).
  288.  
  289.        > edu.
  290.  
  291.   The trailing . here is significant, it tells the server we're asking
  292.   that edu is right under ., this narrows the search somewhat.
  293.  
  294.        Server:  c.root-servers.net
  295.        Address:  192.33.4.12
  296.  
  297.        edu     nameserver = E.ROOT-SERVERS.NET
  298.        edu     nameserver = I.ROOT-SERVERS.NET
  299.        edu     nameserver = F.ROOT-SERVERS.NET
  300.        edu     nameserver = G.ROOT-SERVERS.NET
  301.        edu     nameserver = A.ROOT-SERVERS.NET
  302.        edu     nameserver = H.ROOT-SERVERS.NET
  303.        edu     nameserver = B.ROOT-SERVERS.NET
  304.        edu     nameserver = C.ROOT-SERVERS.NET
  305.        edu     nameserver = D.ROOT-SERVERS.NET
  306.        E.ROOT-SERVERS.NET      internet address = 192.203.230.10
  307.        I.ROOT-SERVERS.NET      internet address = 192.36.148.17
  308.        F.ROOT-SERVERS.NET      internet address = 39.13.229.241
  309.        G.ROOT-SERVERS.NET      internet address = 192.112.36.4
  310.        A.ROOT-SERVERS.NET      internet address = 198.41.0.4
  311.        H.ROOT-SERVERS.NET      internet address = 128.63.2.53
  312.        B.ROOT-SERVERS.NET      internet address = 128.9.0.107
  313.        C.ROOT-SERVERS.NET      internet address = 192.33.4.12
  314.        D.ROOT-SERVERS.NET      internet address = 128.8.10.90
  315.  
  316.   This tells us that *.root-servers.net serves edu., so we can go on
  317.   asking c.  Now we want to know who serves the next level of the domain
  318.   name: mit.edu.:
  319.  
  320.        > mit.edu.
  321.        Server:  c.root-servers.net
  322.        Address:  192.33.4.12
  323.  
  324.        Non-authoritative answer:
  325.        mit.edu nameserver = STRAWB.mit.edu
  326.        mit.edu nameserver = W20NS.mit.edu
  327.        mit.edu nameserver = BITSY.mit.edu
  328.  
  329.        Authoritative answers can be found from:
  330.        BITSY.mit.edu   internet address = 18.72.0.3
  331.        STRAWB.mit.edu  internet address = 18.71.0.151
  332.        W20NS.mit.edu   internet address = 18.70.0.160
  333.  
  334.   steawb, w20ns and bitsy serves mit, select one and inquire about
  335.   ai.mit.edu:
  336.  
  337.        > server W20NS.mit.edu.
  338.  
  339.   Hostnames are not case sensitive, but I use my mouse to cut and paste
  340.   so it gets copied as is from the screen.
  341.  
  342.   Server:  W20NS.mit.edu
  343.   Address:  18.70.0.160
  344.  
  345.   > ai.mit.edu.
  346.   Server:  W20NS.mit.edu
  347.   Address:  18.70.0.160
  348.  
  349.   Non-authoritative answer:
  350.   ai.mit.edu      nameserver = WHEATIES.AI.MIT.EDU
  351.   ai.mit.edu      nameserver = ALPHA-BITS.AI.MIT.EDU
  352.   ai.mit.edu      nameserver = GRAPE-NUTS.AI.MIT.EDU
  353.   ai.mit.edu      nameserver = TRIX.AI.MIT.EDU
  354.   ai.mit.edu      nameserver = MUESLI.AI.MIT.EDU
  355.  
  356.   Authoritative answers can be found from:
  357.   AI.MIT.EDU      nameserver = WHEATIES.AI.MIT.EDU
  358.   AI.MIT.EDU      nameserver = ALPHA-BITS.AI.MIT.EDU
  359.   AI.MIT.EDU      nameserver = GRAPE-NUTS.AI.MIT.EDU
  360.   AI.MIT.EDU      nameserver = TRIX.AI.MIT.EDU
  361.   AI.MIT.EDU      nameserver = MUESLI.AI.MIT.EDU
  362.   WHEATIES.AI.MIT.EDU     internet address = 128.52.32.13
  363.   WHEATIES.AI.MIT.EDU     internet address = 128.52.35.13
  364.   ALPHA-BITS.AI.MIT.EDU   internet address = 128.52.32.5
  365.   ALPHA-BITS.AI.MIT.EDU   internet address = 128.52.37.5
  366.   GRAPE-NUTS.AI.MIT.EDU   internet address = 128.52.32.4
  367.   GRAPE-NUTS.AI.MIT.EDU   internet address = 128.52.36.4
  368.   TRIX.AI.MIT.EDU internet address = 128.52.32.6
  369.   TRIX.AI.MIT.EDU internet address = 128.52.38.6
  370.   MUESLI.AI.MIT.EDU       internet address = 128.52.32.7
  371.   MUESLI.AI.MIT.EDU       internet address = 128.52.39.7
  372.  
  373.   So weaties.ai.mit.edu is a nameserver for ai.mit.edu:
  374.  
  375.        > server WHEATIES.AI.MIT.EDU.
  376.        Default Server:  WHEATIES.AI.MIT.EDU
  377.        Addresses:  128.52.32.13, 128.52.35.13
  378.  
  379.   Now I change query type, we've found the name server so now we're
  380.   going to ask about everything wheaties knows about prep.ai.mit.edu.
  381.  
  382.   > set q=any
  383.   > prep.ai.mit.edu.
  384.   Server:  WHEATIES.AI.MIT.EDU
  385.   Addresses:  128.52.32.13, 128.52.35.13
  386.  
  387.   prep.ai.mit.edu CPU = dec/decstation-5000.25    OS = unix
  388.   prep.ai.mit.edu
  389.           inet address = 18.159.0.42, protocol = tcp
  390.            #21 #23 #25 #79
  391.   prep.ai.mit.edu preference = 1, mail exchanger = life.ai.mit.edu
  392.   prep.ai.mit.edu internet address = 18.159.0.42
  393.   ai.mit.edu      nameserver = alpha-bits.ai.mit.edu
  394.   ai.mit.edu      nameserver = wheaties.ai.mit.edu
  395.   ai.mit.edu      nameserver = grape-nuts.ai.mit.edu
  396.   ai.mit.edu      nameserver = mini-wheats.ai.mit.edu
  397.   ai.mit.edu      nameserver = trix.ai.mit.edu
  398.   ai.mit.edu      nameserver = muesli.ai.mit.edu
  399.   ai.mit.edu      nameserver = count-chocula.ai.mit.edu
  400.   ai.mit.edu      nameserver = life.ai.mit.edu
  401.   ai.mit.edu      nameserver = mintaka.lcs.mit.edu
  402.   life.ai.mit.edu internet address = 128.52.32.80
  403.   alpha-bits.ai.mit.edu   internet address = 128.52.32.5
  404.   wheaties.ai.mit.edu     internet address = 128.52.35.13
  405.   wheaties.ai.mit.edu     internet address = 128.52.32.13
  406.   grape-nuts.ai.mit.edu   internet address = 128.52.36.4
  407.   grape-nuts.ai.mit.edu   internet address = 128.52.32.4
  408.   mini-wheats.ai.mit.edu  internet address = 128.52.32.11
  409.   mini-wheats.ai.mit.edu  internet address = 128.52.54.11
  410.   mintaka.lcs.mit.edu     internet address = 18.26.0.36
  411.  
  412.   So starting at . we found the successive name servers for the next
  413.   level in the domain name.  If you had used your own DNS server instead
  414.   of using all those other servers, your named would of-course cache all
  415.   the information it found while diging this out for you, and would not
  416.   have to ask again for a while.
  417.  
  418.   A much less talked about, but just as important domain is in-
  419.   addr.arpa.  It too is nested like the `normal' domains.  in-addr.arpa
  420.   is a hack, a good hack, but still a hack, that alows us to get the
  421.   hosts name when we have it's address.  If you have the address of a
  422.   machine: 192.128.52.43 named procedes just like for the
  423.   prep.ai.mit.edu example: find arpa. servers.  Find in-addr.arpa.
  424.   servers, find 192.in-addr.arpa. servers, find 128.192.in-addr.arpa.
  425.   servers, find 52.128.192.in-addr.arpa.  servers.  Find needed records
  426.   for 43.52.128.192.in-addr.arpa.  Clever huh? (say `yes').
  427.  
  428.   I have just told a lie.  DNS does not work literally the way I just
  429.   told you.  But it's close enough.
  430.  
  431.   Now to define our own domain.  We're going to make the domain
  432.   linux.bogus and define machines in it.  I use a totally bogus domain
  433.   name to make sure we disturb no-one Out There.
  434.  
  435.   But before we can even start defining our own domain you have to teach
  436.   your named about localhost.
  437.  
  438.   Make the directory /var/named/pz (pz for Primary Zone) and place these
  439.   lines at the end of your named.boot file:
  440.  
  441.   ______________________________________________________________________
  442.   primary         0.0.127.in-addr.arpa            pz/127.0.0
  443.   primary         localhost                       pz/localhost
  444.   ______________________________________________________________________
  445.  
  446.   Please note the lack of `.' at the end of the domain names in this
  447.   file.  The first line names the file pz/127.0.0 as defining
  448.   0.0.127.in-addr.arpa.  This should be the contents:
  449.  
  450.   ______________________________________________________________________
  451.   $ORIGIN 0.0.127.IN-ADDR.ARPA.
  452.   @               IN      SOA     linux.bogus. hostmaster.linux.bogus. (
  453.                                   1       ; Serial
  454.                                   360000  ; Refresh
  455.                                   300     ; Retry
  456.                                   3600000 ; Expire
  457.                                   360000 )        ; Minimum
  458.                           NS      ns.linux.bogus.
  459.   1                       PTR     localhost.
  460.   ______________________________________________________________________
  461.  
  462.   Please note the `.' at the end of the domain names in this file in
  463.   contrast to the named.boot file above.  This `zone file' contains 3
  464.   `resource records' (RRs): A SOA RR.  A NS RR nd a PTR RR.  SOA is
  465.   short for Start Of Authority.  Before the first record comes a $ORIGIN
  466.   directive, it is widely considered Good Practice to have a $ORIGIN
  467.   directive at the start of each zone file.
  468.  
  469.   @ is a special notation meaning the origin, so the first line really
  470.   says
  471.  
  472.          0.0.127.IN-ADDR.ARPA  IN      SOA ...
  473.  
  474.   NS is the Name Server RR, it tells DNS what machine is the name server
  475.   of the domain.  And finaly the PTR record says that 1.0.0.127.IN-
  476.   ADDR.ARPA (i.e. 127.0.0.1) is named localhost.
  477.  
  478.   The SOA record is the preamble to _all_ zone files, and there should
  479.   be exactly one in each zone file, the very first record.  It describes
  480.   the zone, where it comes from (a machine called linux.bogus), who is
  481.   responsible for its contents (hostmaster@linux.bogus), what version of
  482.   the zone file this is (serial: 1), and other things having to do with
  483.   caching and secondary DNS servers.  For the rest of the fields
  484.   ,refresh, retry, expire and minimum use the numbers used in this HOWTO
  485.   and you should be safe.
  486.  
  487.   The NS record tells us who does DNS serving for 0.0.127.in-addr.arpa,
  488.   it is ns.linux.bogus.  The PTR record tells us that 1.0.0.127.in-
  489.   addr.arpa (aka 127.0.0.1) is known as localhost.
  490.  
  491.   The file pz/localhost should cointain this:
  492.  
  493.   ______________________________________________________________________
  494.   $ORIGIN localhost.
  495.   @               IN      SOA     linux.bogus. hostmaster.linux.bogus. (
  496.                                   1       ; Serial
  497.                                   360000  ; Refresh
  498.                                   300     ; Retry
  499.                                   3600000 ; Expire
  500.                                   360000 )        ; Minimum
  501.                           NS      ns.linux.bogus.
  502.                           A       127.0.0.1
  503.   ______________________________________________________________________
  504.  
  505.   If you're skipping ahead from section 2 you can kill and restart your
  506.   named, then go back to section 2.
  507.  
  508.   Now kill and restart your named and use nslookup to examine what
  509.   you've done:
  510.  
  511.        $ nslookup
  512.  
  513.        Default Server:  localhost
  514.        Address:  127.0.0.1
  515.  
  516.        > 127.0.0.1
  517.        Server:  localhost
  518.        Address:  127.0.0.1
  519.  
  520.        Name:    localhost
  521.        Address:  127.0.0.1
  522.  
  523.   so it manages to get localhost from 127.0.0.1, good.  Don't push it,
  524.   we'll move on to checking localhost:
  525.  
  526.   > set q=any
  527.   > localhost.
  528.   Server:  localhost
  529.   Address:  127.0.0.1
  530.  
  531.   localhost
  532.           origin = linux.bogus
  533.           mail addr = hostmaster.linux.bogus
  534.           serial = 1
  535.           refresh = 360000 (4 days 4 hours)
  536.           retry   = 300 (5 mins)
  537.           expire  = 3600000 (41 days 16 hours)
  538.           minimum ttl = 360000 (4 days 4 hours)
  539.   localhost       nameserver = ns.linux.bogus
  540.   localhost       internet address = 127.0.0.1
  541.   localhost       nameserver = ns.linux.bogus
  542.  
  543.   Looks good.  Now for our main task, the linux.bogus domain, insert a
  544.   new primary line in named.boot:
  545.  
  546.   ______________________________________________________________________
  547.   primary               linux.bogus                     pz/linux.bogus
  548.   ______________________________________________________________________
  549.  
  550.   Note the continued lack of ending `.' on the domain name in the
  551.   named.boot file.
  552.  
  553.   In the linux.bogus zone file we'll put some totally bogus data:
  554.  
  555.   ______________________________________________________________________
  556.   ;
  557.   ; Zone file for linux.bogus
  558.   ;
  559.   $ORIGIN linux.bogus.
  560.   ;
  561.   ; Mandatory minimum for a working domain
  562.   ;
  563.   @       IN      SOA     linux.bogus. hostmaster.linux.bogus. (
  564.                           199511301       ; serial, todays date + todays serial #
  565.                           900             ; refresh, seconds
  566.                           600             ; retry, seconds
  567.                           3600000         ; expire, seconds
  568.                           86400 )         ; minimum, seconds
  569.   ;
  570.   @               NS      ns.linux.bogus.
  571.   @               NS      ns.friend.bogus.
  572.   ns.friend.bogus. A      127.0.0.10
  573.   @               MX      10 mail.linux.bogus     ; Primary Mail Exchanger
  574.   @               MX      20 mail.friend.bogus. ; Secondary Mail Exchanger
  575.   mail.friend.bogus. A    127.0.0.11
  576.   ______________________________________________________________________
  577.  
  578.   There is one new RR type in this file, the MX, or Mail eXchanger RR.
  579.   It tells mail systems where to send mail that is addressed to
  580.   someone@linux.bogus, namely too mail.linux.bogus or mail.friend.bogus.
  581.   The number before each machine name is that MX RRs priority, The RR
  582.   with the lowest number (10) is the one mail should be sent to
  583.   primarily.  If that fails it can be sent to one with a higher number,
  584.   a secondary mail handler, i.e. mail.friend.bogus which has priority 20
  585.   here.
  586.  
  587.   Restart named by running /usr/sbin/named.restart.  Examine the results
  588.   with nslookup:
  589.  
  590.        $ nslookup
  591.        > set q=any
  592.        > linux.bogus
  593.        Server:  localhost
  594.        Address:  127.0.0.1
  595.  
  596.        linux.bogus
  597.                origin = linux.bogus
  598.                mail addr = hostmaster.linux.bogus
  599.                serial = 199511301
  600.                refresh = 900 (15 mins)
  601.                retry   = 600 (10 mins)
  602.                expire  = 3600000 (41 days 16 hours)
  603.                minimum ttl = 86400 (1 day)
  604.        linux.bogus     nameserver = ns.linux.bogus
  605.        linux.bogus     nameserver = ns.friend.bogus
  606.        linux.bogus     preference = 10, mail exchanger = mail.linux.bogus.linux.bogus
  607.        linux.bogus     preference = 20, mail exchanger = mail.friend.bogus
  608.        linux.bogus     nameserver = ns.linux.bogus
  609.        linux.bogus     nameserver = ns.friend.bogus
  610.  
  611.   Upon careful examination you will discover a bug.  The line
  612.  
  613.         linux.bogus     preference = 10, mail exchanger = mail.linux.bogus.linux.bogus
  614.  
  615.   is all wrong.  It should be
  616.  
  617.          linux.bogus     preference = 10, mail exchanger = mail.linux.bogus
  618.  
  619.   I deliberately made a mistake so you could learn from it :-) Looking
  620.   in the zone file we find that the line
  621.  
  622.   ______________________________________________________________________
  623.   @               MX      10 mail.linux.bogus     ; Primary Mail Exchanger
  624.   ______________________________________________________________________
  625.  
  626.   is missing a period. Or has a 'linux.bogus' too many. If a machine
  627.   name does not end in a period in a zone file the origin is added to
  628.   it's end.  So either
  629.  
  630.        @               MX      10 mail.linux.bogus.    ; Primary Mail Exchanger
  631.  
  632.   or
  633.  
  634.        @               MX      10 mail                 ; Primary Mail Exchanger
  635.  
  636.   is correct.  I prefer the latter form, it's less to type.  In a zone
  637.   file the domain should either be written out and ended with a `.'  or
  638.   it should not be included at all, in which case it defaults to the
  639.   $ORIGIN.  I must stress that in the named.boot file there should _not_
  640.   be `.'s after the domain names.  You have no idea how many times a `.'
  641.   too many or few have fouled up things and confused the h*ll out of
  642.   people.
  643.  
  644.   So having made my point here is the new zone file, with some extra
  645.   information in it too:
  646.  
  647.   ______________________________________________________________________
  648.   ;
  649.   ; Zone file for linux.bogus
  650.   ;
  651.   $ORIGIN linux.bogus.
  652.   ;
  653.   ; Mandatory minimum for a working domain
  654.   ;
  655.   @       IN      SOA     linux.bogus. hostmaster.linux.bogus. (
  656.                           199511301       ; serial, todays date + todays serial #
  657.                           900             ; refresh, seconds
  658.                           600             ; retry, seconds
  659.                           3600000         ; expire, seconds
  660.                           86400 )         ; minimum, seconds
  661.   ;
  662.   @               NS      ns              ; Inet Address of name server
  663.   @               NS      ns.friend.bogus.
  664.   ns.friend.bogus. A      127.0.0.10
  665.   @               MX      10 mail         ; Primary Mail Exchanger
  666.   @               MX      20 mail.friend.bogus. ; Secondary Mail Exchanger
  667.   mail.friend.bogus. A    127.0.0.11
  668.   ;
  669.   ; Extras
  670.   ;
  671.   localhost       A       127.0.0.1
  672.   @               TXT     "Linux Bogus, your DNS consultant"
  673.   ns              A       127.0.0.2
  674.                   MX      10 mail
  675.                   MX      20 mail.friend.bogus.
  676.                   HINFO   "Pentium" "Linux 1.2"
  677.                   TXT     "RMS"
  678.   richard         CNAME   ns
  679.   www             CNAME   ns
  680.  
  681.   donald          A       127.0.0.3
  682.                   MX      10 mail
  683.                   MX      20 mail.friend.bogus.
  684.                   HINFO   "i486"  "Linux 1.2"
  685.                   TXT     "DEK"
  686.   mail            A       127.0.0.4
  687.                   MX      10 mail
  688.                   MX      20 mail.friend.bogus.
  689.                   HINFO   "386sx" "Linux 1.0.9"
  690.   ftp             CNAME   127.0.0.5
  691.                   MX      10 mail
  692.                   MX      20 mail.friend.bogus.
  693.                   HINFO   "P6" "Linux 1.3.59"
  694.   ______________________________________________________________________
  695.  
  696.   There are a number of new RRs here: HINFO (Host INFOrmation) has two
  697.   parts, it's a good habit to quote each. The first part is the hardware
  698.   or CPU on the machine and the second part the software or OS on the
  699.   machine. ns has a Pentium CPU and runs Linux 1.2.  The TXT record is a
  700.   free text record that you can use for anything you like.  CNAME
  701.   (Canonical NAME) is a way to give each machine several names.  So
  702.   richard and www is a alias for ns.  It's important to note that A MX,
  703.   CNAME and SOA record should never refer to an other CNAME record, they
  704.   should only refer to something with a A record, so it would wrong to
  705.   have
  706.  
  707.   ______________________________________________________________________
  708.   foobar  CNAME   richard                 ; NO!
  709.   ______________________________________________________________________
  710.  
  711.   but correct to have
  712.  
  713.   ______________________________________________________________________
  714.   foobar  CNAME   ns                      ; Yes!
  715.   ______________________________________________________________________
  716.  
  717.   It's also important to note that a CNAME is not a legal host name for
  718.   a mail adddress: webmaster@www.linux.bogus is illegal with the setup
  719.   shown above and you can expect quite a few mail admins Out There to
  720.   enforce this rule even if it works for you.  The way to avoild this is
  721.   to use A records instead:
  722.  
  723.   ______________________________________________________________________
  724.   foobar  A       127.0.0.2
  725.   ______________________________________________________________________
  726.  
  727.   Paul Vixie, the primary named wizard, recomends not using CNAME.  So
  728.   consider not using it very seriously.
  729.  
  730.   Load the new database by running /usr/sbin/named.reload, this causes
  731.   named to read it's files again.
  732.  
  733.        $ nslookup
  734.        Default Server:  localhost
  735.        Address:  127.0.0.1
  736.  
  737.        > ls -d linux.bogus
  738.  
  739.   This means that all records should be listed.
  740.  
  741.   [localhost]
  742.    linux.bogus.                   SOA   linux.bogus hostmaster.linux.bogus. (1995
  743.   11301 900 600 3600000 86400)
  744.    linux.bogus.                   NS    ns.linux.bogus
  745.    linux.bogus.                   NS    ns.friend.bogus
  746.    linux.bogus.                   MX    10   mail.linux.bogus
  747.    linux.bogus.                   MX    20   mail.friend.bogus
  748.    linux.bogus.                   TXT   "Linux Bogus, your DNS consultant"
  749.    mail                           A     127.0.0.4
  750.    mail                           MX    10   mail.linux.bogus
  751.    mail                           MX    20   mail.friend.bogus
  752.    mail                           HINFO 386sx       Linux 1.0.9
  753.    localhost                      A     127.0.0.1
  754.    www                            CNAME ns.linux.bogus
  755.    donald                         A     127.0.0.3
  756.    donald                         MX    10   mail.linux.bogus
  757.    donald                         MX    20   mail.friend.bogus
  758.    donald                         HINFO i486        Linux 1.2
  759.    donald                         TXT   "DEK"
  760.    richard                        CNAME ns.linux.bogus
  761.    ftp                            CNAME 127.0.0.5.linux.bogus
  762.    ftp                            MX    10   mail.linux.bogus
  763.    ftp                            MX    20   mail.friend.bogus
  764.    ftp                            HINFO P6          Linux 1.3.59
  765.    ns                             A     127.0.0.2
  766.    ns                             MX    10   mail.linux.bogus
  767.    ns                             MX    20   mail.friend.bogus
  768.    ns                             HINFO Pentium     Linux 1.2
  769.    ns                             TXT   "RMS"
  770.    linux.bogus.                   SOA   linux.bogus hostmaster.linux.bogus. (1995
  771.   11301 900 600 3600000 86400)
  772.  
  773.   That's good.  Let's check what it says for www alone:
  774.  
  775.        > set q=any
  776.        > www.linux.bogus.
  777.        Server:  localhost
  778.        Address:  127.0.0.1
  779.  
  780.        www.linux.bogus canonical name = ns.linux.bogus
  781.  
  782.   ns.linux.bogus
  783.  
  784.        linux.bogus     nameserver = ns.linux.bogus
  785.        linux.bogus     nameserver = ns.friend.bogus
  786.        ns.linux.bogus  internet address = 127.0.0.2
  787.  
  788.   and ns.linux.bogus has the address 127.0.0.2.  Looks good too.
  789.  
  790.   Of course, this domain is highly bogus, and so are all the addresses
  791.   in it.  For a real domain insert the real domain names and addresses
  792.   and all the other information.  When that is done you need a reverse
  793.   lookup zone file, it should be like the 127.0.0 file and contain
  794.   exactly one PTR RR for each address in use, i.e.
  795.  
  796.        127.0.0.2       PTR     ns.linux.bogus.
  797.        127.0.0.3       PTR     donald.linux.bogus.
  798.        127.0.0.4       PTR     mail.linux.bogus.
  799.        127.0.0.5       PTR     ftp.linux.bogus.
  800.  
  801.   for our example domain (in addition to the SOA RR of-course).
  802.  
  803.   Now it's time for you to play around with things and set up your
  804.   domain.  When you've finished playing with the linux.bogus domain
  805.   remove it from your named.boot file.
  806.  
  807.   4.  DNS and firewalls and other peculiar net things.
  808.  
  809.   This is really outside the scope of this HOWTO.  But I'll give a
  810.   couple of hints: `forwarders', `slave', and have a look in the
  811.   litterature list at the end of this HOWTO.
  812.  
  813.   5.  Maintenance
  814.  
  815.   Keeping it working.
  816.  
  817.   There is one maintenance task you have to do on nameds, other than
  818.   keeping them running.  That's keeping the root.cache file updated.
  819.   The easiest way is using dig, first run dig with no arguments, you
  820.   will get the root.cache according to your own server.  Then ask one of
  821.   the listed root servers with dig @rootserver.  You will note that the
  822.   output looks terrebly like a root.cache file except for a couple of
  823.   extra numbers.  Those numbers are harmless.  Save it to a file (dig
  824.   @e.root-servers.net >root.cache.new) and replace the old root.cache
  825.   with it.
  826.  
  827.   You can also get the same information using nslookup with set q=ns,
  828.   asking a root server for `.' will list the root servers, simple
  829.   editing will render the output in root.cache format.
  830.  
  831.   Lastly you can get the latest root.cache from
  832.   ftp:rs.internic.net/domain/root.cache
  833.   <ftp://rs.internic.net/domain/root.cache>.  You need a new one very
  834.   seldom, don't get it more than at most once a year, rs.internic.net
  835.   does not need the extra load from you, and every one else, getting the
  836.   file once a week.
  837.  
  838.   Remember to restart named after replacing the cache file.
  839.  
  840.   6.  Automatic setup for dialup connections.
  841.  
  842.   This section explains how I have set things up to automate everything.
  843.   My way might not suit you at all, but you might get a idea from
  844.   something I've done.  Also, I use ppp for dialup, while many use slip
  845.   or cslip, so almost everything in your setup can be different from
  846.   mine. But slip's dip program should be able to do many of the things I
  847.   do.
  848.  
  849.   Normaly, when I'm not connected to the net I have a resolv.conf file
  850.   simply containing the line
  851.  
  852.        domain uio.no
  853.  
  854.   This ensures I don't have to wait for the hostname resolving library
  855.   to try to connect to a nameserver that can't help me.  But when I
  856.   connect I want to start my named and have a resolv.conf looking like
  857.   the one described above.  I have solved this by keeping two
  858.   resolv.conf 'template' files named resolv.conf.local and
  859.   resolve.conf.connected.  The latter looks like the resolve.conf
  860.   described before in this document.
  861.  
  862.   To automaticaly connect to the net I run a script called 'ppp-on':
  863.  
  864.   ______________________________________________________________________
  865.   #!/bin/sh
  866.   echo calling...
  867.   pppd
  868.   ______________________________________________________________________
  869.  
  870.   pppd has a file called options that tells it the particulars of how to
  871.   get connected.  Once my ppp connection is up the pppd starts a script
  872.   called ip-up (this is described in the pppd man page).  This is parts
  873.   of the script:
  874.  
  875.   ______________________________________________________________________
  876.   #!/bin/sh
  877.   interface="$1"
  878.   device="$2"
  879.   speed="$3"
  880.   myip="$4"
  881.   upip="$5"
  882.   echo 1&2 PPP: IP up
  883.   cp -v /etc/resolv.conf.connected /etc/resolv.conf
  884.   /usr/sbin/named
  885.   echo PPP: ip-up finished
  886.   ______________________________________________________________________
  887.  
  888.   I.e. I start my named there.  When ppp is disconnected pppd runs a
  889.   script called ip-down:
  890.  
  891.   ______________________________________________________________________
  892.   #!/bin/sh
  893.   echo 1>&2 PPP: IP down
  894.   cp /etc/resolv.conf.local /etc/resolv.conf
  895.   read namedpid </var/run/named.pid
  896.   kill $namedpid
  897.   ______________________________________________________________________
  898.  
  899.   So this gets things configured and up when connecting and
  900.   disconfigured and down when disconnecting.
  901.  
  902.   Some programs, irc and talk come to mind, make a few too many
  903.   assumptions, and for irc the dcc features and talk to work right you
  904.   have to fix your hosts file.  I insert have this in my ip-up script:
  905.  
  906.   ______________________________________________________________________
  907.   cp /etc/hosts.ppp /etc/hosts
  908.   echo $myip      roke >>/etc/hosts
  909.   ______________________________________________________________________
  910.  
  911.   hosts.ppp simply contains
  912.  
  913.   ______________________________________________________________________
  914.   127.0.0.1       localhost
  915.   ______________________________________________________________________
  916.  
  917.   and the echo thing inserts the ip# i have received for my host name
  918.   (roke).
  919.  
  920.   It is probably not smart to run named when you are not connected to
  921.   the net, this is because named will try to send queries to the net and
  922.   it has a long timeout, and you have to wait for this timeout every
  923.   time some program tries to resolve a name.  If you're using dialup you
  924.   should start named when connecting and kill it when disconnecting.  I
  925.   have received mail saying it isn't so, but I have not been able to
  926.   make it work having to wait for long timeouts.  Please mail all
  927.   details if you have better information.
  928.  
  929.   7.  How to become a bigger time DNS admin.
  930.  
  931.   Documentation and tools.
  932.  
  933.   Real Documentation exists.  Online and in print.  The reading of
  934.   several of these is required to make the step from small time DNS
  935.   admin to a big time one.  In print the standard book is DNS and BIND
  936.   by C. Liu and P. Albitz from O'Reilly & Associates, Sebastopol, CA,
  937.   ISBN 0-937175-82-X.  I read this, it's excellent.  There is also a
  938.   section in on DNS in TCP/IP Network Administration, by Craig Hunt from
  939.   O'Reilly..., ISBN 0-937175-82-X.  Another must for Good DNS
  940.   administration (or good anything for that matter) is Zen and the Art
  941.   of Motorcycle Maintenance by Robert M. Prisig :-) Available as ISBN
  942.   0688052304 and others.
  943.  
  944.   Online you will find stuff on  <http://www.vix.com/isc/bind.html>; A
  945.   FAQ, a reference manual (BOG; Bind Operations Guide) as well as papers
  946.   and protocol definitions and DNS hacks.  I have not read most of
  947.   these, but then I'm not a bigtime DNS admin either.  Arnt Gulbrandsen
  948.   on the other hand has read BOG and he's extatic about it :-).  The
  949.   newsgroup comp.protocols.tcp-ip.domains is about DNS.  In addition
  950.   there are a number of RFCs about DNS, the most important are probably
  951.   these:
  952.  
  953.      RFC 1713
  954.         A. Romao, Tools for DNS debugging, 11/03/1994.
  955.  
  956.      RFC 1712
  957.         C. Farrell, M. Schulze, S. Pleitner, D. Baldoni, DNS Encoding of
  958.         Geographical Location, 11/01/1994.
  959.  
  960.      RFC 1536
  961.         A. Kumar, J. Postel, C. Neuman, P. Danzig, S. Miller, Common DNS
  962.         Implementation Errors and Suggested Fixes., 10/06/1993.
  963.  
  964.      RFC 1035
  965.         P. Mockapetris, Domain names - implementation and specification,
  966.         11/01/1987.
  967.  
  968.      RFC 1034
  969.         P. Mockapetris, Domain names - concepts and facilities,
  970.         11/01/1987.
  971.  
  972.      RFC 1033
  973.         M. Lottor, Domain administrators operations guide, 11/01/1987.
  974.  
  975.      RFC 1032
  976.         M. Stahl, Domain administrators guide, 11/01/1987.
  977.  
  978.      RFC 974
  979.         C. Partridge, Mail routing and the domain system, 01/01/1986.
  980.  
  981.