X
    Categories: Linux

DNS (Domain name system).

DNS stands for Domain name system. The basic purpose of the DNS is to provide the IP or resolve the IP address of the Web site/hostname/domain & vice versa.

In smaller scale we do have /etc/hosts to perform the task of converting the hostname & giving us the respective ip address of the system. However this /etc/system has got some limitations such as,

  1. As its normal text file can be readable , it’s not encrypted.
  2. Updating the file is huge task
  3. To have updated copy of the same you will have to download lasted copy which puts also burden on the network.

Hence to overcome above issues DNS comes into picture.

Do not forget to see  my video logs at the last page of this page!!!!! 

          

 

The hierarchy of the domain is as follows:

A domain is a sequence of labels from the node at the root of the domain to the root of the whole tree, with the labels separated by dots.

Each DNS has TLD i.e. Top level domain define like .com or .org. or .in. They have got the authority for naming of the DNS. Under this we have domain name like here we have example domain. Each of the top-level domains has a number of name servers. These are the servers that have information on the hosts within the domain.  Under top level domain we have got subdomain like us.exmple.com here us is the subdomain of the example.com. Under this we have individual host name that exist.

DNS name resolution process.

Consider finding domain name resolution of www.uxtechno.in from the client location www.example.com. Then following steps will occur.

  1. Firstly the request will come to the name server of the example.com for checking the ip record hence it will check the cache. & luckily if it found the record in the cache it will give back to example.com & process will stop here. Else it will go next step.
  2. Then system will check for the configuration of the forwarder. It’s a DNS name server which receives the requests that are not answered by local DNS server. If this fails it will go to next step.
  3. When control come at the DNS server it follows the execution one by one. At first it will contact the name servers of the DNS root domain to find out how to reach the name servers of the .in domain.
  4. Once it found the name server of the .in domain it will check which name server to contact to get the details of the uxtechno domain.
  5. Once it finds name server who has authority for uxtechno.in domain. Name server will send request to get the resource record (ip) it requires. After finding this it will cache this record & sends back to the client.

Steps Setting Up a Primary Name Server:

  1. Check your ip using ifconfig command.

In this example the ip  of the system is 192.168.216.131 and FQDN (fully qualified domain name)             is “kalwa2.home.com”.

  1. Add entry below entry in the file /etc/sysconfig/network-scripts/ifcfg-eth0

DNS1=192.168.216.131

e.g.

# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=”eth0″
BOOTPROTO=”dhcp”
HWADDR=”00:0C:29:9F:B1:76″
IPV6INIT=”no”
DNS1=192.168.216.131
NM_CONTROLLED=”yes”
ONBOOT=”yes”

3. Add below entry in the /etc/hosts file.

192.168.216.131 kalwa2.home.com kalwa

4. Add below entry in the /etc/sysconfig/network

HOSTNAME=kalwa2.home.com

5.     Add below entry in /etc/resolv.conf file
      search localdomain home.com
      nameserver 192.168.216.131
6.     service network restart
7.     yum install bind* (you need yum server configured to work this command)
8.     change below entries in /etc/named.conf

listen-on port 53 { 192.168.216.131; };
# listen-on-v6 port 53 { ::1; }; (make this entry hashed)
allow-query { any; };
include “/etc/named.rfc1912.zones”;

9.     Change below entries in “/etc/named.rfc1912.zones”;

zone “home.com” IN {
type master;
file “forward.zone”;
allow-update { none; };
};

&  also below entry  for reverse lookup (Note: make sure that the IP is in reverse order )

zone “216.168.192.in-addr.arpa” IN {
type master;
file “reverse.zone”;
allow-update { none; };
};

10.    cd /var/named/
11.    cp named.localhost forward.zone
12.    cp named.loopback reverse.zone
13.   change below entries in forward.zone file

@ IN SOA kalwa2.home.com. root.kalwa2.home.com. (

   IN NS kalwa2.home.com.
   Kalwa2 IN A 192.168.216.131
   e.g. [root@kalwa2 named]# cat forward.zone
   $TTL 1D
   @ IN SOA kalwa2.home.com. root.kalwa2.home.com. (
   0 ; serial
   1D ; refresh
   1H ; retry
   1W ; expire
   3H ) ; minimum
          IN NS kalwa2.home.com.
   kalwa2 IN A 192.168.216.131
14.    Change below entries in reverse.zone file
    @ IN SOA kalwa2.home.com. root.kalwa2.home.com. (
        IN NS kalwa2.home.com.
    131 IN PTR kalwa2.home.com.
e.g.
    [root@kalwa2 named]# cat reverse.zone
    $TTL 1D
    @ IN SOA kalwa2.home.com. root.kalwa2.home.com. (
        0 ; serial
       1D ; refresh
       1H ; retry
       1W ; expire
       3H ) ; minimum
       IN NS kalwa2.home.com.
   131 IN PTR kalwa2.home.com.

15.    chgrp named forward.zone
16.    chgrp named reverse.zone
17.    service named start
e.g.
  [root@kalwa2 named]# service named start
     Starting named: [ OK ]
18.  Now test DNS configuration using dig command i.e.dig kalwa2.home.com
NOTE: check for BOLD & UNDERLINED word from the output section for successful DNS configuration.
[root@kalwa2 named]# dig kalwa2.home.com

; <<>> DiG 9.7.3-P3-RedHat-9.7.3-8.P3.el6 <<>> kalwa2.home.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 10350
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 0

;; QUESTION SECTION:
;kalwa2.home.com. IN A

;; ANSWER SECTION:
kalwa2.home.com. 86400 IN A 192.168.216.131

;; AUTHORITY SECTION:
home.com. 86400 IN NS kalwa2.home.com.

;; Query time: 0 msec
;; SERVER: 192.168.216.131#53(192.168.216.131)
;; WHEN: Tue Jun 16 09:00:44 2015
;; MSG SIZE rcvd: 63

19.   Now lets test reverse lookup using dig -x 192.168.216.131 command.

NOTE: check for BOLD & UNDERLINED word from the output section for successful DNS configuration.
e.g.
[root@kalwa2 named]# dig -x 192.168.216.131

; <<>> DiG 9.7.3-P3-RedHat-9.7.3-8.P3.el6 <<>> -x 192.168.216.131
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3477
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1

;; QUESTION SECTION:
;131.216.168.192.in-addr.arpa. IN PTR

;; ANSWER SECTION:
131.216.168.192.in-addr.arpa. 86400 IN PTR kalwa2.home.com.

;; AUTHORITY SECTION:
216.168.192.in-addr.arpa. 86400 IN NS kalwa2.home.com.

;; ADDITIONAL SECTION:
kalwa2.home.com. 86400 IN A 192.168.216.131

;; Query time: 0 msec
;; SERVER: 192.168.216.131#53(192.168.216.131)
;; WHEN: Tue Jun 16 09:01:06 2015
;; MSG SIZE rcvd: 105
20.  nslookup

e.g.
[root@kalwa2 named]# nslookup
> kalwa2.home.com
Server: 192.168.216.131
Address: 192.168.216.131#53

Name: kalwa2.home.com
Address: 192.168.216.131

Click next page for Video log of the DNS server configuration activity.

Please select 720p HD quality in setting for better quality of the video log visualization.

 

Related Post