Contact for queries :

Login

  UpComing Live WebEx Workshop Series

DNS Server Configuration in Linux

When you’re trying to access a website, you type in the name you are looking  for and it comes up.

In the background, though, Domain Name Service (DNS) is what translates that website name into an IP address so that the site may be accessed. This translation also occurs when you are connecting to other systems on your network through their hostnames instead of their IP addresses.

DNS plays a critical role not only in your networks, but also on the Internet as a whole. Knowing how to set up, maintain, and troubleshoot such a server is vital to any network.

The root DNS servers for the world run BIND as their DNS software choice, so naturally Red Hat also includes it on the exams. This chapter covers BIND in great detail because it is such a critical network component.

Task1 : Setting Up BIND

Just as with any other service, you need to install the packages for BIND first.

Step 1. Install the required packages:

# yum install -y bind bind-utils bind-libs

Step 2. Verify that the packages have been installed:

# rpm -qa | grep ^bind
bind-utils-9.7.0-5.P2.el6.x86_64
bind-9.7.0-5.P2.el6.x86_64
bind-libs-9.7.0-5.P2.el6.x86_64

Step 3. Ensure that the service is set to start on system boot:

# chkconfig named on

Step 4. Verify that the service is set to start on boot:

# chkconfig –list named
named 0:off 1:off 2:on 3:on 4:on 5:on 6:off

At this point, you need to decide what type of DNS server you would like to set up. According to Red Hat, there are two types of nameservers:

■ Authoritative—These nameservers answer to resource records that are part of their zones only. This includes both primary (master) and secondary (slave) nameservers.

■ Recursive—These nameservers offer resolution services but are not authoritative for any zone. All query answers are cached in memory for a fixed period of time.

There is another way you can classify nameservers:

■ Master—This nameserver stores original and authoritative zone records for a particular namespace. It also answers queries about the namespace from other nameservers. Each domain must have at least one master.

■ Slave—Although this nameserver receives its namespace information from a master nameserver, this nameserver type can answer queries for which it has authority.  Used for load balancing and redundancy.

■ Caching—This nameserver has no authority and is primarily used for name-to-IP resolution. All resolutions are cached for a fixed period of time. Heavily used by Internet service providers (ISPs).

■ Forwarding—This nameserver has no authority and is used only to forward requests
to specific nameservers for resolution.

Each domain for which your server has authority is called a zone and the information for that zone in kept in….wait for it…zone files.

The caching DNS server requires an additional package to be installed, so let’s start by setting up a master DNS server and its zone first.

Each zone file also requires that you use the fully qualified domain name (FQDN) when defining hostnames. Although we usually address the configuration first, let’s look at the SELinux and firewall requirements instead because the configuration of BIND can become complex.

Task2 : SELinux and Firewall Rules for DNS Server

Task3 : DNS Server Configuration

To begin configuring the DNS server, check out these key config files for a BIND server:

/etc/named.conf Main config file
/etc/rndc.key Key file
/etc/rndc.conf Key config file
/usr/share/doc/bind-9*/sample Directory that holds sample files

Before you do anything, you should make a backup of the /etc/named.conf file:

# cp /etc/named.conf /etc/named.conf.orig

You should also remove this file for now because you will be making a new one in the coming sections:

# rm /etc/named.conf

The first step for configuration is to make sure that your system has a static IP address and that the /etc/resolv.conf file is pointing to localhost as the nameserver:

Step 1. Verify that the localhost is used for DNS queries on RHEL01:
# cat /etc/resolv.conf
search example.com
nameserver 127.0.0.1
nameserver 192.168.1.1

The secondary server listed here is actually my personal router, which can provide DNS as well. Before going any further, you should also understand the different types of resource records used with DNS and why each one is important.

/etc/named.conf Main config file
/etc/rndc.key Key file
/etc/rndc.conf Key config file
/usr/share/doc/bind-9*/sample Directory that holds sample files

A                 – Maps the hostname to an IP address
NS             – Contains the IP address or CNAME of the nameserver
MX           – Defines where mail for a particular domain goes
PTR          – Maps the IP address to a hostname
SOA         – Contains general administrative control for the domain
CNAME  – Used as an alias

There are four different DNS server types, so let’s start with the configuration of each one.

 Troubleshooting DNS Server Configurations.

For the server and client, there are a handful of utilities you can use to verify the functionality of DNS. These utilities include

  • dig                – DNS lookup utility
  • host             –  DNS lookup utility
  • ping             –  Network or hostname verification utility
  • nslookup    –   Utility to lookup a hostname from an IP addresses
  • hostname   –  Utility to sets or show the system hostname (FQDN)

Please refer the below links for more information on using the above tools for troubleshooting.

Setup a FQDN ( fully Qualified domain name) in Linux

It is important to have proper FQDN set for each host that is configured with DNS. If you still haven’t set up the FQDN for your system, you can use the hostname command to set it up.

Syntax: hostname [FQDN]

Step 1. Query the current FQDN of your system:

# hostname
rhel01

Step 2. If you want to change it, you can again use the hostname command, but specify the FQDN after the command:

# hostname rhel01.example.com

This changes your system’s hostname to include the domain in the hostname. If you make any changes to the hostname, you should reboot your system before continuing. As a final troubleshooting step, make
sure that your clients have the correct information located in the /etc/resolv.conf file.
Step 3. Change these DNS settings for Client01:

# cat /etc/resolv.conf
search example.com
nameserver 172.168.1.1
 

November 16, 2015

1 responses on "DNS Server Configuration in Linux"

Leave a Message

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

About iGURKUL

IGURKUL I.T. Training Hub offering various Career Certification courses in Computer Networking, Unix, Linux, Cloud Computing and DevOps Technologies. With its rich experience in IT training service sector, iGURKUL has been able to set Industry best practices in IT Training for the past five years.

In Past five years, more than 5000 professionals have been trained by iGURKUL for System administration, Cloud Computing and DevOps Skill set through our Online Training portal www.unixadminschool.com. And , each day , more than 10000 working professionals from all over the globe visiting our knowledge base www.unixadminschool.com/blog for the best practices and Knowledge learning.

top
copyright protected - 2011 © igurkul I.T. solutions. All rights reserved.