How to configure DNS Server in Ubuntu 14.04 LTS

To configure DNS server in Ubuntu 14.04

After installing ubuntu 14.04 LTS and check the hostname, while installing itself, we can give preferred hostname or else post installaton also, we can change as follows,

$ sudo cat /etc/hostname

Ubuntuclient

change the system  by following executing following commands

$ sudo vi /etc/hostname

ns1.example.com

$ sudo vi /etc/hosts

192.168.5.100 ns1.example.com

$ sudo apt-get update

(system will update it’s repositories through terminal)

$ sudo apt-get install bind9 bind9utils bind9-doc

(We need to install bind9, bind9utils, bind9-doc packages)

$ sudo vi /etc/default/bind9

(We need to set IPV4 mode to  bind and to do the same , edit following bind9 file using vi editor , change in following line)

OPTIONS=”-4 -u bind”

SAVE and EXIT file

Now, bind has been installed and need to configure Primary DNS Server

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

(Insert following lines in named.conf.options file at the end of the file – creating access list “trusted”)

====================================================================

acl “trusted” {
192.168.5.100; # ns1 – can be set to localhost
192.168.5.101; # ns2
};

====================================================================

options {
directory “/var/cache/bind”;

recursion yes;                                # enables resursive queries
allow-recursion { trusted; };    # allows recursive queries from “trusted” clients
listen-on { 192.168.5.100; };     # ns1 private IP address – listen on private network only
allow-transfer { none; };           # disable zone transfers by default

forwarders {
8.8.8.8;
8.8.4.4;
};

====================================================================

Locate following file /etc/bind/named.config.local

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

zone “ns1.example.com” {
type master;
file “/etc/bind/zones/db.ns1.example.com”; # zone file path
allow-transfer { 192.168.5.101; }; # ns2 private IP address – secondary
};

zone “5.100.in-addr.arpa” {
type master;
file “/etc/bind/zones/db.5.100”; # 192.168.5.100/24 subnet
allow-transfer { 192.168.5.101; }; # ns2 private IP address – secondary
};

$ sudo mkdir /etc/bind/zones

(Create folder named ‘zones’ inside /etc/bind directory)

$ sudo vi /etc/bind/zones/db.ns1.example.com
$TTL 604800
@ IN SOA ns1.example.com. admin.ns1.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
; name servers – NS records
IN NS ns1.example.com.
IN NS ns2.example.com.
; name servers – A records
ns1.example.com. IN A 192.168.5.100
ns2.example.com. IN A 192.168.5.101
sudo vi /etc/bind/zones/db.5.100
$TTL 604800
@ IN SOA ns1.example.com. admin.ns1.example.com. (
3 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
; name servers
IN NS ns1.example.com.
IN NS ns2.example.com.
; PTR Records
5.100 IN PTR ns1.example.com. ; 192.168.5.100
5.101 IN PTR ns2.example.com. ; 192.168.5.101
$ sudo named-checkconf

.OK

$ sudo service bind9 restart

Restart the bind – service

In (Ubuntu) client systems

$ sudo vi /etc/resolvconf/resolv.conf.d/head

search ns1.example.com
nameserver 192.168.5.100
nameserver 192.168.5.101

$ nslookup ns1

Server: 192.168.5.100
Address: 192.168.5.100#53

Name: ns1.example.com
Address: 192.168.5.100

Advertisements