How to Install and Configure DNS on RHEL7

0
2098
How to Install and Configure DNS on RHEL7

Domain name servers DNS or Nameserver, maps devices hostnames with their respective IP addresses, DNS is normally implemented using a central servers that is authoritative for a domain and refer to other DNS servers for other domains. There are four DNS server configuration types:

Master:

It has the authoritative zone records for the domain that act as DNS Server. Answers directly queries about the authoritative domain and forwards other domain queries to other DNS Servers.

Slave:

Slave DNS server acts as an authoritative DNS server getting the zone records form the DNS master Server.

Catching-Only:

Caching-Only DNS Server is not authoritative for any zone, all queries are forwarded to other DNS Servers. If they are not stored in the DNS cache zone. Answers for all queries are cached in DNS cache zone for a time.

Forwarding:

As caching-only DNS server, forwarding DNS is not authoritative for any zone, all queries are forwarded to a specific list of nameservers.

A nameserver can be master for some zones, slave for other and offer forwarding to others

Few Important DNS Records

A = IPv4 Address record

AAAA = IPv6 Address record
PTR = Pointer record
NS = Name service / server
MX = Mail Exchanger
SOA = State of Authority
CNAME =    Canonical name / Alias Name

Important Files and required package details

Packages Required   :  bind

Version    :  9

Daemon: named

Config Files:

/var/named/chroot/etc/named.conf

/var/named/chroot/etc/named.rfc1912.zone

 Default zone files location:

/var/named/chroot/var/named/

Port Number: 53

Step 1 : Installing

Let we install bind in the server, using yum

[root@Foxutech ~]# yum install bind* -y

Once packages successfully install, now let we start and enable the services, to start a service first we need start named-chroot before named.service because it will generate config files

[root@Foxutech ~]# systemctl enable named-chroot.service

[root@Foxutech ~]# systemctl start named-chroot.service

[root@Foxutech ~]# systemctl enable named.service

[root@Foxutech ~]# systemctl start named.service

Step 2: Configuration

Once package install and started successfully, now we need to change some fields in our configuration file,

[root@Foxutech ~]# vim /var/named/chroot/etc/named.conf

options {

listen-on port 53 { 127.0.0.1; 192.168.0.3; };

listen-on-v6 port 53 { ::1; };

directory       “/var/named”;

dump-file       “/var/named/data/cache_dump.db”;

statistics-file “/var/named/data/named_stats.txt”;

memstatistics-file “/var/named/data/named_mem_stats.txt”;

allow-query     { localhost; 192.168.0.0/24; };

Here just we need to add your server IP and networks details. Here we are installing and configuring Caching-only DNS Server, Allow query using for enable caching only.

Now edit zones configuration file, here we add domain details and our ip details

[root@Foxutech ~]# vim /var/named/chroot/etc/named.rfc1912.zones

zone “mytest.com” IN {

        type master;

        file “mytest.for.zone”;

        allow-update { none; };

};

zone “0.168.192.in-addr.arpa” IN {

        type master;

        file “mytest.rev.zone”;

        allow-update { none; };

};

#### Zoned Ended Here ####

zone “mytest.com” IN {  here mention your domain name.

file “mytest.for.zone”;  mention forward zone filename(you can give any name)

zone “0.168.192.in-addr.arpa” IN { in this line write your IP address in reverse way

file “mytest.rev.zone”; mention reverse zone filename(you can give any name)

Save configuration file and Exit

 Creating Zone files

Forward lookup zone – forward lookup zone will convert host name to IP address

Reverse lookup zone – reverse lookup zone will convert IP address to host name

Go to /var/named/chroot/var/named/

copy the files as per the file names which we have mentioned in above zones configuration file

in this example

named.local –> mytest.for.zone

named.loopback –> mytest.rev.zone

[root@Foxutech named]# cd /var/named/chroot/var/named

[root@Foxutech named]# cp named.localhost mytest.for.zone

[root@Foxutech named]# cp named.loopback mytest.rev.zone

[root@Foxutech named]# vim mytest.for.zone

$TTL   300

@               IN SOA mytest.com.     root.mytest.com. (

43             ; serial (d. adams)

3H             ; refresh

15M             ; retry

1W             ; expiry

1D )           ; minimum

@       IN     NS     mytest.com.

@               IN A           192.168.0.3

mail           IN A           192.168.0.3

ns1             IN A           192.168.0.3

ns2             IN A           192.168.0.3

Add NS record as DNS Server name and domain name (do not forgot to add (dot) yet end)

First A record will be your domain name and DNS server IP address

[root@Foxutech named]# vim mytest.rev.zone

$TTL   86400

@       IN     SOA     mytest.com. root.mytest.com. (

1997022700 ; Serial

28800     ; Refresh

14400     ; Retry

3600000   ; Expire

86400 )   ; Minimum

IN     NS     ns1.mytest.com.

IN     NS     ns2.mytest.com.

25     IN     PTR     mail.mytest.com.

Note: don’t miss any single (dot) which makes problem while start named service

Step 3: Permission and Restart the Service

Once changes has been done, make sure configuration file contains necessary permission

[root@Foxutech named]# chown root:named mytest.for.zone

[root@Foxutech named]# chown root:named mytest.rev.zone

Add firewall rule to communicate DNS port out

[root@Foxutech ~]# firewall-cmd –permanent –add-service=dns

success

[root@Foxutech ~]# firewall-cmd –reload

success

Now restart your named service.

[root@Foxutech named]# systemctl restart named.service

[root@Foxutech named]# systemctl status named.service

Step 4: Configure DNS in Client

In Client machine, add master DNS details in /ets/resolv.conf

[root@Foxutech named]# vim /etc/resolve.conf

search mytest.com

domain mytest.com

nameserver 192.168.0.3

Step 5; Verify DNS

To Verify DNS, we can use nslookup and dig. Make sure its resolving.

# nslookup mytest.com

#dig mytest.com

#host 192.168.0.3

#dig -x 192.168.0.3

NO COMMENTS

LEAVE A REPLY