How-to configure DNS and DHCP Server Ubuntu Server 11.04

Today we build a DNS and DHCP Server with Ubuntu 11.04. The goal is to have a DNS server for your local LAN with automatically updated DNS addresses for DHCP clients and the DNS caching feature activated. I used some example addresses, which your to replace with yours.

  • Install Ubuntu and choose “DNS Server” during the setup routine
  • Change your NIC to static IP
  • Install with apt-get install “dhcpd” and if not already done “bind9”
sudo apt-get install dhcpd
sudo apt-get install bind9
  • Open “/etc/dhcp/dhcpcd.conf” with your preferred editor and add the following lines:
    ddns-update-style interim;
    ddns-updates on;
    ignore client-updates;
    option domain-name “”;
    option domain-name-servers;
    ddns-rev-domainname “”;
    option routers;
    option broadcast-address;
    include “/etc/bind/rndc.key”;
    zone {
            key “rndc-key”;
    zone {
            key “rndc-key”;
    log-facility local7;
    default-lease-time 172800;
    max-lease-time 604800;
    subnet netmask {
  • Add the follgwing lines to “/etc/bind/named.conf.options” between the “options”:
allow-query {
 forwarders {
  • Create a file under “/etc/bind/” named like “” and add the following lines:
$TTL    3600  IN  SOA (
                       20100112;   Serial
                       10800   ;   Refresh
                       3600    ;   Retry
                       604800  ;   Expire
                       86400   ;   Minimum TTL
; DNS servers          IN      NS
; Machine names   IN      A
; Aliases
ns1                   IN      CNAME
; MX record
;          IN      MX     10
  • Next create a file under “/etc/bind/” named like “db.192.168.1” and add the following lines:
$TTL    3600    IN    SOA (
                            20090504;               Serial
                            10800   ;               Refresh
                            3600    ;               Retry
                            604800  ;               Expire
                            86400   ;               Minimum TTL
; DNS servers         IN      NS
; Machine IPs
1                               IN      PTR
1                               IN      PTR
  • Add the following lines to “/etc/bind/named.conf.local”:
zone “” {
  type master;
  file “/var/cache/bind/”;
  allow-update { key “rndc-key”; };
zone {
  type master;
  file “/var/cache/bind/db.192.168.1”;
  allow-update { key “rndc-key”; };
include “/etc/bind/rndc.key”;
controls {
        inet port 953
        allow {; } keys { “rndc-key”; };
  • Create two symbolic links for the “caching” and “ddns” feature:

ln -sf /etc/bind/ /var/cache/bind/

ln -sf /etc/bind/db.192.168.1 /var/cache/bind/

  • Create the key for interfacing DHCPD and BIND9
rndc-confgen -a
rndc-confgen -r /dev/urandom -a
  • You have to modify the permission
sudo chown root:bind /etc/bind/rndc.key
sudo chmod 644 /etc/bind/rndc.key
  • Next modify “/etc/apparmor.d/usr.sbin.dhcpd3”
/etc/bind/ r,
/etc/bind/** r,
  • Last restart all three services
sudo /etc/init.d/apparmor restart
sudo /etc/init.d/isc-dhcp-server restart
sudo /etc/init.d/bind9 restart
  • Now you are ready to user your own DNS Server with DHCP, caching and automatic registering DHCP Client to your DNS server
  • If you find any failures or not used or necessary settings, please write in the comments or send me a mail, I will correct it immediately



3 thoughts on “How-to configure DNS and DHCP Server Ubuntu Server 11.04

  1. hi

    i followed this guide to get my local LAN up and running. all 3 daemons were able to restart ok (initially had issues with DNS config syntax, as I had followed an earlier static DNS guide until I realised it didn’t do what i wanted).

    all devices seem to get allocated a DHCP lease, but they do not get registered dynamically into DNS. could you offer where to look for or what to change to enable better logging to see what the issue(s) are?

    I have hard-coded the DNS server’s record itself into my /etc/bind/zones/jingo.local.db file and any DHCP clients are able to resolve this ok, as:

    ; Machine names
    jingoserver.jingo.local. IN A

    hoping you can help. i am so close…


    • Hi Dan,
      I am not sure if I understood all your steps correct but I can imagine what the issue are, I did it also wrong at the beginning.

      You should not modify by hand any of the zone files because otherwise the zone files are corrupt for ISC-DHCP daemon and he is no able to update the files.

      To add static entries to your zone file you have to use your the command “nsupdate”. I don’t have the exact syntax for you now, but if you give me a few days, I will write a detailed blog post. If you can’t wait and you have the syntax, please post it at this place.

      Last, I need definitely to review the article, I did some mistake at the How-to. In short words, the zone files should you create add /var/cache/bind/ and the symbolic links you should place under /etc/bind. Otherwise the the zone files will be always overwritten.

      Hope that helps, cheers.

  2. thanks for the quick reply.

    i started following some other guides from further searching. the main source i used was this:

    which was very similar to your own, though i guess used the amendments you mentioned.

    though i had some errors in my DNS config files, which i also corrected using the log files to troubleshoot, i think the main problem was the following section in my dhcpd.conf file:

    zone jingo.local. {
    key “rndc-key”;

    i had this pointed at an unused IP address originally, following your guide word-for-word ( resetting this to the loopback address (guess could have also used which is my server) and restarting the daemon, all dhcp clients now register in dns.

    the new registrations cannot be viewed in the /var/cache/bind/zone.db file. i think its contained the /var/cache/bind/zone.db.jnl file, though this easily viewable. is it dynamic or encoded or something?

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s