DNS Configuration on CentOS 7 Without cPanel Panel

DNS or Domain Name System can be defined as: translating a host name or URL to an IP address. For example, if we type domainanda.com in a browser, the DNS server translates the domain name to the corresponding IP address. Since IP addresses are hard to remember all the time, DNS servers are used to translate hostnames like domainanda.com to 121.xxx.xx.xxx (the IP the server has). Remembering the domain name is easier than having to remember the IP address.


Here are the steps you can follow to configure DNS on CentOS 7:


1. Please login to the SSH server that you have, you can use the putty application or the SSH remote application that you usually use.

2. Install bind9 on your server with the following command:

yum install bind-utils -y

3. After installing bind9, please edit the /etc/named.conf file.

Warning: before editing the /etc/named.conf file, you should backup the original /etc/named.conf file by running the :

cp /etc/named.conf /etc/named.conf-backup

Next, after backing up, please edit the /etc/named.conf file by running the command:

vi /etc/named.conf 

Add the script as shown in the red config:

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

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

/*
– If you are building an AUTHORITATIVE DNS server, do NOT enable recursion.
– If you are building a RECURSIVE (caching) DNS server, you need to enable
recursion.
– If your recursive DNS server has a public IP address, you MUST enable access
control to limit queries to your legitimate users. Failing to do so will
cause your server to become part of large scale DNS amplification
attacks. Implementing BCP38 within your network would greatly
reduce such attack surface
*/
recursion yes;

dnssec-enable yes;
dnssec-validation yes;

/* Path to ISC DLV key */
bindkeys-file “/etc/named.iscdlv.key”;

managed-keys-directory “/var/named/dynamic”;

pid-file “/run/named/named.pid”;
session-keyfile “/run/named/session.key”;
};

logging {
channel default_debug {
file “data/named.run”;
severity dynamic;
};
};

zone “.” IN {
type hint;
file “named.ca”;
};

zone “domainanda.com” IN {
type master;
file “domainanda.ca”;
allow-update { none;};
};

include “/etc/named.rfc1912.zones”;
include “/etc/named.root.key”;



4. Create a DNS ZONE file

Adding DNS ZONE files please do so in the /var/named/ directory, the step to do the addition please run the :

vi /var/named/domainanda.ca

then add the script:

$ORIGIN domainanda.com.
$TTL 86400
@ IN SOA ns1.domainanda.com. root.domainanda.com. (
2001062501 ; serial
21600 ; refres
3600 ; retry
604800 ; expire
86400) ; minimum TTL

IN NS ns1.domainanda.com.
IN NS ns2.domainanda.com.
ns1 IN A 102.138.1.202
ns2 IN A 102.138.1.202
IN A 102.138.1.202
www IN A 102.138.1.202
mail IN A 102.138.1.202


Note: This step is an example with the domainanda.ca file name according to the addition of the script in step 2 and for the IP, please change it according to the server IP you have.

4. If you have finished creating DNS ZONE please do the command:

systemctl enable named
systemctl start named


5. If the stages of points 1-4 have been done, just set the domain pointing to the server ip and please wait for it to be resolved between 1x24 hours.


Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.