Configuring DNS services (revision 4.1)

Introduction

This page describes how Alexis Huxley installed and configured his DNS server.

Procedure

  1. Install the packages required for the DNS server by running:
    apt -y install bind9 dnsutils
  2. Disable IPv6 support by completing this sub-procedure:
    1. Edit /etc/default/named and add to OPTIONS:
      OPTIONS="... -4 ..."
    2. Edit /etc/bind/named.conf.options and comment out:
      // listen-on-v6 { any; };
    3. In the same file, also inside the options { ... }; stanza, add:
      filter-aaaa-on-v4 yes;
  3. Run a script to initialise the zones:
    svn co https://svn.pasta.freemyip.com/main/smalltools/trunk ~/opt/smalltools
    ~/opt/smalltools/bin/dns-edit-zones
    

    and then follow the prompts.

  4. Rerun the same script to and populate the zone files.
  5. Test with:
    host $(hostname -f) localhost
    host $(host $(hostname -f) localhost | sed -n 's/.* has address //p') localhost
  6. To allow systemctl reload bind9 to work (which uses rndc to communicate with named):
    1. Run:
      rndc-confgen
      
    2. Copy the first part of the output into /etc/bind/rndc.conf.
    3. Copy the second part of the output into /etc/bind/named.conf.options, but put it outside the options { ... }; stanza.
    4. Run:
      systemctl restart bind9
    5. Test by running:
      systemctl reload bind9
      
  7. Modify /etc/resolv.conf to set:
    nameserver 127.0.0.1.
    
  8. Modify /etc/resolv.conf on all other hosts (including the old DNS server) with static IP configuration to set:
    nameserver <ip-of-this-new-DNS-server>

    (For the old dhcpd server on the network this is effectively the same as shutting down that service.)

  9. If there is a DHCP server on the network then update the IP that it sends as the DNS server that DHCP clients should use.
  10. If you wish to:
    • access your systems’ “public” hostnames from inside the home network, or
    • blacklist certain external hostnames (e.g. google-analytics.com)

    then see here.

    See also