Chase H.Q.

Caching DNS Server on FreeBSD

  1. Introduction:

  2. 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.

  3. Software:

  4. Operating System:FreeBSD 6.1 for i386Download

  5. Before you begin:

    1. You should already have the operating system installed and working. You should be logged on as root or as a user with root privileges.
  6. Configuring named & local resolution

    1. 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
      
    2. 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; };
      
    3. 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.
    4. Edit /etc/resolv.conf and set your DNS server to localhost by searching for the line beginning with nameserver and changing it to read:
      nameserver 	127.0.0.1
      
  7. Enabling and starting named

    1. Enable the named daemon on startup by editing /etc/rc.conf and adding the line:
      named_enable="YES"
      
    2. To save you rebooting, you can start the named daemon manually by entering the command:
      /usr/sbin/named -u bind -t /var/named
      
  8. Addendum

    1. Document Version: 1.1.0
    2. Changes:
      • 1.1.0
        • Updated for FreeBSD 6.1
    3. References: