Dns Server Configuration In Linux 6 Step By Step Pdf To Excel

HOW TO CONFIGURE LINUX DNS SERVER STEP BY STEP GUIDE EXAMPLE AND IMPLEMENTATION

A DNS server, or name server,is used to resolve an IP address to a hostname or vice versa.
You can set up four different types of DNS servers:
  • A master DNS server for your domain(s), which stores authoritative records for your domain.
  • A slave DNS server, which relies on a master DNS server for data.
  • A caching-only DNS server, which stores recent requests like a proxy server. It otherwise refers to other DNS servers.
  • A forwarding-only DNS server, which refers all, requests to other DNS servers.

CONFIGURE DNS SERVER

In this example we willconfigure a dns server and will test from client side.

For this example we are usingthree systems one linux server one linux clients and one window clients.

Step 1 - bind and caching-nameserver rpm is required to configure dns. Check them for install if not foundinstall them

Step 2 -set hostname to server.example.com and ip address to 192.168.0.254




Main configuration file for dns server is named.conf. By default this file is notcreated in /var/named/chroot/etc/ directory.Instead of named.conf a sample file /var/named/chroot/etc/named.caching-nameserver.confis created. This file is use to make a caching only name server.You can also do editing in this file after changing its name to named.conf to configure master dnsserver or you can manually create a new named.conf file.


In our example we arecreating a new named.conf file


Or do editing exactlyas shown here in image

save this file with :wq and exit

Configure zone file

We have defined two zone files example.com.zone for forward zone and 0.168.192.in-addr.arpa for reverse zone. These files will be store in /var/named/chroot/var/named/location. We will use two sample files for creating these files.

By default this filewill look like this
Change this fileexactly as shown in image below
Now open reverse lookupzone file 0.168.192.in-addr.arpa
By default it will look like this


Now changed the ownershipof these zone files to named group

Setting up a DNS server using BIND. This little lab project will show you how to install and configure BIND on your computer as a caching name server, test it, then set it up as a primary name server with a zone file that you can use as a name resolver for your network or just for testing. The Deployment Guide documents relevant information regarding the deployment, configuration and administration of Red Hat Enterprise Linux 6. It is oriented towards system administrators with a.

Domain Name Server (DNS) used for name resolving to any hosts. Master DNS servers (Primary Server) are the original zone data handlers and Slave DNS server (Secondary Server) are just a backup servers which is used to copy the same zone information’s from the master servers. Master Server will resolve the names for every hosts which we defined in the zone database and use UDP protocol, because UDP protocols never use the acknowledgement process while tcp uses acknowledgement. DNS servers also use UDP protocols to resolve the query request at the earliest.

How DNS Works?

Understanding DNS might be little confusing for newbies. Here is a brief explanation on how the DNS work’s.

Let’s say, if we need to access any website what we will do? Just type www.google.com in browser and hit enter. Hmm that’s all we know, but the fact is, how pain DNS go through it, while querying for us. While we type www.google.com the system will look for www.google.com. Whenever we type some domain name, there is a . (dot) at the end of the www.google.com that say to search the root server of namespace.

Globally there are 13 root servers available to resolve the query. At first, while we hit enter as www.google.com our browser will pass a request to our local resolver, which has entry about our master and slave DNS server info. If they don’t have info about such requested query they will pass the request to the Top Level domain (TLD), if TLD say I don’t know the request, may be the authoritative server know your request, it will forward to authoritative servers, here only www.google.com was defined as address 72.36.15.56.

In mean time authoritative server will give the answer to TLD and TLD will pass to root server and root will provide the info to browser, hence the browser will cache the DNS request for future use. Thus these long process will just resolve with in milliseconds. If they don’t know the request they will reply as NXDOMAIN. That means, there is no record any-were found in the Zone database. Hope this makes you to understand how the DNS works.

Read Also: Setup DNS Cache Server in Ubuntu

Server
My Testing Environment

For this article, I’m using 3 machines, 2 for server setup (master and slave) and 1 for client.

Requirement Packages
Configuration Files Used
Port & Protocols Used

Setup Master DNS Server

First, verify the IP address, Hostname and Distribution version of Master DNS Server, before moving forward for setup.

Verify Master Configuration

Once, you confirm that the above settings are correct, its time to move forward to install required packages.

Installing and Configuring Bind

After installing required packages, now define zone files in master configuration ‘named.conf‘ file.

Given below is my named.conf file entry, change the configuration file as per your need.

Create Zone File in DNS

