Setting up Raspberry Pi as a DHCP, NTP, and DNS server

Installing the Name Server

The Bind9 (Berkeley Internet name service) package is responsible for name resolution. Bind9 is pretty easy to install with apt-get. You need to make sure your Rasp Pi has a large enough SD card (4GB or more, or preferably 16GB). Additionally, you should install the DNS-utils to provide useful commands, such as nslookup and dig. A check with nslookup shows that the Rasp Pi is still using the DSL server as its master, so I need to modify /etc/resolv.conf. You can find directories of free name server addresses online. For my location, I found name servers through sites such as http://www.freie-nameserver.de/ or http://www.ungefiltert-surfen.de/nameserver/de. I can then enter these name servers in the /etc/resolv.conf file (Listing 6).

The Local Zone

To understand the names of the devices on my own network, I need to add a local zone. First, I add the line listen-on port 53 {any;}; to /etc/bind/named.conf.options, and reference to the zone files in /etc/bind/named.conf.local. I then create the zone files with the names and IP addresses of all the devices on the home network (Listing 7), as well as the associated reverse zone file (Listing 8). The dots in lines like homenet.de. are important. If the dot is missing at the end, the system appends the domain name (homenet.de), and then the name no longer matches.

If you are interested in more details of BIND configuration, the content of the files presented here, and the importance of each entry, I recommend the DNS & BIND Cookbook[3]. If you want to completely immerse yourself in the functionality of the domain name service, I recommend DNS & BIND[4].