Sie sind auf Seite 1von 11

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

Alias (CNAME) Record: Mapping alias DNS domain name to another

hostname to IP Address
(Ex:sys1.linuxtechies.com = 210.211.230.77)

name .
(Ex: www.linuxtechies.com = sys1.linuxtechies.com)

Pointer (PTR) record : Mapping an IP Address to Hostname

Mail Exchange (MX)records : Mapping DNS domain name to name of

(Ex: 210.211.230.77 = sys1.linuxtechies.com)


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 ~]#

[root@localhost ~]# vi /etc/resolv.conf


; generated by /sbin/dhclient-script
search localdomain
nameserver 192.168.5.1
~

:wq

[root@localhost ~]#
Step2 : Configure hostname mylinuxpc1.linuxtechies.com

[root@localhost ~]# hostname


localhost.localdomain
[root@localhost ~]#
[root@localhost ~]# hostname mylinuxpc1.linuxtechies.com
[root@localhost ~]#
[root@localhost ~]# hostname
mylinuxpc1.linuxtechies.com
[root@localhost ~]#
[root@localhost ~]# vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=mylinuxpc1.linuxtechies.com
:x
[root@localhost ~]#
[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

Dependencies Resolved
===========================================================================
Package
Arch
Version
Repository
Size
===========================================================================
Installing:
bind
i386
30:9.3.3-7.el5
core
954
k
bind-chroot
i386
30:9.3.3-7.el5
core
38
k
bind-devel
i386
30:9.3.3-7.el5
core
2.6
M
bind-libbind-devel
i386
30:9.3.3-7.el5
core
440
k
bind-libs
i386
30:9.3.3-7.el5
core
834
k
bind-sdb
i386
30:9.3.3-7.el5
core
223
k
bind-utils
i386
30:9.3.3-7.el5
core
162
k
caching-nameserver
i386
30:9.3.3-7.el5
core
55
k
Transaction Summary
===========================================================================
Install
8 Package(s)
Update
0 Package(s)
Remove
0 Package(s)
Total download size: 5.2 M
Downloading Packages:
(1/8): bind-chroot-9.3.3- 100% |=========================| 38 kB
(2/8): bind-sdb-9.3.3-7.e 100% |=========================| 223 kB
(3/8): bind-libbind-devel 100% |=========================| 440 kB
(4/8): bind-devel-9.3.3-7 100% |=========================| 2.6 MB
(5/8): bind-libs-9.3.3-7. 100% |=========================| 834 kB
(6/8): caching-nameserver 100% |=========================| 55 kB
(7/8): bind-utils-9.3.3-7 100% |=========================| 162 kB
(8/8): bind-9.3.3-7.el5.i 100% |=========================| 954 kB
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: bind-libs
#########################
Installing: bind
#########################
Installing: bind-utils
#########################
Installing: bind-chroot
#########################
Installing: bind-sdb
#########################
Installing: bind-libbind-devel
#########################
Installing: bind-devel
#########################
Installing: caching-nameserver
#########################

00:00
00:00
00:00
00:00
00:00
00:00
00:00
00:00

[1/8]
[2/8]
[3/8]
[4/8]
[5/8]
[6/8]
[7/8]
[8/8]

Installed: bind.i386 30:9.3.3-7.el5 bind-chroot.i386 30:9.3.3-7.el5 binddevel.i386 30:9.3.3-7.el5 bind-libbind-devel.i386 30:9.3.3-7.el5 bindlibs.i386 30:9.3.3-7.el5 bind-sdb.i386 30:9.3.3-7.el5 bind-utils.i386
30:9.3.3-7.el5 caching-nameserver.i386 30:9.3.3-7.el5
Complete!
[root@mylinuxpc1 /]#

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

; serial (d. adams)


; refresh

15M
1W
1D )
@
mylinuxpc1
www

IN NS
IN A
IN A

; 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 mylinuxpc1.linuxtechies.com.
root.mylinuxpc1.linuxtechies.com. (
1997022700 ; Serial
28800
; Refresh
14400
; Retry
3600000 ; Expire
86400 ) ; Minimum
@
IN
NS
mylinuxpc1.linuxtechies.com.
1
IN
PTR mylinuxpc1.linuxtechies.com.
:wq

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
A
NS

192.168.5.1
mylinuxpc1.linuxtechies.com.

;; ADDITIONAL SECTION:
mylinuxpc1.linuxtechies.com. 86400 IN A

192.168.5.1

;; Query time: 0 msec


;; SERVER: 192.168.5.1#53(192.168.5.1)
;; WHEN: Fri Jul 05 15:15:05 2013
;; 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

Das könnte Ihnen auch gefallen