Wednesday, 7 January 2015

Quick Start: Setup CentOS 7 as a DNS Server

Quick Start: Setup CentOS 7 as a DNS Server

In this tutorial, I'll be showing you simply steps using which you can create and configure a functional DNS Server on your CentOS 7 system.

System Details:
Base OS:        CentOS 7 64 Bit (Minimal ISO)


First of all, make sure your system has a static IP address assigned to it and a fully qualified domain name.

Next, install the DNS packages:

# yum install bind bind-utils

Edit the "named.conf" file and edit the content as shown below:

# vi /etc/named.conf

# Replace the content in RED with your values
options {
listen-on port 53 {;;}; ## DNS Server IP
# listen-on-v6 port 53 { ::1; };
directory "/var/named";
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;;}; # IP Subnet

# Add the following lines before the include statement as shown
zone "" IN { 
type master; 
file ""; 
allow-update { none; }; 
zone "" IN { 
type master; 
file ""; 
allow-update { none; }; 

Save the file and exit the editor.
Next, we create the Zone files. There will be two files created, one for the forward lookup and one for the reverse lookup. These files are created in the /var/named directory and their names should be same as mentioned in the named.conf file (Earlier steps)

Forward Zone Lookup File:

# vi /var/named/

Add the following content as shown. Replace the content marked in RED with your matching requirements.

$TTL 86400 
@ IN SOA ( 
             2011071001 ;Serial 
             3600 ;Refresh 
             1800 ;Retry 
             604800 ;Expire 
             86400 ;Minimum TTL  
@    IN     NS
@    IN     A 
@    IN     A 
@    IN     A 
master       IN       A 
client1       IN       A 
client2       IN       A

Save and exit the editor.

Reverse Zone Lookup File:

# vi /var/named/

$TTL 86400 
@ IN SOA ( 
             2011071001 ;Serial 
             3600 ;Refresh 
             1800 ;Retry 
             604800 ;Expire 
             86400 ;Minimum TTL  
@    IN     NS
@    IN     PTR
master       IN       A 
client1       IN       A 
client2       IN       A
15       IN     PTR
101     IN     PTR
102     IN     PTR

Save and exit the editor.

Enable and start the DNS service:

# systemctl enable named

# systemctl start named

Enable the ports on the Firewall and reload the firewall

# firewall-cmd --permanent --add-port=53/tcp

# firewall-cmd --reload

Verify your DNS:

Check DNS default configuration file for errors:

# named-checkconf /etc/named.conf

Next, check both the forward and reverse lookup files for any errors as well.

# named-checkzone /var/named/

# named-checkzone /var/named/

Once checked, modify the network interface file and add the DNS details as shown below:


NOTE: In my case, I am using multiple DNSs. You can assign multiple DNS values using as shown in the image below.

Alternatively, you can even add the DNS entry in the /etc/resolv.conf file as well for name resolution.

# vi /etc/resolv.conf


Restart your network to apply the changes

# systemctl restart network

Test the DNS:

Run the following commands to verify whether the DNS can resolve the hostnames correctly or not.

# dig

You can alternatively run nslookup to verify your Zones

# nslookup

There you have it.. a simple and easy to use DNS server on a CentOS 7 System.. Hope this post helps you out! Stay tuned for a lot more coming your way soon!!



John Hill said...

Thanks for a easy to understand tutorial.

Dhiya L said...

Thank you for posting such a wonderful article here. I got some valid information. Really article with execution models you had posted. It was such informative. Really its a wonderful article. Thank you for sharing and please keep update like this type of article because i want to learn more relevant to this topic.

Hadoop Training

Arjun Rishi said...

Good post. Keep sharing such a useful post.

Digital marketing training in chennai

Anu Sri said...

Glad to find your blog. You shared useful post. Thanks !

php training institute in chennai

Unknown said...

I was very impressed with you. website you create highly qualified and highly original contents obat tradisional tbc. It's very very cool I like. obat radang amandel Keep the spirit.

Rajapriya R said...

nice and really helpful article to everyone... thanks for sharing

selenium training in chennai | selenium training institute in chennai | Android training in chennai | android training institute in chennai

Saradha Devi said...

great one
Best Selenium Training in Chennai | Android Training in Chennai | Java Training in chennai | Webdesigning Training in Chennai

Qinan Chen said...

discount nike shoes
polo ralph lauren outlet online
true religion jeans outlet
cheap ugg boots
jordan retro
kobe bryant shoes
jordan femmes pas cher
ugg sale
burberry outlet online

Distributor Pusat Jelly Gamat QnC said...

Your article is very original, I was amazed by you. It contained interesting to see and not boring. I hope this website you manage to be the best and be number one.
obat pengapuran
obat sakit pinggang

rufus golla said...

Thank u so much very easy tutorial.

Post a Comment