X

How To Install DNS Server (Bind9) On Ubuntu 18.04

Sharing is caring!

DNS refers to Domain Name System. It is very import for your local network and public network. So I want to show step by step guide for DNS server how to install and configure DNS (Bind9) on local network.

How To Install DNS (Bind9) On Ubuntu 16.04
How To Install DNS (Bind9) On Ubuntu 14.04

System requirements :

  • Ubuntu 18.04 VPS or local machine
  • RAM 1 GB (More best performance)
  • LAN interface
  • SSH enable

My Server IP Address : 10.66.40.50

Name server : ns1.technologyrss.local

Step #01: Must be server update complete using below command.

root@ns1:~# apt update && apt upgrade -y

Change server host name like as below. Open hosts file via any editor.

root@ns1:~# vi /etc/hosts
127.0.0.1 localhost
10.66.40.50 ns1.technologyrss.local ns1

then save it Esc :wq press Enter.

And then change another file open using below command

root@ns1:~# vi /etc/hostname
ns1

then save it Esc :wq press Enter.

Now reboot your server using command

root@ns1:~# reboot

Step #02: Edit resolv.conf file and add google dns and my ip address as name server.

root@ns1:~# vi /etc/resolv.conf
nameserver 10.66.40.50
nameserver 8.8.8.8

then save it Esc :wq press Enter.

Now Install DNS (Bind9) server using command below

root@ns1:~# apt-get install bind9 bind9utils bind9-doc -y

Step #03: Wait up to installation is completed then goto bind folder.

root@ns1:~# cd /etc/bind/

Now backup or copy default named.conf.local file.

root@ns1:/etc/bind# cp named.conf.local named.conf.local.back

db.local file is zone file that means forward and reverse zone. So I copy (db.local) file for two purposes.

This one forward zone file.

root@ns1:/etc/bind# cp db.local db.fwd.technologyrss.local

Another one reverse zone file.

root@ns1:/etc/bind# cp db.local cp db.local db.rev.technologyrss.local

Now create zones folder using command

root@ns1:/etc/bind# mkdir /etc/bind/zones

Move created two file into /etc/bind/zones folder.

root@ns1:/etc/bind# mv db.fwd.technologyrss.local zones
root@ns1:/etc/bind# mv db.rev.technologyrss.local zones

Step #04: Now edit named.conf.local file then insert forward and reverse file location.

root@ns1:/etc/bind# vi named.conf.local

Insert below text after default text then save it.

zone "technologyrss.local" IN {
type master;
file "/etc/bind/zones/db.fwd.technologyrss.local";
allow-update { none; }; // Since this is the primary DNS, it should be none.
};

//Reverse lookup name, should match your network in reverse order

zone "66.10.in-addr.arpa" IN {
type master;
file "/etc/bind/zones/db.rev.technologyrss.local";
allow-update { none; }; //Since this is the primary DNS, it should be none.
};

then save it Esc :wq press Enter.

Note : Server IP 10.66.40.50 so This first two 66.10. 

Step #05: Open named.conf.options file for add acl and listen information.

root@ns1:/etc/bind# vi named.conf.options

Insert all information into named.conf.options file then save it.

acl "Trusted" {
10.66.40.50; # Name Server
};

options {
directory "/var/cache/bind";

recursion yes; # enables resursive queries
allow-recursion { Trusted; }; # allows recursive queries from "trusted" clients
listen-on { 10.66.40.50; }; # 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;
};

dnssec-validation auto;

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

then save it Esc :wq press Enter.

Step #06: And now edit two file forward and reverse zone file.

root@ns1:/etc/bind# cd zones

Now open forward zone file via any editor.

root@ns1:/etc/bind/zones# vi db.fwd.technologyrss.local

Sample below my config you can change it for your domain name.

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns1.technologyrss.local. root.ns1.technologyrss.local. (
                        6
                        604800
                        86400
                        2419200
                        604800 )
;
@       IN      NS      localhost.
@       IN      A       127.0.0.1
@       IN      AAAA    ::1

