Вы находитесь на странице: 1из 9

DNS (Domain Naming System)

What is DNS?

DNS (Domain Naming System) is used to resolve (convert) friendly Hostname


(www.gayatricomputers.com) to IP Address (210.211.230.77) and IP Address to
Hostname.

How does DNS Server work?


DNS server converts friendly name (www.gayatricomputers.com) to Hostname
(sys1.gayatricomputers.com) and Hostname to IP Address (210.211.230.77)

Namespace in DNS / DNS Structure

Types of DNS servers:


1.Primary DNS Server : The first DNS server which contains master copy all
database (Hostnames and IP Addresses )
2. Secondary DNS server: The second DNS server which contains replication
(Duplicate) database from Primary DNS server.
What are the functions of Secondary DNS server? (OR)Why do require Secondary DNS
server?
Secondary DNS Provides:
1. Load Balancing: If the Primary DNS server got more load then some load will
shared (Balanced) by secondary DNS servers.
2. Fault Tolerance: If the Primary DNS server fails ,then converting from
hostname to IP Address will be done by Secondary DNS servers.
Types of Zones in DNS server
Zone: It is text file, which contains information about Hostnames ,IP Addresses
and Alias records ..Etc.
/etc/named.caching-nameserver.conf
/etc/named.rfc1912.zones

Types of Zones:
1 .Forward Lookup Zone: This Zone contains information for converting
Hostname to IP Address.
var/named/chroot/var/named/ localdomain.zone
var/named/chroot/var/named/ localhost.zone

2. Reverse Lookup Zone: This zone contains information for converting IP Address
to Hostname.

var/named/chroot/var/named/ named. local

Types of Resource Records in Zones:


Host (A) Record : Mapping hostname to IP Address (Ex:sys1.linuxtechies.com =
210.211.230.77)
Alias (CNAME) Record: Mapping alias DNS domain name to another name .
(Ex: www.linuxtechies.com = sys1.linuxtechies.com)
Pointer (PTR) record : Mapping an IP Address to Hostname
(Ex: 210.211.230.77 = sys1.linuxtechies.com)
Mail Exchange (MX)records : Mapping DNS domain name to name of the
Computer ( The computer which forwards mails or exchange mails).This is
required for Mail Server (Exchange Server)
Steps for Configuring DNS Server:
Step1 : Configure IP address as 192.168.5.1 and Primary DNS Server IP as
192.168.5.1
Step2 : Configure hostname mylinuxpc1.linuxtechies.com
Step3 : Install DNS Server packages (bind packages)
Step4 : Configure /etc/named.caching-nameserver.conf
Step5 : Create Zone / Domain name in /etc/named.rfc1912.zones
Step6 : Create Forward Lookup Zone file in /var/named/chroot/var/named
Step7 : Create Reverse Lookup Zone file in /var/named/chroot/var/named
Step8: Start DNS Service named service
Step9 : Test / Diagnostics DNS Server by using dig command
Step10 : Test / Diagnostics DNS Server by using ping command
Step1 : Configure IP address as 192.168.5.1 and Primary DNS Server IP as
192.168.5.1
[root@localhost ~]# ifconfig eth0
eth0
Link encap:Ethernet HWaddr 00:0C:29:3A:3E:B6
inet addr:192.168.5.1 Bcast:192.168.5.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe3a:3eb6/64 Scope:Link

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1


