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

How to Set up a DNS Client

Set up the clients prior to setting up the DNS server.

  1. Become superuser.

  2. 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 2000::16:a:a00:20ff:de8a:643a
    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 that is registered with 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

    The next 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 servers, master or slave. Name server entries have the following form.


    nameserver IP_address
    

    IP_address is the IP address of a master or slave DNS name server. IP_address can be either an IPv4 or an IPv6 address. The resolver queries these name servers in order until the resolver 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(). 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.

  3. 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. Open the /etc/nsswitch.conf file.

    2. DNS can be the only source or an additional source for the hosts information. Locate the hosts line and use DNS as 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 else the clients will search for unresolved names twice in DNS.

    3. Specify DNS as a source of hosts information.

    4. Save the file and reboot.