Setting up a caching only name server 

http://www.mclink.it/personal/MG2508/nbsdeng/chap-dns.html

A caching only name server has no local zones; all the queries go to the root servers and the replies are accumulated in the local cache. The next time the query is performed the answer will be faster because the data is already in the server's cache. Since this type of server doesn't handle local zones, to resolve the names of the local hosts it will still be necessary to use the already known /etc/hosts file.

Since NetBSD supplies defaults for all the files needed by a caching only server, the configuration of this type of DNS is very easy, and can be performed with a few commands, without writing a single line in the configuration files.

Note: the number of the configuration files and their contents varies between versions of NetBSD.

The program which supplies the DNS server is the named daemon, which uses the named.conf configuration file for its setup. The default file supplied by NetBSD is located in the /etc/namedb directory, but the daemon looks for it in the /etc/ directory, so we start by creating a link:

# ln -s /etc/namedb/named.conf /etc/named.conf

The name server is ready for use! We can now tell to the system to use it adding the following line to the /etc/resolv.conf file:

nameserver 127.0.0.1

Now we can start named.

# named

Note: we have now started the name server manually. Once we have tested it and are confident that it works, we can launch it automatically at boot using the relevant option of the /etc/rc.conf file. 11.5.1. Testing the server

Now that the server is running we can test it using the nslookup program.

# nslookup
Default server: localhost
Address: 127.0.0.1
>

Let's try to resolve an host name, for example www.mclink.it (try a site near you.)

> www.mclink.it
Server:  localhost
Address:  127.0.0.1
Name:    www.mclink.it
Address:  195.110.128.8

If you repeat the query a second time, the result is slightly different:

> www.mclink.it
Server:  localhost
Address:  127.0.0.1
Non-authoritative answer:
Name:    www.mclink.it
Address:  195.110.128.8

As you've probably noticed, the address is the same, but the message "Non-authoritative answer", has appeared. This message indicates that the answer is not coming from an authoritative server for the domain mclink.it but from the cache of our own server.

The results of this first test confirm that the server is working correctly.

We can also try the host command, which gives the following result.

# host www.mclink.it
www.mclink.it has address 195.110.128.8