From last few days I am using Ubuntu as my primery OS at home. So try to setup Dynamic DNS and DHCP server on Ubuntu 10.10.

Required Packages:
bind9
dhcp3-server

Installing required packages

apt-get install bind9 dhcp3-server

Configuring Bind
First you need to make changes in /etc/hosts and /etc/resolv.conf

vi /etc/hosts
127.0.0.1	localhost
192.168.1.2	vidyadhar.home.network	vidyadhar
vi /etc/resolv.conf
nameserver 127.0.0.1

I choose domain name as home.network
Create forward lookup zone file name db.home.network in /etc/bind.

vi /etc/bind/db.home.network
home.network.           IN SOA  vidyadhar.home.network. vidyadhards@gmail.com. (
                                1          ; serial
                                10800      ; refresh (3 hours)
                                3600       ; retry (1 hour)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
home.network.                           IN      NS   vidyadhar.home.network.
localhost.home.network.                 IN      A    127.0.0.1
vidyadhar.home.network.         IN      A    192.168.1.2

Create reveresed lookup zone file name db.192.168.1 in /etc/bind

vi /etc/bind/db.192.168.1
1.168.192.in-addr.arpa.     IN SOA  vidyadhar.home.network. vidyadhards@gmail.com. (
                                1          ; serial
                                10800      ; refresh (3 hours)
                                3600       ; retry (1 hour)
                                604800     ; expire (1 week)
                                86400      ; minimum (1 day)
                                )
1.168.192.in-addr.arpa.		IN	NS   vidyadhar.home.network.
2.1.168.192.in-addr.arpa.	IN	PTR  vidyadhar.home.network.

Make changes in named.conf.local

vi /etc/bind/named.conf.local
zone "home.network" in {
        type master;
        file "/etc/bind/db.home.network";
        allow-update { key "rndc-key"; };
        notify yes;
};

zone "1.168.192.in-addr.arpa" in {
        type master;
        file "/etc/bind/db.192.168.1";
        allow-update { key "rndc-key"; };
        notify yes;
};

include "/etc/bind/rndc.key";

Configuring dhcp server

vi /etc/dhcp3/dhcpd.conf
# Basic stuff to name the server and switch on updating
server-identifier       192.168.1.2;
ddns-updates            on;
ddns-update-style       interim;
ddns-domainname         "home.network.";
ddns-rev-domainname     "in-addr.arpa.";
# Ignore Windows FQDN updates
ignore                  client-updates;

# Include the key so that DHCP can authenticate itself to BIND9
include                 "/etc/bind/rndc.key";

# This is the communication zone
zone home.network. {
        primary 127.0.0.1;
        key rndc-key;
}

# Normal DHCP stuff
option domain-name              "home.network";
option domain-name-servers      192.168.1.2;
option ip-forwarding            off;

default-lease-time              600;
max-lease-time                  7200;
log-facility			local7;
allow booting;
allow bootp;

# Tell the server it is authoritative on that subnet (essential)
authoritative;
subnet 192.168.1.0 netmask 255.255.255.0 {
        range                           192.168.1.50 192.168.1.254;
        option broadcast-address        192.168.1.255;
        option routers                  192.168.1.1;
        allow                           unknown-clients;
        filename "pxelinux.0";
        next-server 192.168.1.2;

        zone 1.168.192.in-addr.arpa. {
                primary 192.168.1.2;
                key "rndc-key";
        }

        zone localdomain. {
                primary 192.168.1.2;
                key "rndc-key";
        }
}

Changes in named.conf.options

vi /etc/bind/named.conf.options
options {
        directory "/var/cache/bind";

        // If there is a firewall between you and nameservers you want
        // to talk to, you may need to fix the firewall to allow multiple
        // ports to talk.  See http://www.kb.cert.org/vuls/id/800113

        // If your ISP provided one or more IP addresses for stable
        // nameservers, you probably want to use them as forwarders.
        // Uncomment the following block, and insert the addresses replacing
        // the all-0's placeholder.
        // allow localhost to perform updates

        forwarders {
                8.8.8.8;8.8.2.2;
        };

        auth-nxdomain no;    # conform to RFC1035
        listen-on-v6 { any; };
};

        controls {
        inet 127.0.0.1 allow { localhost; } keys { "rndc-key"; };
        };

Assign permissionz

chmod g+w /etc/bind
chmod +r /etc/bind/rndc.key

Apparmour changes
Add following line in apparmour before closing “}”

vi /etc/apparmor.d/usr.sbin.dhcpd3
/etc/bind/ rw,
/etc/bind/** rw,

Now start dhcp & bind

/etc/init.d/apparmor restart
/etc/init.d/dhcp3-server start
/etc/init.d/bind9 restart

For troubleshooting you can check /var/log/daemon.log file

DDNS & DHCP server on Ubuntu
Tagged on:                                                                             

6 thoughts on “DDNS & DHCP server on Ubuntu

    • January 3, 2011 at 9:46 am
      Permalink

      I dont agree… Is there any specific reason to do so?

      Reply
  • January 16, 2011 at 2:19 am
    Permalink

    Absolutely fantastic. You, sir, are a God among men. This saved me twice in the last few weeks when my old Fedora 7 gateway machine went down (twice!) and I had to rebuild using Ubuntu 10.04 LTS. My one comment is that it seems the original design of the DNS package does point to storing the zone files in /var/lib/bind.

    My evidence is found in package default /etc/apparmor.d/usr.sbin.named in which the following two lines show the intent of the designers to store zones in that directory.

    /var/lib/bind/** rw,
    /var/lib/bind/ rw,

    I fought with the apparmor settings trying to get it to read zone files out of /etc/bin for a while before giving up and moving them to /var/lib/bind.

    I am sure it’s possible to get them there as it appears you did it but I had less of a fight with apparmor by doing it the “approved” method.

    Reply
  • Pingback:Mehrdust » Blog Archive » DHCP server on ubuntu

  • Pingback:DHCP & Dynamic DNS in Ubuntu 10.10 | Cumptrnrd's Blog

  • Pingback:DynDNS DHCP Bind – Ubuntu 14.04 Trusty | Cymea Blog

Leave a Reply

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