Sharing Ilmu

Sharing for useful things

How To Configure DNS Server ubuntu server 20.04 LTS

In this tutorial I’ll discuss about how to configuration dns server on ubuntu server 20.04 LTS. DNS are used for translate ip address to domain and vice versa.

Fist For configuration dns server change ip address configuration. Open netplan configuration.

root@Taufik:~# nano /etc/netplan/00-installer-config.yaml

Configure dns on nameservers. Set ip dns is address of those server at first so that dns reading will be request to local dns server first.

# This is the network config written by 'subiquity'
network:
ethernets:
      enp0s3:
           addresses: [10.202.0.30/27]
           gateway4: 10.202.0.1
           nameservers:
                addresses: [10.202.0.30, 10.202.0.1]
version: 2

 

Change ip address configuration :

root@Taufik:~# netplan apply

 

Configure resolv.conf

root@Taufik:~# nano /etc/resolv.conf

Add configuration as the following :

GNU nano 4.8                    /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 10.202.0.30

 

Configure Host :

root@Taufik:~# nano /etc/hosts

Change host configuration as the following :

127.0.0.1 localhost
127.0.1.1 taufiknurhuda.com
10.202.0.30 taufiknurhuda.com

# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

 

Update system :

root@Taufik:~# apt-get update

 

Install dependency packages :

root@Taufik:~# apt-get install libxml2 libicu66 -y

 

Install BIND9 packages for dns server service :

root@Taufik:~# apt-get install bind9 -y

 

Configure dns zone :

root@Taufik:~# nano /etc/bind/named.conf.local

Add the configuration as the following.  see at zone 0.202.10, it’s the network for server ip 10.202.0.30 written in reverse.

//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";

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

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

 

Change directory to /etc/bind :

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

 

Copy  default db file configuration to new db file. db.local to db.domain and db.127 to db.ip.

root@Taufik:/etc/bind# cp db.local db.domain
root@Taufik:/etc/bind# cp db.127 db.ip
root@Taufik:/etc/bind#

 

Configure db.domain :

root@Taufik:/etc/bind# nano db.domain

Do configuration as the following :

;
; BIND data file for local loopback interface
;
$TTL     604800
@          IN           SOA          taufiknurhuda.com. root.taufiknurhuda.com. (
                                                2             ;  Serial
                                           604800             ; Refresh
                                            86400             ; Retry
                                          2419200             ; Expire
                                           604800 )           ; Negative Cache TTL
;
@          IN           NS            ns.taufiknurhuda.com.
ns         IN            A                10.202.0.30
@          IN            A                10.202.0.30
www        IN            A                10.202.0.30

 

save and exit.

 

Configure db.ip :

root@Taufik:/etc/bind# nano db.ip

Do configuration as the following. 30 is the host id that used on server ip 10.202.0.30 :

;
; BIND data file for local loopback interface
;
$TTL     604800
@          IN           SOA          taufiknurhuda.com. root.taufiknurhuda.com. (
                                                1             ;  Serial
                                           604800             ; Refresh
                                            86400             ; Retry
                                          2419200             ; Expire
                                           604800 )           ; Negative Cache TTL
;
@          IN           NS            ns.taufiknurhuda.com.
30         IN           PTR           taufiknurhuda.com.
30         IN           PTR           www.taufiknurhuda.com.

save and exit.

 

Restart bind9 service :

root@Taufik:~# systemctl restart bind9.service

 

Test the configuration using nslookup :

root@Taufik:~# nslookup taufiknurhuda.com
Server:         10.202.0.30
Address:      10.202.0.30#53

Name: taufiknurhuda.com
Address: 10.202.0.30
root@Taufik:~#

 

root@Taufik:~# nslookup www.taufiknurhuda.com
Server:    10.202.0.30
Address:   10.202.0.30#53

Name: www.taufiknurhuda.com
Address: 10.202.0.30

 

root@Taufik:~# nslookup 10.202.0.30
30.0.202.10.in-addr.arpa name = www.taufiknurhuda.com.
30.0.202.10.in-addr.arpa name = taufiknurhuda.com.
30.0.202.10.in-addr.arpa name = ns.taufiknurhuda.com.
root@Taufik:~#

As the shown above, if nslookup test is pointed to local ip server. Dns configuration is successfull.

 

z

Leave a Reply

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

*
*
You may use these <abbr title="HyperText Markup Language">HTML</abbr> tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>