How to setup DHCP Server and Dynamic DNS with BIND?

Install the needed packages:

sudo aptitude install bind9 isc-dhcp-server

Configure DNS:

sudo vi /etc/bind/named.conf.options

>   options {
>     directory "/var/cache/bind";
>     auth-nxdomain no;    # conform to RFC1035
>     forwarders {
>         192.168.100.1;
>         };

Dynamic Updating DNS:

sudo /usr/sbin/rndc-confgen -a

This will create a file named rndc.key, whose contents will look something like this:

  key "rndc-key" {
        algorithm hmac-md5;
        secret "idz+GGAJRtrqz4j4kZ3DjQ==";
  };

Creating DNS Zones_Forward Zone:

sudo vi /etc/bind/named.conf.local

  key "rndc-key" {
         algorithm hmac-md5;
        secret "idz+GGAJRtrqz4j4kZ3DjQ==";
  };

  zone "itkylin.com" {
  type master;
  file "/etc/bind/db.itkylin.com"; 
  };

DNS Zones population_Forward zone:

sudo cp /etc/bind/db.local /etc/bind/db.itkylin.com
sudo vi /etc/bind/db.itkylin.com

  key "rndc-key" {
         algorithm hmac-md5;
        secret "idz+GGAJRtrqz4j4kZ3DjQ==";
  };

  zone "itkylin.com" {
  type master;
  file "/etc/bind/db.itkylin.com"; 
  };

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

DNS Zones population_Reverse zone:

sudo cp /etc/bind/db.127 /etc/bind/db.192
sudo vi /etc/bind/db.192

  $TTL  604800
  @ IN  SOA ns.itkylin.com. root.itkylin.com. (
                  1     ; Serial
             604800     ; Refresh
              86400     ; Retry
            2419200     ; Expire
             604800 )   ; Negative Cache TTL
  ;
  @ IN  NS  ns.
  1 IN  PTR ns.itkylin.com.
  2 IN  PTR ibr.itkylin.com.

Now create links for the zone files in the /var/ directory

sudo ln -sf /etc/bind/db.itkylin.com /var/lib/bind/
sudo ln -sf /etc/bind/db.itkylin.com /var/cache/bind/
sudo ln -sf /etc/bind/db.192 /var/lib/bind/
sudo ln -sf /etc/bind/db.192 /var/cache/bind/

Configuring DHCP:

sudo vi /etc/dhcp/dhcpd.conf

 #GLOBAL OPTIONS 
  ddns-updates on;
   ddns-update-style interim;
  update-static-leases on;
  authoritative;
  key "rndc-key" {
        algorithm hmac-md5;
        secret "idz+GGAJRtrqz4j4kZ3DjQ==";
  };
  allow unknown-clients;
  use-host-decl-names on;
  default-lease-time 1814400; #21 days
  max-lease-time 1814400; #21 days
  log-facility local7;

  #Building DNS Zones
  zone    itkylin.com. {
            primary localhost;
            key rndc-key;
    }
    zone 100.168.192.in-addr.arpa. {
            primary localhost;
            key rndc-key;
    }

  #Building LAN Scope
  subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.20 192.168.100.50;
  option subnet-mask 255.255.255.0;
  option routers 192.168.100.1;
  option domain-name-servers 192.168.100.1;
  option domain-name "itkylin.com";
  ddns-domainname "itkylin.com.";
  ddns-rev-domainname "in-addr.arpa.";
  }