Bind DNS Service

dns

DNS is a structured database system that maps a computer’s fully qualified domain name into an IP address.

Computers in a network use IP addresses to locate and connect to each other, but IP addresses is not easy for people to remember. For example, on the web, it’s much easier for people to remember the www.genuinewebhosting.net than it is to remember its IP address (20.20.20.3).

Reverse DNS (rDNS) does the opposite. It translates IP addresses to a domain name.

How to identify a network device

A node or computer in a network can be identified by

  • MAC address : This is a permanent hex number punched in the NIC.
  • IP address: Assigned by a network administrator, used in LAN using TCP/IP protocol
  • Domain name: such as genuinewebhosting.net, yahoo.com. etc

How systems communicate in a network

In this example the computer-A is trying to view the site using the URL http://mycomp.com

The host ‘A’ contacts the DNS server to find the IP for ‘mycomp.com’, gets it from the DNS, and then contact the IP address for the web page.

DNS Structure

The Internet Corporation for Assigned Names and Number

The ICANN manages the DNS root of the Internet domain namespace. It’s role is to manage the assignment of identifiers, and to ensuring that all users have unique names.

DNS settings in client hosts

In the client system, the IP address of a default DNS server has to be provided

  • In a linux hosts the initial resolver is configured using the file /etc/resolve.conf
  • In windows the default DNS server is configured in the TCP/IP settings

Types of Records in a DNS database

Types on entries/records used in a DNS database are as follows:

  • A record: Used to point a domain name to an IP address
  • PTR record: Used to point an IP to a domain name
  • CNAME record: Used to point a domain name to another domain name
  • MX record: Used to point to a mail server’s IP
  • NS record: Points to its Name Server

Installing BIND DNS

Rpms that are required to install BIND DNS are:
1. Bind-9_ _ _.rpm
2. Caching_nameserver_ _ _.rpm
3. bind_utils_ _ _.rpm

Configuration file : /etc/named.conf
Demon : named

Where are the named log?

Transaction of BIND DNS by default are logged in /var/log/messages
Detail logging can be enabled using the rndc utility.
# rndc querylog : This command is used to enable/disable detail logs.
# service named status : This will output the status of logging too.

Creating a simple /etc/named.conf

# vi /etc/named.conf

options {
directory “/var/named”;
};

zone “mycomp.com” {
type master;
file ” mycomp_forward”;
};

zone “0.168.192.in-addr.arpa” {
type master;
file “mycomp_reverse”;
};

Check for syntax errors in named.conf

The command named-checkconf /etc/named.conf with check for any syntax errors.
Any error caught will be displayed. Else will return to prompt

How to create a forward database

The file localdomain.zone can be used as a template. Below listed templates are availanle if caching_nameserver is installed

# cd /var/named/
# cp localdomain.zone mycomp_forward
# vi mycomp_forward
Add the following line:
sample.mycomp.com.   IN   A   192.168.0.2

How to create a reverse DNS database

# cd /var/named/
# cp named.local mycomp_reverse
# vi mycomp_reverse
Add the following line:
2   IN   PTR   sample.mycomp.com.

How to check for syntax errors in database

The command named-checkzone can be used

#] named-checkzone mycomp.com /var/named/mycomp_forward
zone mycomp.com/IN: loaded serial 42
OK
#]

  • Any error caught will be displayed.
  • Else will return to prompt with the serial number.

DNS: Master/Slave

Here one DNS server will work as the master. All updates will be made in master DNS
Slave DNS pulls info from master frequently.

How to configure a slave DNS

The configuration file /etc/named.conf of a simple slave DNS server:

options {
directory “/var/named” ;
};

zone “mycomp.com” {
type slave ;
file “mycomp_forward” ;
masters {10.146.179.68; } ;
};

Once you start the DNS server this slave host will contact the master (10.146.179.68) and make a copy of sample_forward file the local host. So if this file appears in the slave host, it shows the transfer happened correctly.

Reasons why slave DNS cannot update its database from the master server

  • Check for an entry allow-transfer in the named.conf file in the master DNS server
  • Ensure the named.conf files, and the folder /var/named is owned by the user and group named.
  • The SELINUX / Iptables could create issues.