Notes on DNS—details for turning into a DNS server

Russ Bateman
2 May 2013
last update:

This is very tentative and unfinished; it's mostly research right now.

You may be looking for this post:
Failure to ping outside of LAN, ping


First, discover your existing DNS service by it primary and secondary IP addresses:

    root@af-blackpearl:/etc/bind# cat /etc/resolv.conf
    nameserver                <---------- primary DNS server
    nameserver                <---------- secondary DNS server

Assume all commands here from root...

  1. Install DNS server.
        $ apt-get install bind9 dnsutils
  2. Modify /etc/hosts (maybe not!?)       localhost.localdomain    localhost   af-blackpearl
  3. Edit named.conf.options to add forwarders to use in case your additional DNS settings don't cover what's asked for.
        $ vim /etc/bind/named.conf.options
    At this point, there is something different to do if the host your new DNS server is running on gets its IP address via DHCP (dynamically) or just has its own static IP address. If dyanmic, please see this URL:

  4. Edit /etc/network/interfaces. Change or add the following directives (in bold).
        # This file describes the network interfaces available on your system
        # and how to activate them. For more information, see interfaces(5).
        # The loopback network interface
        auto lo
        iface lo inet loopback
        # The primary network interface
        auto eth0
        #iface eth0 inet dhcp		(originally DHCP; we want static IP now...)
        iface eth0 inet static
    	    dns-nameservers 127.0.1
        # Use this address for our Tomcat ReST URIs!
        #auto eth0:0
        #iface eth0:0 inet static
        #	address
        #	netmask
  5. Define zones for the new, local domain in named.conf.local.
        zone "" IN
            type master;
            file "/etc/bin/zones/";
  6. Also, add a zone for reverse DNS look-ups on the local network. If this looks funny, it's because the IP address is backwards (on purpose).
        zone ""
            type master;
            file "/etc/bind/zones/";
  7. Create subdirectory zones.
        $ mkdir /etc/bind/zones
  8. Create the local domain database. There are some comments here you can add in case you ever need to edit this file. See especially Howto: Setup a DNS server with bind here.
        $ cd zones
        $ vim
        ; Use semicolons to add comments.
        ; Host-to-IP Address DNS Pointers for
        ; Note: The extra dots at the end of the domain names are important.
        ; The following parameters set when DNS records will expire, etc.
        ; The serial number must always increase to prevent undesirable
        ; consequences. A good format to use is YYYYMMDDII where the II index
        ; is in case you make more than one change on the same day.
        $ORIGIN .
        $TTL 86400      ; 1 day IN SOA
            2008080901 ; serial
            8H ; refresh
            4H ; retry
            4W ; expire
            1D ; minimum
        ; NS indicates that Ubuntu is the name server on
        ; MX indicates that Ubuntu is (also) the mail server on IN NS IN MX 10
        ; Set the address for
        localhost    IN A
        ; Set the hostnames in alphabetical order
        print-srv    IN A
        router       IN A
        server       IN A
        ubuntu       IN A
        xbox         IN A
  9. Create the reserve look-up database. (I'm not adding the comments).
        ; IP Address-to-Host DNS Pointers for the 16.86.192 subnet
        @ IN SOA
            2008080901 ; serial
            8H ; refresh
            4H ; retry
            4W ; expire
            1D ; minimum
        ; define the authoritative name server
                   IN NS
        ; our hosts, in numeric order
        1         IN PTR
        2         IN PTR
        3         IN PTR
        5         IN PTR
        9         IN PTR
  10. Restart the bind9 service to use the new settings.
        $ service bind9 restart
        - or -
        $ /etc/init.d/bind9 restart
  11. Restart the network interface
    $ nohup sh -c "ifdown eth0 && ifup etch0"

    --this has been deprecated if you're using DHCP. See

  12. Change /etc/resolv.conf?

    instead of it continuing to use what's been (before setting up local DNS).

    Warning: Most *nicies have changed how /etc/resolv.conf works! Please see here.

  13. Check out that host works. (Much to be changed here.)
        $ host

    The response should be has address has IPv6 address blah:blah:blah::blah

  14. Test that computers at are listed. (Much to be changed here.)
        $ host -l name server has address has address has address has address has address has address
  15. Step. Test reverse look-up.
        $ host
    domain name pointer

Last, a firewall is needed if this is being done behind a router at home to keep from exposing your network. Port 53 nust not be forwarded to your DNS server!