• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to install and configure DNS server in CentOS 7

{{postValue.id}}

To install and configure DNS server in CentOS 7

Domain Name System or DNS is a service that will resolve the host name for the particular IP address. When we search for a domain namely www.google.com in browser, the . (dot) seperating the domain name will search for the root server of namespace. Globally there are 13 root servers available to resolve the query. The DNS will lookup to a local resolver that contains an entry about the DNS server information, if there is no such record in local resolver, the search escalates to Top Level Domain (TLD), if there is no such record found, the search will escalate to the authoritative server. The browser will cache the DNS request for future uses. This is the work process of DNS server. This tutorial will explain the installation and configuration procedure of DNS server in CentOS 7.


Installation and Configuration procedure

To proceed with the installation procedure, install the bind package using the following command and press y to continue with the installation process.

[root@linuxhelp11 ~]# yum install bind* -y
BDB2053 Freeing read locks for locker 0x3c91: 2296/139663582197568
BDB2053 Freeing read locks for locker 0x3c93: 2296/139663582197568
Loaded plugins: fastestmirror, langpacks
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
updates                                                  | 3.4 kB     00:00     
extras/7/x86_64/primary_db                                 | 191 kB   00:00     
Determining fastest mirrors
* base: mirrors.nhanhoa.com
.
.
 bind-sdb-chroot.x86_64 32:9.9.4-50.el7_3.1                                    
  bind-utils.x86_64 32:9.9.4-50.el7_3.1                                         

Complete!

Edit the Configuration file of the name server using vim editor. Add primary DNS server IP in listen on port 53 option. Enter IP range of hosts in the allow-query option and define forward and reverse lookup zone for the primary DNS server. Make the following changes and save it.

[root@primarydns ~]# vi /etc/named.conf
zone " linuxhelp11.com"  IN {
type master 
file " fwd.linuxhelp11"  
allow-update { none  } 
} 

zone " 7.168.192.in-addr.arpa"  IN {
type master 
file " rev.linuxhelp11"  
allow-update { none  } 
} 

Enter into named directory by running the cd command as follows.

[root@linuxhelp11 ~]# cd /var/named/

Create forward zone files using vim editor. Add the following lines to the file and save it.

[root@linuxhelp11 named]# vim fwd.linuxhelp11

$TTL 86400
@   IN  SOA     ns1.linuxhelp11.com. root.linuxhelp11.com. (
        2011071001   Serial
        3600         Refresh
        1800         Retry
        604800       Expire
        86400        Minimum TTL
)
@       IN  NS          ns1.linuxhelp11.com.
@       IN  A           192.168.7.236
ns1     IN  A           192.168.7.236

Now create reverse zone files. Add the following lines to the file and save it.

[root@linuxhelp11 named]# vim rev.linuxhelp11
Add the following lines to the file
$TTL 86400
@   IN  SOA     ns1.linuxhelp11.com. root.linuxhelp11.com. (
        2011071001   Serial
        3600         Refresh
        1800         Retry
        604800       Expire
        86400        Minimum TTL
)
@       IN  NS          ns1.linuxhelp11.com.
ns1     IN  A           192.168.7.236
236     IN  PTR         ns1.linuxhelp11.com.

Start the DNS service by executing the following command.

[root@linuxhelp11 named]# systemctl start named.service 

Next add port in the firewall and reload the firewall by running the following commands.

[root@linuxhelp11 named]# firewall-cmd --permanent  --add-port=53/tcp
success

[root@linuxhelp11 named]# firewall-cmd --permanent  --add-port=53/udp
success

[root@linuxhelp11 named]# firewall-cmd --reload
success

To check for errors in the configuration file and zone file execute the set of following commands. The configuration of DNS is now complete.

[root@linuxhelp11 named]# named-checkconf /etc/named.conf 
[root@linuxhelp11 named]# named-checkzone linuxhelp11.com /var/named/fwd.linuxhelp11
zone linuxhelp11.com/IN: loaded serial 2011071001
OK
[root@linuxhelp11 named]# named-checkzone linuxhelp11.com /var/named/rev.linuxhelp11
zone linuxhelp11.com/IN: loaded serial 2011071001
OK

