Redhat / DNS Server Installation and Configuration on Centos 7 – Bind (Named), NS (Nameserver) – Public DNS Or Private DNS
What is DNS? What is NS?
I would like to refer many questions like this to related articles and make a direct transition to this topic.
Note: The domain to be used in the article is fatlan.com, ips are not real.
In Linux systems, you need to install the DNS system and install the Bind package to activate it. The name of the service is known as Named. With Named you can provide service management.
In the first place, I install a Centos 7 server and then use a fixed IP to lift up the network. Then run yum update command to stabilize the server. Then, I change the hostname of the server to ns1.fatlan.com
from the file “/etc/hostname” . I also make this change in the file “/etc/hosts” . In the meantime, after updating and installing the packages, make sure to show yourself as a DNS server from the files “/etc/resolv.conf” and “/etc/sysconfig/network-scripts/ifcfg-ens0”.
Then let’s install the necessary packages for DNS with the following command.
1 | > yum install bind bind-utils |
Now the important part is the configuration and we will configure the file et “/etc/named.conf” first, but make a backup of the “named.conf” file first.
By default, the content of “named.conf” is like ss below.
Let’s talk about what will be changed or added before editing the file with the help of an editor.
The default lines are;
1 2 3 4 5 | –listen-on port 53 { 127.0.0.1; }; –listen-on-v6 port 53 { ::1; }; –allow-query { localhost; }; |
The shape will change;
1 2 3 4 5 | –listen-on port 53 { any; }; –listen-on-v6 port 53 { none; }; –allow-query { any; }; |
Rows to be added;
–forward only; //optional
–forwarders { 8.8.8.8; }; //optional
Zone and reverse zone information of –fatlan.com
is specified in this file.
The final screenshot is as follows.
Now it’s time to create zone files, that is, DNS records. We need to create these zone and revzone files in the directory “/ var / named /” and in the “/etc/named.conf” directory names.
Let’s go to the directory first.
1 2 3 | > touch fatlan.com.zone > touch 100.34.203.revzone |
Finally, I enter the contents of the “fatlan.com.zone” and “100.34.203.revzone” zone files through any editor as shown in the ss below.
Note: I added A, CNAME and PTR records as an example. The other configuration types are important because the zone and revzone are different because I have added both types to be an example.
fatlan.com.zone;
100.34.203.revzone;
Now that’s all right up to, but all we have to do is test the accuracy of all these adjustments.
First, check if we have correctly configured “/etc/named.conf”. If something doesn’t turn, it’s true.
1 | > named-checkconf |
Now let’s check the fatlan.com.zone file.
1 | > named-checkzone fatlan.com /var/named/fatlan.com.zone |
Finally, check the file 100.34.203.revzone.
1 | > named-checkzone 100.34.203.in-addr.arpa /var/named/100.34.203.revzone |
Now that everything’s fine, let’s start the named service.
1 | > systemctl start named.service |
Finally, let’s make sure he listens to port 53. Remember to allow access to port 53 from the firewall.
1 | > netstat -plntua | egrep -i named |
Everything on the server-side is over, let’s redirect a user machine’s DNS to our new server and check the status of decoding records.
I hope it has been a useful article.