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
Copy Code
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";
};
};
Copy Code
Then, configure rfc1912.zones
cp -pv /etc/named.rfc1912.zones /var/named/named.rfc1912.zones
Copy Code
Create Zones
Edit /etc/named.conf.
Copy Code
vi /etc/named.conf
Copy Code
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
Copy Code
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.
Copy Code
(
1001 ;Serial
3H ;Refresh
15M ;Retry
1W ;Expire
1D ;Minimum TTL
)
Copy Code
;Name Server Information
@ IN NS ns1.example.com.
Copy Code
;IP address of Name Server
ns1 IN A x.x.x.x
Copy Code
;Mail exchanger
example.com. IN MX 10 mail.example.com.
Copy Code
;A – Record HostName To IP Address
www IN A y.y.y.y
Copy Code
mail IN A z.z.z.z ;
Copy Code
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
Copy Code
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
Copy Code
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;www.example.com. IN A
Copy Code
;; ANSWER SECTION:
www.example.com. 86400 IN A y.y.y.y
Copy Code
;; AUTHORITY SECTION:
example.com. 86400 IN NS primary.example.com.
Copy Code
;; ADDITIONAL SECTION:
ns1.example.com. 86400 IN A x.x.x.x
Copy Code
;; 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
Copy Code
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
Copy Code
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
Copy Code
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;100.0.168.192.in-addr.arpa. IN PTR
Copy Code
;; ANSWER SECTION:
100.0.168.192.in-addr.arpa. 86400 IN PTR www.example.com.
Copy Code
;; AUTHORITY SECTION:
0.168.192.in-addr.arpa. 86400 IN NS ns1.example.com.
Copy Code
;; ADDITIONAL SECTION:
ns1.example.com. 86400 IN A x.x.x.x
Copy Code
;; 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
Copy Code
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.
0 Comments