RX packets:7455 errors:0 dropped:0 overruns:0 frame:0
TX packets:8359 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:686857 (670.7 KiB) TX bytes:793417 (774.8 KiB)
Interrupt:67 Base address:0x2000
[root@localhost ~]# vi /etc/resolv.conf
; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.5.1
~ :wq
Step2 : Configure hostname mylinuxpc1.linuxtechies.com
[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname mylinuxpc1.linuxtechies.com
[root@localhost ~]# hostname
mylinuxpc1.linuxtechies.com
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mylinuxpc1.linuxtechies.com
:x
[root@localhost ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1
localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.5.1 mylinuxpc1.linuxtechies.com
mylinuxpc1
:wq
[root@localhost ~]#
[root@localhost ~]# reboot
Step3 : Install DNS Server packages (bind packages)
[root@mylinuxpc1 /]# yum install

bind*

caching* -y

Step4 : Configure /etc/named.caching-nameserver.conf


[root@mylinuxpc1 /]# gedit /etc/named.caching-nameserver.conf
//
// named.caching-nameserver.conf
//
// Provided by Red Hat caching-nameserver package to configure the
// ISC BIND named(8) DNS server as a caching only nameserver
// (as a localhost DNS resolver only).

//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
// DO NOT EDIT THIS FILE - use system-config-bind or an editor
// to create named.conf - edits to this file will be lost on
// caching-nameserver package upgrade.
//
options {
listen-on port 53 { 127.0.0.1;192.168.5.1; };
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";
query-source port 53;
query-source-v6 port 53;
allow-query { localhost; 192.168.5.0/24;};
};
logging {
channel default_debug {
file "data/named.run";
severity dynamic;
};
};
view localhost_resolver {
match-clients
{ localhost; 192.168.5.0/24; };
match-destinations { localhost; };
recursion yes;
include "/etc/named.rfc1912.zones";
};
Click on Save and Exit from gedit command
Step5 : Create Zone / Domain name in /etc/named.rfc1912.zones
[root@mylinuxpc1 /]# gedit /etc/named.rfc1912.zones
// named.rfc1912.zones:
//
// Provided by Red Hat caching-nameserver package
//
// ISC BIND named zone configuration for zones recommended by
// RFC 1912 section 4.1 : localhost TLDs and address zones
//
// See /usr/share/doc/bind*/sample/ for example named configuration files.
//
zone "." IN {
type hint;
file "named.ca";
};
zone "localdomain" IN {

type master;
file "localdomain.zone";
allow-update { none; };
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
zone "linuxtechies.com" IN {
type master;
file "linuxtech.for";
allow-update { none; };
};
zone "5.168.192.in-addr.arpa" IN {
type master;
file "linuxtech.rev";
allow-update { none; };
};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa" IN {
type master;
file "named.ip6.local";
allow-update { none; };
};
zone "255.in-addr.arpa" IN {
type master;
file "named.broadcast";
allow-update { none; };
};
zone "0.in-addr.arpa" IN {
type master;
file "named.zero";
allow-update { none; };
};
Click on Save and Exit from gedit

Step6 : Create Forward Lookup Zone file in /var/named/chroot/var/named folder


[root@mylinuxpc1 ~]# cd /var/named/chroot/var/named/
[root@mylinuxpc1 named]#
[root@mylinuxpc1 named]# pwd
/var/named/chroot/var/named
[root@mylinuxpc1 named]#
[root@mylinuxpc1 named]# ls
data
localdomain.zone named.ca
localhost.zone named.ip6.local slaves
named.broadcast named.local
[root@mylinuxpc1 named]#

named.zero

[root@mylinuxpc1 named]# cp localhost.zone linuxtech.for(Forward Lookup Sample File)


[root@mylinuxpc1 named]# cp named.local linuxtech.rev (Reverse Lookup Sample File)
[root@mylinuxpc1 named]# vi linuxtech.for
$TTL 86400
@
IN SOA mylinuxpc1.linuxtechies.com.
root.mylinuxpc1.linuxtechies.com. (
42
3H
15M
1W
1D )
@
mylinuxpc1
www

IN NS
IN A
IN A

; serial (d. adams)


; refresh
; retry
; expiry
; minimum

mylinuxpc1.linuxtechies.com.
192.168.5.1
192.168.5.1

[root@mylinuxpc1 named]#
Step7 : Create Reverse Lookup Zone file in /var/named/chroot/var/named
[root@mylinuxpc1 named]# vi linuxtech.rev
$TTL 86400
@
IN
SOA

@
1
:wq

IN
IN

mylinuxpc1.linuxtechies.com. root.mylinuxpc1.linuxtechies.com. (
1997022700 ; Serial
28800
; Refresh
14400
; Retry
3600000 ; Expire
86400 ) ; Minimum
NS
mylinuxpc1.linuxtechies.com.
PTR mylinuxpc1.linuxtechies.com.

Step8: Start DNS Service named service

[root@mylinuxpc1 named]# service named status


rndc: connect failed: 127.0.0.1#953: connection refused
[root@mylinuxpc1 named]#
[root@mylinuxpc1 named]# service named start
Starting named:
[ OK ]
[root@mylinuxpc1 named]# service named status
number of zones: 9
debug level: 0
xfers running: 0
xfers deferred: 0
soa queries in progress: 0
query logging is OFF
recursive clients: 0/1000
tcp clients: 0/100
server is up and running
[root@mylinuxpc1 named]#
[root@mylinuxpc1 named]# chkconfig --list named
named
0:off 1:off 2:off 3:off 4:off 5:off 6:off
[root@mylinuxpc1 named]#
[root@mylinuxpc1 named]# chkconfig named on
[root@mylinuxpc1 named]#
[root@mylinuxpc1 named]# chkconfig --list named
named
0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@mylinuxpc1 named]#
Step9 : Test / Diagnostics DNS Server by using dig command
[root@mylinuxpc1 named]# dig www.linuxtechies.com
; <<>> DiG 9.3.3rc2 <<>> www.linuxtechies.com
;; global options: printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 44390
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; QUESTION SECTION:
;www.linuxtechies.com.
IN

;; ANSWER SECTION:
www.linuxtechies.com. 86400 IN
;; AUTHORITY SECTION:
linuxtechies.com. 86400 IN

A
NS

192.168.5.1
mylinuxpc1.linuxtechies.com.

;; ADDITIONAL SECTION:
mylinuxpc1.linuxtechies.com. 86400 IN A
;; Query time: 0 msec
;; SERVER: 192.168.5.1#53(192.168.5.1)
;; WHEN: Fri Jul 05 15:15:05 2013

192.168.5.1

;; MSG SIZE rcvd: 99


[root@mylinuxpc1 named]#
Step10 : Test / Diagnostics DNS Server by using ping command
[root@mylinuxpc1 named]# ping www.linuxtechies.com
PING www.linuxtechies.com (192.168.5.1) 56(84) bytes of data.
64 bytes from mylinuxpc1.linuxtechies.com (192.168.5.1): icmp_seq=1 ttl=64 time=0.013
ms
64 bytes from mylinuxpc1.linuxtechies.com (192.168.5.1): icmp_seq=2 ttl=64 time=0.029
ms
64 bytes from mylinuxpc1.linuxtechies.com (192.168.5.1): icmp_seq=3 ttl=64 time=0.037
ms
64 bytes from mylinuxpc1.linuxtechies.com (192.168.5.1): icmp_seq=4 ttl=64 time=0.029
ms
64 bytes from mylinuxpc1.linuxtechies.com (192.168.5.1): icmp_seq=5 ttl=64 time=0.031
ms
--- www.linuxtechies.com ping statistics --5 packets transmitted, 5 received, 0% packet loss, time 4001ms
rtt min/avg/max/mdev = 0.013/0.027/0.037/0.010 ms
[root@mylinuxpc1 named]#
Requirements for DNS Clients :
1.PC with any O.S (Linux /Windows / Apple Mac O.S )
2.PC with NIC (LAN Card)
Steps for Configuring DNS Clients:
Step1 : Configure IP address as 192.168.5.2 ( between 192.168.5.2 to 192.168.5.254)
Step2 : Configure Primary DNS Server as 192.168.5.1 in /etc/resolve.conf file for
Linux O.S
Step3 : Configure Preferred DNS Server as 192.168.5.1 in TCP/IP Configuration
window
Test DNS by using ping www.linuxtechies.com command

Вам также может понравиться