Domain Name Service


 

 

 

 

 

Introduction to DNS

Linux comes with two ways of setting up a name service.

The first way is a throwback to Unix, but is no longer used much, but still exists, and requires a minimalistic configuration.

The information is stored in the file /etc/hosts, and two lines of information are sufficient :-

 

    127.0.0.1 localhost

    192.192.192.193 linux-1.e-nor.loc linux-1

    

These two lines are created by the Linux installation process.

When the name service is requested by a local application, this file is looked at first, if the required information is not there, then Linux goes and looks for a DNS server.

First of all, Linux looks in a file /etc/resolv.conf - this file contains a pointer to a DNS server.

Again, the installation of Linux creates the required information in this file, and the essential information is in three lines :-

 
 
          domain e-nor.loc
 
          search e-nor.loc
 
          nameserver 127.0.0.1
  
  

Since 127.0.0.1 is the loopback address, it advises that the DNS server is on this host.

Some documentation on the internet suggests that it is wrong to have both the domain line and the search line in this file. However since the installation of Linux creates this file, it may be preferable to leave it as it was created.

 

Configuring DNS

On Linux, the application that performs the DNS service is a daemon called "named".

When the server is booted and "named" is started, it goes and looks in a file called /etc/named.conf.

This file specifies to "named" where it will find the information it requires to offer a naming service.

It starts by advising "named" where the relevant files are located, and then presents the information in a number of "zones".

 

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

zone "e-nor.loc" {
        type master;
        file "named.for";
};

zone "192.192.192.IN-ADDR.ARPA" {
        type master;
        file "named.rev";
};

zone "127.IN-ADDR.ARPA" {
        type master;
        file "named.local";
};

  

The information above is sufficient for an isolated network, but if a network is connected to the outside world, there would have to be another zone which pointed to DNS servers in the outside world.

The "named.for" file contains the main forward lookup table, and for this network it could look like

 

@   IN    SOA   linux-1.e-nor.loc.  root.linux-1.e-nor.loc. (
                 1                   ; Serial number
                 3H                  ; Refresh after 3 hours
                 1H                  ; Retry after 1 hour
                 1W                  ; Expire after 1 week
                 3H                  ; Time to live is 3 hours
                 )

                 IN        NS        linux-1.e-nor.loc.
                 IN        MX        10 linux-1.e-nor.loc.
localhost        IN        A         127.0.0.1

linux-1          IN        A         192.192.192.193
alpha            IN        A         192.192.192.194
bravo            IN        A         192.192.192.195
charlie          IN        A         192.192.192.196
delta            IN        A         192.192.192.197
echo             IN        A         192.192.192.198
foxtrot          IN        A         192.192.192.199
golf             IN        A         192.192.192.200

www.e-nor.loc.   IN        CNAME     linux-1.e-nor.loc.
ftp.e-nor.loc.   IN        CNAME     linux-1.e-nor.loc.

  

The "named.rev" file contains the information for reverse lookups, and for this network could look like

 

@  IN   SOA   linux-1.e-nor.loc.  root.linux-1.e-nor.loc. (
                 1                   ; Serial number
                 3H                  ; Refresh after 3 hours
                 1H                  ; Retry after 1 hour
                 1W                  ; Expire after 1 week
                 3H                  ; Time to live is 3 hours
                 )

               IN        NS        linux-1.e-nor.loc.

193            IN        PTR       linux-1.e-nor.loc
194            IN        PTR       alpha.e-nor.loc.
195            IN        PTR       bravo.e-nor.loc.
196            IN        PTR       charlie.e-nor.loc.
197            IN        PTR       delta.e-nor.loc.
198            IN        PTR       echo.e-nor.loc.
199            IN        PTR       foxtrot.e-nor.loc.
200            IN        PTR       golf.e-nor.loc.

  

The "named.local" file provides reverse lookup for the local host, and again, for this network could look like

 

@  IN   SOA   linux-1.e-nor.loc.  root.linux-1.e-nor.loc. (
                 1                   ; Serial number
                 3H                  ; Refresh after 3 hours
                 1H                  ; Retry after 1 hour
                 1W                  ; Expire after 1 week
                 3H                  ; Time to live is 3 hours
                 )

               IN        NS        linux-1.e-nor.loc.
1.0.0          IN        PTR       localhost.

  

Configuring "named" is quite demanding - the information in the various files has to be in a very precise layout.

It can take several shots to get it to load without errors. Then it can be tested with "nslookup" entered at the server console, and it should all be working okay.

Thereafter it should also be functional okay for the other hosts on the network.

However there is a more rigorous testing programme called "Dig".

Dig is packaged with Caldera Linux 1.3 as standard, and looks more critically at all the file configurations.

Even though "nslookup" suggests everything is working fine, Dig may refuse to work. A common type of error may exist - to do with dots at the end of domain names, which are either there when they should not be, or are missing when they should be present.

In the file /etc/named.conf, there should be no dots after the domain names.

In the /var/named/named.* files, there should be dots after all domain names.

It is also worth mentioning that the names and the locations of the zone files are not fixed. In Caldera Linux 1.3, the directory /var/named/ is created by the installation process, but you don`t have to use it. The files can go elsewhere, and they can be called whatever you like - as long as the information in the /etc/named.conf matches.

 


© 2002 Ron Turner


Return to the Linux index page