Originally Published: Monday, 10 April 2000 Author: Chen Chang and Sylvester Smith, Linuxcare
Published to: learn_articles_support/Articles Page: 1/1 - [Printable]

Linuxcare: "How To Set Up DNS Services: 3 Part Series"

Linuxcare's Chen Chang and Sylvester Smith, have taken the time to write a 3 part series on DNS Services. Part one essentially sets the stage for how one sets up a DNS server for your LAN. This week, part two will discuss server configuration. Come back next week for part three when we'll wrap up the series with client configuration.

   Page 1 of 1  

Part 2: Server Configuration

Last week we provided an introduction to using DNS on Linux. Our second part in this series involves server configuration. The server portion consists of the name server daemon, named. The configuration of named.conf involves several files. The main configuration file for named is /etc/named.conf. This file defines the basic parameters for the name server and indicates the location of database files which contain information needed for name and address resolution. The default /etc/named.conf which comes with Red Hat 6.1 looks like this:

// generated by named-bootconf.pl
options {
        directory "/var/named";
        /* 
        * If there is a firewall between you and nameservers you want
         * to talk to, you might need to uncomment the query-source
         * directive below.  Previous versions of BIND always asked
         * questions using port 53, but BIND 8.1 uses an unprivileged
         * port by default.
         */
        // query-source address * port 53;
};

// // a caching only nameserver config // zone "." { type hint; file "named.ca"; };

zone "0.0.127.in-addr.arpa" { type master; file "named.local"; };

The // and # are used to indicate a comment. Comments can also be enclosed between /* and */ . To start, we will add what is known as a zone statement to the /etc/named.conf:

zone "gracie.edu" {
        type master;
        file "gracie.hosts";
};

A zone statement in /etc/named.conf specifies several parameters for a zone or domain which the DNS server will provide service for. In the first line of our zone statement, we are indicating that the information contained in the zone statement is for the domain "gracie.edu". The next line indicates that our DNS server, helio, is to serve as the primary DNS server for queries regarding the domain "gracie.edu". The next line, indicates that the database file, or "zone file", which contains the information needed for the hostname to ip address translation can be found in the file "gracie.hosts". This file is located in the directory defined in the option section at the beginning of the file:

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

In this case, the directory to contain the zone files, is set to be /var/named. The file, /var/named/gracie.hosts, is constructed by hand. Warning: the syntax of the file contents is critical. A missing "." or ";" will cause errors later on. In our case, we will create this file with a text editor and fill it with the following contents:

@       IN      SOA     helio.gracie.edu. root.helio.gracie.edu.  (
                                      2000030901 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum

IN NS helio.gracie.edu.

helio IN A 192.168.1.1 rickson IN A 192.168.1.2 royce IN A 192.168.1.3 royler IN A 192.168.1.4 rorian IN A 192.168.1.5

The first section of the file is the SOA or Start of Authority record. This record defines such things as the hostname of the master server, the email address of the adminstrator of the domain, as well as the values of some parameters which affect name service behavior for the zone. For a more detailed explanation on the contents and the syntax of this file, refer to the references listed at the end of the article.

The next section is known as a NS or Name Server resource record. It defines the name of the name server for the domain.

                IN      NS      helio.gracie.edu.
The last section consists of A or Address resource records. These define the IP address for the hosts in the domain gracie.edu.
helio           IN      A       192.168.1.1
rickson         IN      A       192.168.1.2
....
With this file in place, name resolution setup is complete. We can also configure our DNS server to provide address resolution, translating IP addresses to hostnames. To do this, we can add the following reverse zone statement to /etc/named.conf.
zone "1.168.192.in-addr.arpa" {
        type master;
        file "192.168.1.reverse";
};

In the first line of our reverse zone statement, we are indicating that the information contained in the reverse zone statement is for the 192.168.1.0 network. The next line indicates that our DNS server, helio, is to serve as the primary, or master, DNS server for queries regarding the 192.168.1.0 network. The next line indicates that the database file, or "reverse zone file", which contains the information needed for the IP address to hostname translation, can be found in the file "192.168.1.reverse". Like the zone file, the reverse zone file, will also be located in /var/named. For our reverse zone file, we will include the following information:

@       IN      SOA     rickson.gracie.edu. root.rickson.gracie.edu.  (
                                      2000030901 ; Serial
                                      28800      ; Refresh
                                      14400      ; Retry
                                      3600000    ; Expire
                                      86400 )    ; Minimum

IN NS helio.gracie.edu.

1 IN PTR helio.gracie.edu. 2 IN PTR rickson.gracie.edu. 3 IN PTR royce.gracie.edu. 4 IN PTR royler.gracie.edu. 5 IN PTR rorian.gracie.edu.

Like the zone file, the reverse zone file also begins with a SOA record, and a NS record. However, the last section of the reverse zone file contains PTR records rather than A records. PTR, Pointer, records maps IP addresses to hostnames for the domain.

To sum up, we have appended a zone statement and a reverse zone statement for the gracie.edu domain to /etc/named.conf. We have also created a zone file, gracie.hosts, and placed it in /var/named. In addition, we have created a reverse zone file, 192.168.1.reverse, and placed in /var/named also.

With these configuration files in place, we have now completed the setup of the server portion of BIND and can now start the name service on the DNS server with: # /etc/rc.d/init.d/named start

With your DNS servers configured, you are ready to configure client machines to access them. Join us next week when we'll conclude this three part series and discuss client configuration.


Chen Chang is a Linuxcare University Courseware Writer. His areas of interest include TCP/IP networking, Samba, open source advocacy, and system administration. His "Power Tips" column appears every Monday at linux.com. Send your questions and comments to powertips@linuxcare.com




   Page 1 of 1