Setting up a caching name server is easy and fun. Well it's easy. All you need to do is install the name server software, copy the configuration file provided here to the appropriate location, start the name server program, and make a simple change to your resolver configuration.
Here are a couple of examples of how to install the the name server software on linux. If you're not using either of those systems use your favorite internet search engine to find instructions for installing the software on your system (try searching for "install bind dns OS name").
debian or *buntu linuxThe packages to install are bind9 and dnsutils. There are a number of package managers on debian-based systems - use your favorite to install those two packages. Here's an example using apt-get:
redhat or centos linuxapt-get install bind9 dnsutilsThe packages to install are bind and bind-utils. Install them with yum like this:
yum install bind
yum install bind-utils
This file tells the name server how to behave. It's usually /etc/named.conf, but sometimes /etc/bind/named.conf. Put a copy in /etc and if your system has /etc/bind, put a copy there too (the extra copy won't hurt anything).
If you've installed the name server software using your system's package management system it probably installed a script to run the name server when the system is started. So a simple way to start the name server is to reboot. Otherwise you'll need to find the script and and run it. You'll probably want to find it eventually anyway, so perhaps digging it up right away would be best.
After the name server is started, test it using the dig command:
dig @127.0.0.1 argus.stanford.edu
You should get an answer that looks something like this (the important
bits are in green):
All that's left is to update your resolver configuration to use the newly installed local caching name server.; <<>> DiG 9.9.5-9-Debian <<>> @127.0.0.1 argus.stanford.edu ; (1 server found) ;; global options: +cmd ;; Got answer: ;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 65485 ;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0 ;; QUESTION SECTION: ;argus.stanford.edu. IN A ;; ANSWER SECTION: argus.stanford.edu. 1800 IN A 171.64.7.115 ;; Query time: 0 msec ;; SERVER: 127.0.0.1#53(127.0.0.1) ;; WHEN: Tue Aug 11 15:48:45 PDT 2015 ;; MSG SIZE rcvd: 52
This file tells a system which name servers to use. In order for a host to use its own name server the loopback address, 127.0.0.1, must be listed as the first name server in the file.
Now that the local name server is first in the resolver configuration it's important that the name server starts when the system boots. Make sure the system is configured so that happens. Reboot the system to make sure.
/etc/named.conf or maybe /etc/bind/named.conf (download)
Configuration Files/etc/resolv.conf (download)// // named.conf file for local caching servers at Stanford // forwarding only - even works on hosts using RFC 1918 addresses // options { // *local queries only* listen-on-v6 { ::1; }; listen-on { 127.0.0.1; }; allow-query { ::1; 127.0.0.1; }; // forward *only* and use the Stanford anycast DNS service as forwarders forward only; forwarders { 2607:f6d0:0:53::67:53; 2607:f6d0:0:53::64:53; 171.64.1.234; 171.67.1.234; }; // rely on the forwarders for DNSSEC validation dnssec-validation no; }; // this is a very simple server, so turn off remote administration controls {};Use this file as-is or add the nameserver entries to your /etc/resolv.conf before any other nameserver entries.
# resolver configuration file for systems with a local caching server domain stanford.edu search stanford.edu sunet # local server first, then the Stanford anycast service IPs nameserver 127.0.0.1 nameserver 171.64.1.234 nameserver 171.67.1.234