;Name Server Information
        IN      NS      ns1.technologyrss.local.
;Name Server A records
ns1.technologyrss.local.      IN      A       10.66.40.50

then save it Esc :wq press Enter.

Step #07: Now open reverse zone file via any editor.

root@ns1:/etc/bind/zones# vi db.rev.technologyrss.local

Sample below my config you can change your domain name.

;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     ns1.technologyrss.local. root.ns1.technologyrss.local. (
                        5
                        604800
                        86400
                        2419200
                        604800 )
;
@       IN      NS      localhost.
@       IN      A       127.0.0.1
@       IN      AAAA    ::1

;Name Server Information

        IN      NS     ns1.technologyrss.local.

;PTR records from ip last two part

40.50      IN      PTR    ns1.technologyrss.local.

then save it Esc :wq press Enter.

My server IP address 10.66.40.50 so it last two 40.50 PTR record.

Now bind service restart

service bind9 restart

root@ns1:/etc/bind/zones# service bind9 restart

Step #08: Check zone file working properly.

root@ns1:/etc/bind/zones# named-checkzone 66.10.in-addr.arpa db.fwd.technologyrss.local
db.fwd.technologyrss.local:20: ignoring out-of-zone data (ns1.technologyrss.local)
zone 66.10.in.addr.arpa/IN: loaded serial 2
OK
root@ns1:/etc/bind/zones# named-checkzone 66.10.in-addr.arpa db.rev.technologyrss.local
zone 66.10.in.addr.arpa/IN: loaded serial 2
OK

Step #09: Manage DNS server from web GUI so now I am install webmin into my dns server.

root@ns1:~# apt update

Add webmin repo into sources list file

root@ns1:~# vi /etc/apt/sources.list
deb http://download.webmin.com/download/repository sarge contrib
deb http://webmin.mirror.somersettechsolutions.co.uk/repository sarge contrib

Check public key using below command

root@ns1:~# wget -q http://www.webmin.com/jcameron-key.asc -O- | sudo apt-key add –

Now run update command

root@ns1:~# apt-get update

Then install webmin package using below command.

root@ns1:~# apt-get install webmin

After installation done! Then login using below URL.

https://10.66.40.50:10000

All is done!

Troubleshooting !!!. Must be add name server ip as your dns server ip address. like this.

root@ns1:~# cat /etc/resolv.conf

Output like this

nameserver 10.66.40.50
nameserver 8.8.8.8
search technologyrss.local

If you see can’t save dns first time so you must be add rndc.conf file. see video last step for this config.

For more details see my YouTube video. Don’t forget subscribe my channel. Please subscribe my channel for more update.

 

5 1 vote
Article Rating
Admin: I am system administrator as Windows and Linux platform. I have 4 years skilled from the professional period. I have to configure Linux based system such as an Asterisk VOIP system, Network monitoring tools (ZABBIX), Virtualization (XEN Server), Cloud computing (Apache CloudStack) etc. Now share my professional skill each interested person. Thanks to all.

View Comments (6)

  • IMPORTANT ERROR IN REVERSE RESOLUTION.
    Do you need change the entries for Reverse Zone:
    YOUR IP IS 10.66.40.50 and you create reverse zone like this:

    ;PTR records from ip last two part

    40.50 IN PTR ns1.technologyrss.local.

    but it's necessary than you create entry like this:

    50.40 IN PTR ns1.technologyrss.local

    Do you think than work correctly but only you have dns direct resolution.

    Regards ;-) and enjoy the road sysadm.

    Thanks 4 you great work.

    3K3Y.

    • Thanks. YES. This is last octet in use first.
      Like if your IP address is 192.168.10.50 so PTR is 50.10 IN PTR ns1.yourdomain.local

      • it not work my reverse and i do it exactly like you
        The error is :
        db.rev.abc.local:20:unknow RR type 32.1 where my ip to make the dnd is 192.168.1.32
        can you help me?

        • you enter last two octet in your file like (1.32 IN PTR abc.local.). Please see my video for more. Please subscribe my channel for more update.
          Thanks.

Leave a Comment