Bind is a DNS service that can be installed on most Linux distributions, and its high popularity is for its high and free performance. Like other DNS servers, BIND has a standardized and integrated architecture and the ability to add multiple domains. This tutorial will go through the steps to Install Bind on CentOS 7.

Install Bind on CentOS 7

Update your CentOS using the below command:

yum update –y

Reboot your server after updating CentOS:

reboot

Now, Install bind and its tools using below command:

yum install bind bind-utils –y 

We must configure our DNS server after it is installed. Open named.conf file using a text editor like nano or Vi. The main config file for BIND is called named.conf:

nano /etc/named.conf

Remove all its lines and replace the following lines inside it:

options {
                   #listen-on port 53 { 127.0.0.1; 192.168.10.100 };
        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 { any; };
        allow-transfer     { localhost;  };
        recursion no;

        dnssec-enable yes;
        dnssec-validation yes;
        dnssec-lookaside auto;

        /* Path to ISC DLV key */
        bindkeys-file "/etc/named.iscdlv.key";
        managed-keys-directory "/var/named/dynamic";
};

Save and exit the text editor.

Now, we have configured the main options in this file. If it looks complicated, don't worry, we will explain what we added to the file. 

Listen on: listen-on defines the port and IP address(es) on which BIND will listen for incoming queries. The default is port 53 on all server interfaces. Enter Multiple listen-on statements are allowed. This statement may only be used in a global options clause. Enter your server's local IP address for this option.

Allow transfer: defines a match list, e.g. IP address(es) that are allowed to transfer (copy) the zone information from the server (master or slave for the zone). If you decide to configure a secondary DNS server, you must mention its IP here. 

Recursion: This option protects you from DDOS attacks on the DNS server, and you must set it as NO.

After configuring BIND basic options, we will continue the tutorial with Zone configuration. 

Zone configuration in BIND

To create a Zone, append these lines to the end of named.conf file:

nano named.conf

 zone "1gbits.com" IN {
                type master;
                file "azarlearn.com.zone";
                allow-update { none; };
        };  

Note: Enter your domain name instead of 1gbits.com.

Note: We have created a file with a .zone extension you must edit it to configure records, etc. After adding a zone to named.conf file, you do not need to work with this file again. Save and exit it.

Now to configure zones and its records, open the file that you have defined it in previous step:

nano –w /car/named/azarlearn.com.zone 

Then copy these lines to it:

$TTL 86400
@   IN  SOA     ns1.azarlearn.com. root.azarlearn.com. (
        2013042201  ;Serial
        3600        ;Refresh
        1800        ;Retry
        604800      ;Expire
        86400       ;Minimum TTL
)
; add nameservers
IN           NS     ns1.azarlearn.com.
; Resolve nameserver hostnames to IP
ns1         IN         A      192.168.10.100  

In the first seven lines of the above file, we have configured Refresh Time, TTL, etc.

We have defined a NS record too.To define other records in BIND, you must enter the record name and address like our final line. For example, we created an A record and point it to client using the following line:

Client1       IN         A     192.168.10.101

 This A record point to client1 with 192.168.10.101 IP address. To apply configurations, restart the BIND service using the below command:

systemctl restart named 

To add BIND to startup services, use the below command:

systemctl enable named

Congratulations! You have installed BIND on CentOS 7 and configured Zone. You can use the Webmin control panel if you need a web-based environment to control BIND. 

Conclusion

We hope this tutorial helped you install Bind on CentOS 7 hassle-free. If you are facing any problems with the installation, feel free to comment here. We will help you to solve the issue in no time. 

People also read: