Setting up a caching name server on your network will speed up internet
traffic by eliminating hostname lookups for each domain accessed. The
caching DNS server must initially query another DNS server to find the
IP of a domain name but once the initial lookup is performed, the IP
address of that domain is stored in memory (RAM) cache for the duration
of the named daemon's uptime. That means that if you access a specific
domain multiple times, you can eliminate the wait period usually associated
with checking a primary DNS server. Without the caching domain server, each
connection queries the primary DNS server for the IP address of the domain
this process has some overhead, especially if the primary DNS is busy.
You will need the proper software for the DNS server setup. The required
package is called 'bind' which includes the daemon called 'named'. You may
have the bind package already installed if you use a popular distribution
such as Redhat or Debian. You will want to make sure you are using bind
version 8 or up.
The primary configuration for the named daemon is called "/etc/named.conf".
The configuration should be similar to the following...
/etc/named.conf:
options {
directory "/var/named";
};
zone "." {
type hint;
file "root.hints";
};
zone "0.0.127.in-addr.arpa" {
type master;
file "127.0.0";
};
The 'directory' line within the options{} area tells the named daemon where
to look for files you specify in the other areas. Although you can set the
default directory to any directory you want, the "/var/named" directory is
the standard according to the "Linux File system Standard".
The root.hints file describes the root name servers for the internet. It's
syntax is beyond the scope of this document. It can be made simply by
using the command:
% dig > /var/named/root.hints
...or...
% dig @rs.internic.net . ns > root.hints
The file root.hints changes over time and must be updated and maintained.
It will not be something that changes regularly though. To update the file,
simply run the command above and restart the named daemon.
The 127.0.0 file specified in the named.conf file should have the following
contents...
@ IN SOA ns.linux.lan. root.linux.lan. (
1 ; Serial
8H ; Refresh
2H ; Retry
1W ; Expire
1D) ; Minimum TTL
@ IN NS ns.linux.lan.
1 IN PTR localhost.
Using Named
Connect to the internet and start the named server if it hasn't been
configured to start automatically. To start named, use the following
command...
% /etc/sbin/ndc start
To test your setup, use the nslookup program. You will notice that once you
query a domain name, you will get an output as follows...
% nslookup
> www.zebra.net
Server: localhost
Address: 127.0.0.1
Name: www.zebra.net
Address: 206.206.206.23
Now, try it again using the same domain...
> www.zebra.net
Server: localhost
Address: 127.0.0.1
Non-authoritative answer:
Name: www.zebra.net
Address: 206.206.206.23
Notice the "Non-authoritative answer:" line on the second try. This means
that the named daemon did not go out into the internet to ask a primary DNS
server about the domainname. This also means that the domainname's IP
address is in cache now. Did you notice how much faster the second try
returned the the IP information? That is the amount of time saved each
time you click a link on a web page or connect an ftp address, etc.
/etc/resolv.conf:
domain yourdomain.edu
search subdomain.yourdomain.edu yourdomain.edu
nameserver 127.0.0.1
nameserver 206.124.64.253
nameserver 206.124.65.253
The search line specifies what domains should be searched for any hostnames
you want to connect to. The nameserver line specifies nameservers to query
to resolve hostnames to IP addresses.
The search line will be used as follows: If a client tries to look up a
machine named 'quartz' then quartz.subdomain.your-domain.edu is tried
first, then it will try to look for quartz.your-domain.edu next. This
also means that if a client looks for www.yahoo.com, the DNS server will
try www.yahoo.com.sub.your-domain.edu, then www.yahoo.com.your-domain.edu,
this can take time so be careful not to include too many search domains.
If you frequently contact hosts in another domain you can add the domain to
the search line as well.
/etc/host.conf or /etc/nsswitch.conf:
Which file we will deal with depends on which libc version you have. If you
have "/etc/nsswitch.conf", we will want to edit it, otherwise you should
skip to the "/etc/host.conf" file configuration.
In the "/etc/nsswitch.conf" file, look for a line starting with 'hosts:' and
make sure it reads as follows...
hosts: files dns
If you do not have this line in your nsswitch.conf file, then add it. This
states that programs should first look in the "/etc/hosts" file, then check
DNS according to resolv.conf.
The "/etc/host.conf" should have a line that starts with 'order', it should
look like this...
order hosts,bind
If you do not have this line, you should add it. This line tells the
hostname resolving routines to first look in "/etc/hosts", then ask the
nameservers you specified in resolv.conf.
Using Forwarders
In large networks, DNS administrators often setup the forwarders{} hiearchy
to lighten the load on the internal DNS servers. By using the DNS servers
of your network provider as forwarders, you can make DNS queries faster.
The syntax for using forwarders is in your named.conf file in the options{}
area. You can either use the ISP DNS servers or if you are on a subnet, use
the next networks DNS servers...
forward first;
forwarders {
10.0.0.1;
10.1.0.1;
};
Once you add this configuration to the named.conf file, restart the named
daemon to activate the changes.
Notes:
If you are using a firewall and are having problems accessing the DNS
server, you will want to specify the port in the "/etc/named.conf" file.
Place the following lines in the options{} area...
forward only;
forwarders {
10.0.0.1;
10.1.0.1;
};
query-source port 53;
The DNS Server uses a daemon called 'named' or NAME Daemon.
The named daemon stores it's DNS cache in memory.
There is no way to save the cache for machine restarts,
therefore, each restart begins a new DNS cache in RAM.
The named daemon's default configuration file is located in /etc:
/etc/named.conf
'ndc' calls the Name Server Daemon 'named':
% ndc start
% ndc restart
All arguments to ndc after the first are passed to named:
% ndc start /var/named/named.conf
% ndc restart /var/named/named.conf
To update root.hints|named.cache, use the 'dig' application:
% dig @a.root-servers.net > /var/named/root.hints
% dig @a.root-servers.net . ns > root.hints.new
Replace root.hints with root.hints.new.
Restart ndc.
The default location for named.conf is /etc.
notify no;
# Tells named not to notify its secondary (slave) servers
# when it has rx an update to a zone file.
Reverse Lookups:
% nslookup
> 192.168.196.4
> ls -d 196.168.192.in-addr.arpa