System Administration Guide: Naming and Directory Services (DNS, NIS, and LDAP)

Configuring a Network For DNS

To configure a network for DNS, you must set up a client and a server.

Setting Up a DNS Client

Set up the client(s) prior to setting up the DNS server.

How to Set up a DNS Client
  1. Create the /etc/resolv.conf file.

    A simple example resolv.conf file for a client (non-server) machine in the doc.com domain is shown below.


    Example 4–2 Sample resolv.conf File


    ; Sample resolv.conf file for the machine polaris
    domain doc.com
    ; try local name server
    nameserver 10.0.0.1
    ; if local name server down, try these servers
    nameserver 192.168.16.6
    nameserver 192.168.16.7
    ; sort the addresses returned by gethostbyname(3c)
    sortlist
    130.155.160.0/255.255.240.0
    130.155.0.0

    The first line of the /etc/resolv.conf file lists the domain name in the following form.


    domain domainname
    

    Where domainname is the name registered with the Internet governing bodies (as of this writing, the InterNIC).


    Note –

    No spaces or tabs are permitted at the end of the domain name. Make sure that you enter a hard carriage return immediately after the last character of the domain name.


    The second line identifies the loopback name server in the form.


    nameserver 10.0.0.1

    Succeeding lines list the IP addresses of up to three DNS master, slave, or cache-only name servers that the resolver should consult to resolve queries. Do not list more than three master or slave servers. Name server entries have the following form.


    nameserver IP_address
    

    IP_address is the IP address of a master or slave DNS name server. The resolver queries these name servers in the order they are listed until it obtains the information it needs.

    The fifth line of the /etc/resolv.conf file lists the address sortlist in the form:


    sortlist
    addresslist
    

    addresslist specifies the sort order of the addresses returned by gethostbyname(3c). In our example, gethostbyname returns the netmask pair 130.155.160.0/255.255.240.0 ahead of the IP address 130.155.0.0.

  2. Modify the /etc/nsswitch.conf file.

    NIS. If your master enterprise-level naming service is NIS, with proper configuration, NIS is already DNS-enabled.

    Files-based. If your master enterprise-level naming service is based on /etc files, or if your master enterprise-level naming service is NIS+, do the following.

    1. Become superuser.

    2. Open the /etc/nsswitch.conf file.

    3. DNS can be the only source or an additional source for the hosts information. Locate the hosts line and use DNS in one of the ways shown below.


      hosts: files dns

      or


      hosts: nis dns [NOTFOUND=return] files

      or


      hosts: dns nis [NOTFOUND=return] files

      Do not use the above syntax for NIS clients, or they will be forced to search for unresolved names twice in DNS.

    4. Specify DNS as a source of hosts information.

    5. Save the file and reboot.

Setting Up a DNS Server

