Need help?

Our experts have had an average response time of 13.14 minutes in February 2024 to fix urgent issues.

We will keep your servers stable, secure, and fast at all times for one fixed price.

Configure BIND master DNS Server on CentOS 7

by | Sep 18, 2021

Wondering how to configure BIND master DNS Server on CentOS 7? We can help you.

As part of our Server Management Services, we assist our customers with several queries.

Today, let us see steps performed by our Support Techs in order to configure BIND.

How to configure BIND master DNS Server on CentOS 7?

The Domain Name System (DNS) is a hierarchical distribute 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.

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.

Today, let us see the steps followed by our Support techs to perform this task.

Environment

Server Name: ns1example.com

IP Address: x.x.x.x

Install DNS (BIND)

BIND stands for Berkeley Internet Name Domain, a software that provides an ability to perform name to IP conversion.

yum -y install bind bind-utils

Configure DNS (BIND)

Configure it as given below:

include "/etc/rndc.key";
controls {
inet 127.0.0.1 allow { localhost; } keys { "rndc-key"; };
};
options {
recursion no;
directory "/var/named"; // the default
pid-file "/var/run/named/named.pid";
dump-file "data/cache_dump.db";
statistics-file "data/named_stats.txt";
allow-transfer { "none"; };
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view "localhost_resolver" {
match-clients { 127.0.0.0/24; };
match-destinations { localhost; };
recursion yes;
zone "." IN {
type hint;
file "/var/named/named.ca";
};
include "/var/named/named.rfc1912.zones";
};
view "internal" {
match-clients { localnets; };
match-destinations { localnets; };
recursion yes;
zone "." IN {
type hint;
file "/var/named/named.ca";
};
zone "example.com" IN {
type master;
file "/var/named/example.com.db";
};
};
view "external" {
recursion no;
additional-from-cache no;
zone "." IN {
type hint;
file "/var/named/named.ca";
};
zone "example.com" IN {
type master;
file "/var/named/example.com.db";
};
};

Then, configure rfc1912.zones

cp -pv /etc/named.rfc1912.zones /var/named/named.rfc1912.zones

Create Zones

Edit /etc/named.conf.
vi /etc/named.conf

Create Zone Files

By default, zone lookup files are placed under /var/named directory.

Create a zone file called fwd.example.com.db for forward lookup under /var/named directory.

All domain names should end with a dot (.).

vi /var/named/example.com.db

There are some special keywords for Zone Files

A – A record
NS – Name Server
MX – Mail for Exchange
CNAME – Canonical Name

@ IN SOA ns1.example.com. root.example.com.
(
1001 ;Serial
3H ;Refresh
15M ;Retry
1W ;Expire
1D ;Minimum TTL
)

;Name Server Information

@ IN NS ns1.example.com.

;IP address of Name Server

ns1 IN A x.x.x.x

;Mail exchanger

example.com. IN MX 10 mail.example.com.

;A – Record HostName To IP Address

www IN A y.y.y.y
mail IN A z.z.z.z ;

CNAME record ftp IN CNAME www.example.com.

Whenever you update the zone lookup file, you need to change/increment the serial like 1002 ;Serial.

Once zone files are created, restart bind service.

systemctl restart named

Enable it on system startup.

systemctl enable named

Use the following command to verify the forward lookup.

dig www.example.com

Output: The DNS server should give 192.168.0.100 as ip for www.example.com.

; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.1 <<>> www.example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35563
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.example.com. IN A
;; ANSWER SECTION:
www.example.com. 86400 IN A y.y.y.y
;; AUTHORITY SECTION:
example.com. 86400 IN NS primary.example.com.
;; ADDITIONAL SECTION:
ns1.example.com. 86400 IN A x.x.x.x
;; Query time: 0 msec
;; SERVER: 192.168.0.10#53(192.168.0.10)
;; WHEN: Wed Jul 03 02:00:40 EDT 2019
;; MSG SIZE rcvd: 100

Install BIND utilities yum install -y bind-utils package to get nslookup or dig command.

Confirm the reverse lookup.

dig -x y.y.y.y

Output: The DNS server gives www.example.com as a name for y.y.y.y.

; <<>> DiG 9.9.4-RedHat-9.9.4-74.el7_6.1 <<>> -x y.y.y.y
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4807
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 2
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;100.0.168.192.in-addr.arpa. IN PTR
;; ANSWER SECTION:
100.0.168.192.in-addr.arpa. 86400 IN PTR www.example.com.
;; AUTHORITY SECTION:
0.168.192.in-addr.arpa. 86400 IN NS ns1.example.com.
;; ADDITIONAL SECTION:
ns1.example.com. 86400 IN A x.x.x.x
;; Query time: 0 msec
;; SERVER: x.x.x.x#53(x.x.x.x)
;; WHEN: Wed Jul 03 02:02:47 EDT 2019
;; MSG SIZE rcvd: 124

It is now confirmed that both forward and reverse lookups are working fine.

[Need help with similar issue? We are available 24*7]

Conclusion

In short, we saw steps followed by our Support Techs to Configure BIND master DNS Server on CentOS 7.

PREVENT YOUR SERVER FROM CRASHING!

Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.

GET STARTED

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Categories

Tags

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF