HOWTO: Setup a Locally Authoritative DNS Server on Ubuntu 9.10

How to setup a locally authoritative DNS server on a LAN with Ubuntu 9.10. These instructions should work almost entirely on Ubuntu 10.x without modification.

# File:	HOWTO Setup a DNS Server on Ubuntu 9.10.notes
# Date:	2010/03/25
# Refs: https://help.ubuntu.com/8.04/serverguide/C/dns-installation.html
#       https://help.ubuntu.com/community/BIND9ServerHowto
# Desc:	Setting up a locally authoritative DNS server on a LAN with Ubuntu 9.10

# Install bind9 (the actual DNS server) and the dnsutils package
# (useful for testing and troubleshooting DNS issues). We 
# also install resolvconf so that we can manage the static
# IP DNS settings in /etc/network/interfaces since NetworkManager
# will stomp on any changes we make to /etc/resolv.conf
sudo apt-get install bind9 dnsutils resolvconf

# Establish a static IP for the nameserver by editing
# /etc/network/interfaces. In our setup, we have a multihomed
# machine with eth0 static on the trusted LAN and eth1 DHCP
# to the internet
auto eth0
iface eth0 inet static
    address 192.168.72.1
    netmask 255.255.255.0
    network 192.168.72.0
    gateway 192.168.72.254
    broadcast 192.168.72.255
    # dns-options are implemented by the resolvconf package
    dns-nameservers 192.168.72.1
    dns-search test.com

# Make the static IP changes take affect
# NOTE: You should be able to use 
# ifconfig <interface> down/up, but I found rebooting to be
# the only reliable way. Also, when these changes take effect,
# you'll have NO internet DNS yet, so beware.
sudo shutdown -r now

# For our setup here, I want to be an authoritative nameserver 
# on the local LAN, so I need at least 1 Forward Zone and
# 1 Reverse Zone for it. Our domain is test.com and our 
# subnet is 192.168.72.0. First we add the zones to
# /etc/bind/named.conf.local
zone "test.com" {
        type master;
        file "/etc/bind/db.test.com";
};

zone "72.168.192.in-addr.arpa" {
        type master
        notify no;
        file "/etc/bind/db.192";
};

# Use an existing zone file as a template
sudo cp /etc/bind/db.local /etc/bind/db.test.com

# Edit the /etc/bind/db.test.com file to fit our zone requirements
;
; BIND data file for test.com
;
$TTL    604800
@       IN      SOA     ns.test.com. root.test.com. (
                       20100325         ; Serial (YYYYMMDD)
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.test.com.
@       IN      A       192.168.72.1
ns      IN      A       192.168.72.1

; Hostname entries
hydrogen    IN  A       192.168.72.1
helium      IN  A       192.168.72.2
lithium     IN  A       192.168.72.3
beryllium   IN  A       192.168.72.4
boron       IN  A       192.168.72.5

# Use an existing reverse zone file as a template
sudo cp /etc/bind/db.127 /etc/bind/db.192

# Edit the Reverse Zone file for our reqs
;
; BIND reverse data file for test.com
;
$TTL    604800
@       IN      SOA     ns.test.com. root.test.com. (
                       20100325         ; Serial (YYYYMMDD)
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns.
1       IN      PTR     ns.test.com.

; Hostname RNL pointers
2       IN      PTR     helium.test.com.
3       IN      PTR     lithium.test.com.
4       IN      PTR     beryllium.test.com.
5       IN      PTR     boron.test.com.


# Start the bind9 daemon
sudo /etc/init.d/bind9 start

# Check the status of the server. You should get a big 
# printout from the local nameserver
dig @localhost

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.