How to configure BIND for DNS server in RHEL/CentOS 7

Computers Development

DNS(Domain Name System) is very important when you use internet to access any website. With the help of DNS you are able to redirect to domain names to IP. To explain further I would say all the servers are configured with an IP and it is very difficult to remember the IP address of particular web server to open a link, this is why a unique domain name is given to the website. When you open a domain name it is binded with the server IP and redirects to the particular web server where the files are hosted. For example if you want to open Facebook.com(Domain name) it is redirected to the IP of the server where the files are hosted and it responses with your request from IP to Facebook.com. DNS is used to redirect from IP to Domain name and later on from Domain name to IP.

Things to do.

  • Need to install BIND
  • Configure named service
  • Configure forward and reverse zone.
  • Give permissions to the files.
  • Check if DNS is working

 

Install BIND

To start with installation you need to know, we have to install BIND(which stands for Berkeley Internet Name Domain). BIND is the package which is installed to run DNS services.

[root@localhost ~]#yum install bind*

Configure BIND.

To configure BIND, you need to make changes to few files.

[root@localhost ~]# vi /etc/named.conf

options {

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

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; any; };


[root@localhost ~]# vi /etc/named.rfc1912.zones

zone "bash.codes" IN {

type master;

file "f.zone";

allow-update { none; };

};

zone "1.168.192.in-addr.arpa" IN {

type master;

file "r.zone";

allow-update { none; };

};


 

 

Now you need to do an entry in Forward and Reverse zone. You need to make a copy of localhost and loopback to configure forward and reverse DNS with permissions.

[root@localhost ~]# cd /var/named/

[root@@localhost named]# ls

[root@localhost named]# cp named.localhost f.zone

[root@localhost named]# cp named.loopback r.zone

[root@localhost named]# vim f.zone

$TTL 1D

@       IN SOA bash.codes. root.bash.codes. (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H )    ; minimum

                NS      bash.codes.

bash.codes.      A       192.168.1.29

[root@localhost named]# vim r.zone

$TTL 1D

@       IN SOA  bash.codes. root.bash.codes. (

0       ; serial

1D      ; refresh

1H      ; retry

1W      ; expire

3H )    ; minimum

NS      bash.codes.

29      PTR     bash.codes.

[root@localhost named] chmod 644 f.zone r.zone

 

Now you need to access resolv.conf file and add the IP address of the DNS server also add the same DNS

[root@localhost named]# vim /etc/resolv.conf

# Generated by NetworkManager

nameserver 192.168.1.29

 

After this you also need to add the DNS address of the server in network settings.

[root@localhost named]# nmtui

Need to enable DNS service and the service name is named.

[root@localhost named]# systemctl enable named

[root@localhost named]# systemctl restart named

Now you need to check if the DNS is working well or not, if error comes you need to check the configuration again.

[root@localhost named]# nslookup bash.codes

[root@localhost named]# dig bash.codes

[root@localhost named]# dig -x 192.168.1.55

 

Note: If you have enabled the firewall, then you need to add DNS Port 53 to allow through firewall.

[root@localhost named]# firewall-cmd --permanent --add-port=53/tcp

[symple_divider style=”solid” margin_top=”20px” margin_bottom=”20px”]

[symple_box color=”gray” text_align=”left” width=”100%” float=”none”]

If you like the blog please follow us [icon name=”icon-facebook”] [icon name=”icon-twitter”] [icon name=”icon-google-plus-sign”]

[/symple_box]