To check the DNS service, give the DNS machine IP to client machine (here we are using windows machine as the client) and check for the IPv4 DNS server in network connection details.
network details
Switch over to the browser and search for any sites like YouTube.
browser
It will lead the browser page to Youtube without any glitches.
youtube

Another method to check the DNS is to open the command prompt in client machine and give the command nslookup google.com. It will show the output that the internet is working from our DNS by the client machine' s IP address. terminal

The installation and configuration procedure of DNS server in CentOS 7 is done successfully.

Tags:
michael
Author: 

Comments ( 4 )

sushmitajayswal
The Reverse Zone and Forward Zone configuration should contain ";"
Reverse Zone :
$TTL 86400
@ IN SOA dns1.example.com. root.dns1.example.com. (
2011071001 ; Serial
3600 ; Refresh
1800 ; Retry
604800 ; Expire
86400 ; Minimum TTL
)

@ IN NS dns1.example.com.
dns1 IN A 192.168.229.229
229 IN PTR dns1.example.com.

Forward Zone :
$TTL 86400
@ IN SOA dns1.example.com. root.dns1.example.com. (
2011071001 ; se = Serial
3600 ; ref = Refresh
1800 ; ret = Retry
604800 ; ex = Expire
86400 ; min = Minimum TTL
)
@ IN NS dns1.example.com.
@ IN A 192.168.229.229
dns1 IN A 192.168.229.229

In the named.conf file add ";" after none : allow-update { none; }
waqaralikhan
typing mastake
linuxhelp
check your named.conf file at zone entry and also check your SOA record file.
sajidali14391
i am getting this error please resolve this issue i am using centOs 7 .i did the same above conf but getting the error following below


[root@DNS named]# named-checkconf /etc/named.conf
/etc/named.conf:56: missing ';' before 'file'
/etc/named.conf:57: missing ';' before 'allow-update'
/etc/named.conf:57: missing ';' before '}'
/etc/named.conf:58: missing ';' before '}'
/etc/named.conf:60: missing ';' before 'zone'
/etc/named.conf:62: missing ';' before 'file'
/etc/named.conf:63: missing ';' before 'allow-update'
/etc/named.conf:63: missing ';' before '}'
/etc/named.conf:64: missing ';' before '}'
/etc/named.conf:66: missing ';' before 'include'
[root@DNS named]# named-checkzone linuxhelp11.com /var/named/fwd.linuxhelp11
dns_rdata_fromtext: /var/named/fwd.linuxhelp11:3: near 'Serial': syntax error
zone linuxhelp11.com/IN: loading from master file /var/named/fwd.linuxhelp11 failed: syntax error
zone linuxhelp11.com/IN: not loaded due to errors.
Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

What is a Fully Qualified Domain Name?

A

A Fully Qualified Domain Name is the complete name to specify a specific computers location in the hierarchy of a complete domain. For example there may be two groups within the DNS Made Eas

Q

Is DNS TCP or UDP?

A

DNS uses TCP for Zone transfer and UDP for name queries either regular (primary) or reverse. UDP can be used to exchange small information whereas TCP must be used to exchange information larger than 512 bytes.

Q

What is DNS and its function?

A

DNS stands for Domain Name System. The main function of DNS is to translate domain names into IP Addresses, which computers can understand.

Q

Why UDP is used for DNS?

A

The client that sent the original DNS request will know to resubmit the request using the TCP protocol. The DNS protocol itself is designed to be a simple, small protocol. UDP is simple, fast, and reasonable reliable. DNS is simple enough that a simple stateless protocol like UDP is better-suited than TCP.

Q

Is DNS a protocol?

A

The domain name system (DNS) is the way that internet domain names are located and translated into internet protocol (IP) addresses.

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Ryan ?
how to use visual traceroute tool

Am using traceroute command to check for the route. i got this tool while surfing. So pls help me out installation and usage of Visual traceroute tool.

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.