Following are the explanation of each configuration we used in above file.

  1. listen-on port 53 – This is used for the DNS to listen in available interfaces.
  2. Master DNS – Define, your Master DNS IP address to listen the query.
  3. Slave DNS – Define your Slave DNS, which is used to sync our zone information to resolve the hosts from Master.
  4. recursion no – If its set to yes, recursive queries will make the server into DDOS attack.
  5. Zone Name – Define your Zone name here defined as tecminlocal.com.
  6. type master – As this system was configured for a master server, for upcoming slave server this will be slave.
  7. tecmintlocal.fwd.zone – This file have the host information for this zone.
  8. allow-update none – If none will set. it won’t use Dynamic DNS (DDNS).

Creating Master Zone Files

At first let us define forward look-up zone entry. Here we need to create the zone files in the name of what we have define in the named.conf file as below.

We use sample configuration files for creating forward zone files, for this we’ve to copy the sample configuration files.

Once, you’ve copied configuration files, now edit these zones files using vim editor.

Before defining our host information in forward zone file, first have a quick look at the sample zone file.

Sample Zone File

This is my forward zone configuration, append the below entry and make changes as per your need.

Save and quit the file using wq!. After editing the forward look-up, it looks like below, Use TAB to get a decent format in zone file.

Dns Server Configuration In Linux 6 Step By Step Pdf To Excel Converter

Now, create reverse lookup file, we have already made a copy of loop-back file in the name of tecmintlocal.rev.zone. So, we use this file to configure our reverse look-up.

Before defining our host information in reverse zone file, have a quick look of sample reverse lookup file as shown below.

Sample Reverse Lookup Zone

This is my reverse zone configuration, append the below entry and make changes as your need.

Save and quit the file using wq!. After editing the reverse look-up, it looks like below, Use TAB to get a decent format in zone file.

Check the group ownership of forward look-up & reverse look-up files, before checking for any errors in configuration.

Here we can see both the files are in root users ownership, because files which we makes a copy from sample files are available under /var/named/. Change the group to named on both files using following commands.

After setting correct ownership on the files, verify them again.

Verify Zone Files

Now, check for the errors in zone files, before starting the DNS service. First check the named.conf file, then check other zone files.

By default iptables was running and our DNS server is restricted to localhost, if client wants to resolve name from our DNS Server, then we have to allow the inbound request, for that we need to add iptables inbound rule for the port 53.

Now, verify that the rules has been added correctly in INPUT chain.

Next, save the rules and restart firewall.

Open DNS Port on Firewall

Start the named service and make it persistent.

Finally, test the configured Master DNS zone files (forward and reverse), using dig & nslookup tools.

Test Forward DNS Zone

Test DNS Zones

Cool! we have configured a Master DNS, now we need to setup a Slave DNS Server. Let’s move forward to setup a slave server, This won’t take much time as master setup.

Setup Slave DNS Server

In Slave machine, also we need to install same bind packages as shown in Master, so let’s install them using following command.

Open and edit ‘named.conf’ file for our zone database and port listen.

Make changes as shown, as per your requirements.

Configure Slave DNS

Start the DNS service using.

After restarting the bind service, we don’t have to define the zone information individually, as our allow-transfer will replicate the zone information from master server as shown in the image below.

Verify, the zone information using cat command.

Next, open DNS port 53 on iptables to allow inbound connection.

Save the iptables rules and restart the iptables service.

Make the service persistent on system boot.

Open DNS Port

That’s it!. Now time to configure our client machines and check for the hostname.

Configure Client Machine

In client side we need to assign the Primary (192.168.0.200) and Secondary DNS (192.168.0.201) entry in network settings to get assign a hostname. To do, run the setup command to define all these entries as shown in the picture.

Else, edit the ‘/etc/reslov.conf‘ file and add the following entries.

Now, verify the ip, hostname and name server look-up.

Verify DNS Entry

Now, check the forward & Reverse DNS look-up using.

Understaing the dig Output:

  1. Header – This says everything what we have asked and how the result was.
  2. Status – Status was NO ERROR, that means which query request sent by us was successful without any ERROR.
  3. Question – The Query which was made by us, here my query was masterdns.tecmintlocal.com.
  4. Answer – The Query request resolved if there is available information.
  5. Authority – The name servers response for the domain and zone.
  6. Additional – Additional info’s regarding name-servers such as host-name and IP address.
  7. Query time – How long it took for resolving the names from the above servers.

Finally check for our node and make a ping.

Check Client DNS Info

Finally, setup completed, here we have configured both Primary (Master) and Slave (Seconday) DNS server successfully, hope everyone have setup-ed without any issue, feel free to drop a comment if you face any issue while setup.

Share