How to Set Up a DNS Server
  1. Become superuser.

  2. Set the server up as a DNS client (this includes setting up the server's resolv.conf file). See Setting Up a DNS Client.

  3. Set up the boot file. See Example Boot Files.

  4. Set up the data files. You need to set up four data files.

    • named.ca

    • hosts

    • hosts.rev

    • named.local

  5. Initialize the server. See Initializing the Server.

  6. Test the server. See Testing Your Installation.


    Note –

    The most common use of DNS is to connect your network to the Internet. To connect to the Internet, your network IP address must be registered with whomever is administering your parent domain. Who that administrator is varies according to your geographic location and type of parent domain. This manual does not describe how to register networks with domain administrators.


How to Specify a Master Server

The two types of master server are as follows.

To specify a server as the master server for a given zone, you create three master records in that server's named.boot file.

  1. Create the master record for the zone.

    This record designates the server as a master server for the zone and tells the server where to find the authoritative hosts file. A “master” record has three fields.

    • The first field designates the server as master.

    • The second field identifies the zone the master serves.

    • The third field identifies the hosts file.

    For example, the following line in a boot file specifies that the server is the master server for the doc.com zone, using authoritative data from the file db.doc.


    master    doc.com    db.doc
  2. Create a master record for the zone's reverse map.

    This record designates the server as a master server for the zone's reverse address map, that is, the reverse address domain for doc.com. The record also tells the server where to find the authoritative hosts file. This record has three fields. The first field designates the server as master, the second field identifies the zone, and the third field identifies the hosts.rev file.

    The reverse address domain for a zone contains the zone's IP address in reverse order followed by in-addr.arpa. For example, suppose that the doc.com zone's IP address is 10.0.0. In that case, the reverse address domain would be 0.0.10.in-addr.arpa.

    Thus, the following line in a boot file specifies that the server is the master server for the reverse address domain of the doc.com zone, using authoritative data from the file doc.rev.


    master   0.0.10.in-addr.arpa    doc.rev
  3. Create a master record for the reverse address of the local loopback interface or host.

    This record designates the server as a master server for the loopback host, and tells the server where to find the authoritative hosts file. This record has three fields, the first field designates the server as master, the second field identifies the loopback host reverse address, and the third field identifies the hosts file.


    Note –

    Loopback hosts are always identified as 0.0.10.in-addr.arpa.


    Thus, the following line in a boot file specifies that the server is the master server for the reverse address domain of the loopback host using authoritative data from the file named.local.


    master  0.0.10.in-addr.arpa   named.local

How to Specify a Slave Server

A slave server maintains a copy of the data for the zone. The master server sends its data and delegates authority to the slave server. Clients can query a slave server for DNS information. By using slave servers, you can improve response time and reduce network overhead by spreading the load over multiple machines. Slave servers also provide redundancy in case the master server is not available.

When in.named starts, it requests all the data for the given zone from the master. The slave server then periodically checks with the master to see if it needs to update its database. The process of sending the most recent zone database from the master to the slave is called a zone transfer. Thus, you do not modify data files on a slave server, you modify the data files on the zone's master server and the slave servers update their files from the master.

To specify that a server is to be the slave server for a given zone, you create slave records in that server's named.boot file. Separate records can designate the server as a slave server for the zone, the zone's reverse address domain, and the loopback host.

A slave record has three required fields:

A “slave” record can have one or more optional fields after the required fields. The optional fields are:

For example, the following lines in a boot file specify that the server is the slave server for the doc.com zone and its reverse address domain, that it obtains its authoritative data from the master server with an IP address of 172.16.0.1, that it uses the server 172.16.0.2 as a slave source of zone data, and initially loads its data from the file doc.com.bakup:


 
slave   doc.com   129.146.168.119  192.146.168.38  doc.com.bakup
slave   4.0.32.128.in-addr.arpa       129.146.168.119 

In the context of the various example files presented in this chapter, the sample boot file lines above correspond to the boot file of the dnsslave server, which is an alias for the sirius machine whose IP address is 192.146.168.38.


Note –

A server can act as the master server for one or more zones, and as the slave server for one or more zones. The mixture of entries in the boot file determines whether a server is a master or slave server for a given zone.


How to Specify a Cache-Only or Stub Server

All servers are caching servers in the sense that they all maintain a cache of DNS data. A caching only or stub server is a server that is not a master server for any zone other than the in-addr.arpa. domain.

A cache-only server does not maintain any authoritative data. It handles queries and asks the hosts listed in the in.named file for the information needed. In other words, a cache-only server handles the same kind of queries that authoritative name servers perform, but it does not maintain any authoritative data itself.

The following is a sample boot file for a cache only server.


Example 4–3 Sample Master Boot File for Caching-only Server


;
; Sample named.boot file for caching-only name server
;
; type                  domain                 source file or host
;
directory /var/named
cache                   .                      named.ca
master                 0.0.127.in-addr.arpa   named.local

You do not need a special line to designate a server as a cache-only server. What denotes a cache-only server is the absence of any slave or master authority lines in the boot file, except as noted below.

A cache-only server requires the following.