Caching DNS Server on FreeBSD
Introduction:
This article describes how to setup a caching DNS server. This is the simplest setup of a server that
is not authorative on any particular zone but simply makes queries of other DNS servers and caches the
result for local clients. It is written specifically for the operating system version shown below but
will probably work on later versions with little deviation.
Software:
Operating System: | FreeBSD 6.1 for i386 | Download |
Before you begin:
-
You should already have the operating system installed and working.
You should be logged on as root or as a user with root privileges.
Configuring named & local resolution
-
Change to the namedb directory and create a local reverse DNS zone file by entering the commands:
cd /var/named/etc/namedb/
sh make-localhost
|
-
Edit /var/named/etc/namedb/named.conf an search for the section:
// If named is being used only as a local resolver, this is a safe default.
// For named to be accessible to the network, comment this option, specify
// the proper IP address, or delete this option.
listen-on { 127.0.0.1; };
|
As the comment says, if the DNS server is only to be used
by the computer it is installed on, you can leave this
if you want other computers to be able to query the server
you should comment out this line as shown:
// If named is being used only as a local resolver, this is a safe default.
// For named to be accessible to the network, comment this option, specify
// the proper IP address, or delete this option.
// listen-on { 127.0.0.1; };
|
-
Now search for a section that reads:
// If you've got a DNS server around at your upstream provider, enter
// its IP address here, and enable the line below. This will make you
// benefit from its cache, thus reduce overall DNS traffic in the Internet.
/*
forwarders {
127.0.0.1;
};
*/
|
Again, as the comment says, if you have access to a DNS server
hosted by your ISP you can have your server query that one instead
of the root servers. If you want to do this you should change this
section so it looks like the example below, subtituting the IP
address of your ISP's DNS server:
// If you've got a DNS server around at your upstream provider, enter
// its IP address here, and enable the line below. This will make you
// benefit from its cache, thus reduce overall DNS traffic in the Internet.
forwarders {
111.222.33.4;
};
|
Note: You must remove the /* and */ comment marks or
this setting will be ignored.
-
Edit /etc/resolv.conf and set your DNS server to localhost by searching for
the line beginning with nameserver and changing it to read:
Enabling and starting named
-
Enable the named daemon on startup by editing /etc/rc.conf and adding the line:
-
To save you rebooting, you can start the named daemon manually by entering the command:
/usr/sbin/named -u bind -t /var/named
|
Addendum
-
Document Version: 1.1.0
-
Changes:
-
References:
|