Wednesday, 18 July 2018

Setup DNS server on OEL/Linux

In this post, I am going to share the steps for setup of DNS server. It will be used in my for RAC 12c setup.

Pre-req:

Virtual Box is installed and a Machine is prepared. Below is the configuration of the machine.

Virtual DNS OS Configuration:
RAM: 1GB
HardDisk Size : 12 GB

Operating System: Oracle Enterprise Linux

The installation of the Server would be a basic installation with Option selected as Software Development Workstation to get a GUI. Once the OS installation is done you can optionally install Guest Addition as it helps for easy mouse movements and sharing a file from host system to this guest virtual system.

IPADDR=192.168.56.101
GATEWAY=255.255.255.0
NETMASK=255.255.255.0




High level Steps to configure DNS Server.

  • ·         Install DNS Package
  • ·         Assign static IP to the server
  • ·         Assign FQDN(Fully Qualified Domain Name) for server
  • ·         Configure /etc/hosts
  • ·         Configure /etc/resolv.conf        
  • ·         Configure /etc/named.conf
  • ·         Configure Forward and reverse zone
  • ·         Change the group ownership  of Forward and reverse zone file
  • ·         Restart DNS Server.
  • ·         Change permission of the resolv.conf

1- Installation of the DNS server (BIND)

 From the command line issue the following command.
         # yum install bind-libs bind bind-utils


   2-Assign static IP

     
cd /etc/sysconfig/network-scripts
I am using my adapter 2 so I have changed the entry in eth1.
Change ifcfg-eth1 file and add below entry
  
cd /etc/sysconfig/network-scripts
vi ifcfg-eth1

BOOTPROTO=static
IPADDR=192.168.56.101
GATEWAY=255.255.255.0
NETMASK=255.255.255.0

 3-Assign FQDN for server

  Add any fully qualified name which you want to give.  

 vi /etc/sysconfig/network
 NETWORKING=yes
 HOSTNAME=path.labs

4-Change /etc/resolv.conf


Change /etc/resolv.conf and also change it permission so that it will be not overwritten once server is restarted.
This resolv.conf entry has to be made on all the client systems as well.

[root@path network-scripts]# cat /etc/resolv.conf
# Generated by NetworkManager
search path.labs
nameserver 192.168.56.101

Permission change
chattr +i resolv.conf

5-Change /etc/named.conf  File
    
Edit the contents of the "/etc/named.conf" file. Depending on the setup you require, you may need to make lots of changes, or none at all. For my home network I use "path.lab" as my domain and the IP range "192.168.56.*", so this is what I will show here.
We are adding both forward and reserve lookup

I will show lines which needs to be updated 

listen-on port 53 { 127.0.0.1;192.168.56.101; };
allow-query     { any; };

and I will show lines which needs to be add

zone "path.labs" IN {
        type master;
        file "path.labs.zone";
        allow-update { none; };
};

zone "56.168.192.in-addr.arpa." IN {
        type master;
        file "56.168.192.in-addr.arpa";
        allow-update { none; };
};


    6-Create Forward and Reverse zone files

     Create forward and reverse lookup file

cd  /var/named  touch      56.168.192.in-addr.arpa       path.labs.zone

Add below entry in respective files.

[root@path named]# cat path.labs.zone

$TTL    86400
@               IN SOA  localhost root.localhost (
                                        42              ; serial (d. adams)
                                        3H              ; refresh
                                        15M             ; retry
                                        1W              ; expiry
                                        1D )            ; minimum
                IN NS           localhost
localhost       IN A            127.0.0.1
path   IN A    192.168.56.101


root@path named]# cat 56.168.192.in-addr.arpa


$ORIGIN 56.168.192.in-addr.arpa.
$TTL 1H
@       IN      SOA     path.labs.     root.path.labs. (      2
                                                3H
                                                1H
                                                1W
                                                1H )
56.168.192.in-addr.arpa.         IN NS      path.labs.
101     IN PTR  path.labs.

 7-Change Ownership of the forward and reverse file.

cd /var/named
chown named:named 56.168.192.in-addr.arpa path.labs.zone

    8-To Make sure Bind is started every time server is   restarted.

chkconfig named on
Restart named
service named restart

9-Check if DNS is working fine

[root@path named]# nslookup path
Server:             192.168.56.101
Address:          192.168.56.101#53

Name:  path.path.labs
Address: 192.168.56.101

[root@path named]# nslookup 192.168.56.101
Server:             192.168.56.101
Address:          192.168.56.101#53

101.56.168.192.in-addr.arpa      name = path.labs.