Easy Ways to Configure DNS on Cent OS 7
What is DNS ?
The Domain Name System (DNS) is a hierarchical distributed naming system for computers, services, or any resource connected to the Internet or a private network. It associates various information with domain names assigned to each of the participating entities.
Most importantly, it translates domain names meaningful to humans into the numerical identifiers associated with networking equipment for the purpose of locating and addressing these devices worldwide.
Install BIND package :
BIND stands for Berkeley Internet Name Domain, a software which provides an ability to perform name to ip conversion.
# yum -y install bind bind-utils
Configure BIND :
Configuration file of bind is /etc/named.conf, open up /etc/named.conf file. Comment out the following line, and this will enable BIND to listen on all ip addresses.
#listen-on port 53 { 127.0.0.1; };
#listen-on-v6 port 53 { ::1; };
If you want to build public DNS server, then change the line like below
allow-query { any; };
Create Zones :
The following is the forward zone entry in named.conf file, written for the darzilla.com domain. Edit /etc/named.conf.
# vi /etc/named.conf
zone “darzilla.com” IN {
type master;
file “fwd.darzilla.db”;
allow-update { none; };
};
Here
darzilla.com– Domain name
master – Primary DNS
fwd.darzilla.db – Forward lookup file
allow-update – Since this is the primary DNS, it should be none
Create Zone Files :
Now, it’s the time to create a lookup file for a created zone. By default, zone lookup files are placed under /var/named directory. Create a zone file called fwd.itzgeek.local.db for forward lookup under /var/named directory. All domain names should end with a dot (.).
There are some special keywords for Zone Files
A – A record
NS – Name Server
MX – Mail for Exchange
CNAME – Canonical Name
E – Canonical Name
$TTL 14400
darzilla.com. 86400 IN SOA ns1.darzilla.com. admin.darzilla.com. (
2018052401 ;Serial Number
3600 ;refresh
7200 ;retry
1209600 ;expire
86400 )
darzilla.com. 86400 IN NS ns1.darzilla.com.
darzilla.com. 86400 IN NS ns2.darzilla.com.
darzilla.com. 14400 IN A 103.14.121.87
ns1.darzilla.com. 14400 IN A 103.14.121.87
ns2.darzilla.com. 14400 IN A 103.14.121.87
darzilla.com. 14400 IN MX 0 darzilla.com.
mail 14400 IN CNAME darzilla.com.
www 14400 IN CNAME darzilla.com.
ftp 14400 IN A 103.14.121.87
Once zone files are created, restart bind service.
# systemctl restart named.service
Enable it on system startup.
# systemctl enable named.service
Verify zones
Visit any client machine and add a DNS server ip address in /etc/resolv.conf if Network Manager does not manage the network.
# vi /etc/resolv.conf nameserver YourserverIP
If Network Manager manages the networking then place the following entry in /etc/sysconfig/network-scripts/ifcfg-eXX file.
DNS1=YourserverIP
Restart network service.
# systemctl restart NetworkManager.service
Restart network service.
Thanks for reading this blog, hope It will be helpful for you 🙂