Documents to read:
1. DNS-HOWTO
Note: Use [ $ zless /usr/share/doc/HOWTO/en-txt/DNS-HOWTO.gz ]
Type [q] to exit
2. Read different files in [ /usr/share/doc/bind9-doc/arm/ ] with a
X-window browser or try with text terminal browser [ lynx ]
$ lynx file:/usr/share/doc/bind9-doc/arm/
3. TCP/IP Illustrated, Volume 1 Chapter - 14
by W. Richard Stevens
4. DNS and BIND 4th Edition
by Cricket Liu and P. Albitz
Square brackets are used to separate keywords, such as filenames,
programs names etc etc from lines of text. They have no other meaning.
Create a directory [DNS] in your home directory.
you $ mkdir DNS
Copy [ dns.txt ] in DNS directory. The following files might be needed
for installation of some programs.
bind9_9.2.1-2.woody.1_i386.deb
bind9-doc_9.2.1-2.woody.1_all.deb
libdns5_9.2.1-2.woody.1_i386.deb
libisc4_9.2.1-2.woody.1_i386.deb
libisccc0_9.2.1-2.woody.1_i386.deb
libisccfg0_9.2.1-2.woody.1_i386.deb
dnsutils_9.2.1-2.woody.1_i386.deb
telnetd_0.17-18_i386.deb
lynx_2.8.4.1b-3_i386.deb
In the following text, the IP address 172.16.2.10 is used as the
address of your machine ( IP address of eth0 interface ). Replace it
with IP address of your machine. Do not assume that the IP address
printed on the front cover of your machine is correct. Confirm it with
the following command.
# ifconfig eth0
DNS - Domain Name System is a global distributed hierarchical database
and it is used by TCP/IP applications to convert hostnames to
IP address and IP address to hostnames. DNS also provides other
information such as e-mail routing information.
This experiment is to be done with [BIND9] program, with some related
softwares. Full implementation of [BIND9] is not to be used. Moreover
some Debian Linux specific features would also be skipped.
Complete Assignment-1.
The [/etc/hosts] file is also used to map hostnames to IP address, but
the scope is limited due to number of hosts in the INTERNET. As this
experiment is on DNS configuration, [ /etc/hosts ] file is not to be
used to convert hostname to IP address. To do this, you have to modify
one line in the file [ /etc/nsswitch.conf ]. This file specify in what
order some system databases are looked up.
Complete Assignment-2.
The registered domain name of CEMK is [ cemk.ac.in ]. To carry out lab
experiment on DNS, another domain name is to be used, to prevent any
possible network accident. The domain name [ netlab.cse.cemk ] is to
be used for this experiment. The FQDN ( Fully Qualified Domain Name )
of your host is to be changed in the next assignment.
Complete Assignment-3.
Resolver: Applications must convert a name to IP address for a network
connection. IP headers carry only IP address, not hostname.
Applications access the resolver, mainly via two C-library
functions [gethostbyname(3)] and [gethostbyaddr(3)], to map
hostname to IP address and IP address to hostname. The DNS
is accessed by [resolver].
The configuration file of the [ resolver ] is to be modified for this
experiment.
You may read [resolver(5)].
Note: use [ $ man 5 resolver ]
Complete Assignment-4.
BIND9 needs a configuration file [ named.conf ]. The configuration
file in turn, defines some zone files. By default, the configuration
file is placed under [ /etc/bind/ ] directory. The zone files are
usually also placed under [/etc/bind/] directory. The existing files
are to be saved and new files are to be created by you.
Complete Assignment-5.
--------------------------
Assignment-1:
Check status of [bind9]
$ dpkg --status bind9
If it is installed, you need not reinstall it. However if it is not
installed, install it using following steps.
Bring the file [ bind9_9.2.1-2.woody.1_i386.deb ] in [ DNS ] directory
and install
# dpkg -i bind9_9.2.1-2.woody.1_i386.deb
Note: The location of this file in the CD set
/pool/main/b/bind9/bind9_9.2.1-2.woody.1_i386.deb in CD-1
However if the needed library functions are not installed, the above
method of installation would fail. In such cases use [ dselect ] for
installation.
Use the following command to check correct operation of [ telnetd ]
$ dpkg --status telnetd
Install [telnetd] if needed
# dpkg -i telnetd_0.17-18_i386.deb
(File - /pool/main/n/netkit-telnet/telnetd_0.17-18_i386.deb in CD-1)
Assignment-2:
Edit [/etc/nsswitch.conf] to hash an existing line and to
replace it with another line. Do NOT modify other lines
#................ /etc/nsswitch.conf ..................
#hosts: files dns # original line
hosts: dns[NOTFOUND=return] # added by you
.
.
.
#............. end of /etc/nsswitch.conf ..............
The directive of the original line ( now hashed by you ):
Hostnames are
to be mapped into IP addresses, first by consulting [/etc/hosts] file.
If the desired entry is not found there, DNS is to be consulted.
The directive of the line added by you:
Only DNS should be consulted
to map between hostnames and IP addresses.
In your free time read manuals [hosts(5)] and [nsswitch.conf(5)].
Assignment-3:
Record the output of the following command
$ uname -a
Edit [/etc/hostname] file
# nano /etc/hostname
#...... /etc/hostname .....
#pc-10.cemk.ac.in
pc-10.netlab.cse.cemk
#.. end of /etc/hostname ..
Replace [pc-10] with the hostname of your PC
Execute the following command to update the change made by you
# /etc/init.d/hostname.sh
Record the output of the following command
$ uname -a
Assignment-4:
Edit [/etc/resolv.conf] as under
#................. /etc/resolv.conf ...................
nameserver 172.16.2.10
# Replace above address with IP address of your machine
#nameserver 210.212.4.3 # CEMK name server
#nameserver 172.16.2.xx # name server of your friend
#search cemk.ac.in
search netlab.cse.cemk
#.............. end of /etc/resolv.conf ...............
search directive: When a short name, such as [ pc-1 ] is queried
[netlab.cse.cemk] is appended to it, to make it
[pc-1.netlab.cse.cemk]
nameserver directive: Resolver looks for a name server running at the
specified address.
Comment out all lines of [ /etc/host.conf ] by putting hash [#] before
each line as shown below
#..... /etc/host.conf .....
#order hosts,bind
#multi on
#.. end of /etc/host.conf..
You are not going to use this file for this experiment
Assignment-5:
Copy the existing directory of BIND9 configuration files
# cp -r /etc/bind/ /etc/bind-save-you-date
Replace [you] with your username and [date] with today's date
Check with
# ls -l /etc/ | grep bind
Remove all files under [/etc/bind/] directory.
# rm -ri /etc/bind/
Create directory if it is removed by above command
# mkdir /etc/bind/
Creation of the main configuration file [ /etc/bind/named.conf ]:
To avoid typing errors, do not try to type the contents of the file.
Include the file [ dns.txt ] in your editor and keep only the relevant
portion. You may use the following procedure.
Become [root]
you $ su
Password:
# nano /etc/bind/named.conf
Include a file in the editor by pressing [ CTRL-R ]
Prompt -> File to insert [from ./] : /home/you/DNS/dns.txt
Keep [CTRL-K] pressed to delete multiple lines. Keep only the required
portion and save.
//....................... /etc/bind/named.conf ......................
// This is the primary configuration file for the BIND
acl "lab-net" { 172.16.2.0/24; }; // access control list
options {
directory "/etc/bind";
pid-file "/etc/bind/you-pid";
// do not uncomment the following three lines now
// forwarders {
// 210.212.4.3;
// };
auth-nxdomain no; # conform to RFC1035
// allow-query { any; }; # this is default
allow-query { "lab-net"; 127.0.0.0/8 };
allow-query { "lab-net"; 127.0.0.0/8; };
};
// Tell the name server, the IP addresses of root name servers of the
// world
zone "." {
type hint;
file "/etc/bind/root.hint";
};
// Be authoritative for the localhost forward zone
zone "localhost" {
type master;
file "/etc/bind/local";
notify no;
};
// Be authoritative for the localhost reverse zone
zone "0.0.127.in-addr.arpa" {
type master;
file "/etc/bind/local.rev";
notify no;
};
// Be authoritative for the [ netlab.cse.cemk. ] domain forward zone
zone "netlab.cse.cemk" {
type master;
file "/etc/bind/netlab.cse.cemk.db";
notify no;
};
// Be authoritative for the [netlab.cse.cemk.] domain reverse zone
zone "2.168.192.in-addr.arpa" {
type master;
file "/etc/bind/172.16.2";
notify no;
};
//.................. end of /etc/bind/named.conf ...................
Replace [ you ] in the above file, with your login name. Check the
syntax of the above configuration file with
# named-checkconf /etc/bind/named.conf
There are two lines starting with [allow-query]. One of them is wrong.
Comment out the incorrect entry. Check again.
The different zone files mentioned in the above configuration file
are edited one by one.
Note: The comment character is semicolon [ ; ] in the zone files
;.................... /etc/bind/root.hint ......................
; These are the root servers of the world
; This file holds the information on root name servers needed to
; initialise cache of Internet domain name servers
;
; This file is made available by InterNIC registration services
; under anonymous FTP as
; file /domain/named.root
; on server FTP.RS.INTERNIC.NET
; file named.root
;
; last update: Aug 22, 1997
; related version of root zone: 1997082200
;
;
; formerly NS.INTERNIC.NET
;
. 3600000 IN NS A.ROOT-SERVERS.NET.
A.ROOT-SERVERS.NET. 3600000 A 198.41.0.4
;
; formerly NS1.ISI.EDU
;
. 3600000 NS B.ROOT-SERVERS.NET.
B.ROOT-SERVERS.NET. 3600000 A 128.9.0.107
;
; formerly C.PSI.NET
;
. 3600000 NS C.ROOT-SERVERS.NET.
C.ROOT-SERVERS.NET. 3600000 A 192.33.4.12
;
; formerly TERP.UMD.EDU
;
. 3600000 NS D.ROOT-SERVERS.NET.
D.ROOT-SERVERS.NET. 3600000 A 128.8.10.90
;
; formerly NS.NASA.GOV
;
. 3600000 NS E.ROOT-SERVERS.NET.
E.ROOT-SERVERS.NET. 3600000 A 192.203.230.10
;
; formerly NS.ISC.ORG
;
. 3600000 NS F.ROOT-SERVERS.NET.
F.ROOT-SERVERS.NET. 3600000 A 192.5.5.241
;
; formerly NS.NIC.DDN.MIL
;
. 3600000 NS G.ROOT-SERVERS.NET.
G.ROOT-SERVERS.NET. 3600000 A 192.112.36.4
;
; formerly AOS.ARL.ARMY.MIL
;
. 3600000 NS H.ROOT-SERVERS.NET.
H.ROOT-SERVERS.NET. 3600000 A 128.63.2.53
;
; formerly NIC.NORDU.NET
;
. 3600000 NS I.ROOT-SERVERS.NET.
I.ROOT-SERVERS.NET. 3600000 A 192.36.148.17
;
; temporarily housed at NSI (InterNIC)
;
. 3600000 NS J.ROOT-SERVERS.NET.
J.ROOT-SERVERS.NET. 3600000 A 198.41.0.10
;
; housed in LINX, operated by RIPE NCC
;
. 3600000 NS K.ROOT-SERVERS.NET.
K.ROOT-SERVERS.NET. 3600000 A 193.0.14.129
;
; temporarily housed at ISI (IANA)
;
. 3600000 NS L.ROOT-SERVERS.NET.
L.ROOT-SERVERS.NET. 3600000 A 198.32.64.12
;
; housed in Japan, operated by WIDE
;
. 3600000 NS M.ROOT-SERVERS.NET.
M.ROOT-SERVERS.NET. 3600000 A 202.12.27.33
; End of File
;................ end of /etc/bind/root.hint ...................
Check the syntax of the above zone file
# named-checkzone -d . /etc/bind/root.hint
This zone file has no NS or SOA resource records.
;.................... /etc/bind/local ......................
;
; BIND data file for local loopback interface
;
$TTL 604800
@ IN SOA localhost. root.localhost. (
1 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS localhost.
@ IN A 127.0.0.1
;................ end of /etc/bind/local ...................
The above zone file is checked with the following command. The
expected output is also shown.
# named-checkzone -d localhost /etc/bind/local
loading "localhost" from "/etc/bind/local" class "IN"
zone localhost/IN: loaded serial 1
OK
;................... /etc/bind/local.rev ...................
; reverse zones file for the 127.0.0 net
$TTL 3D
@ IN SOA netlab.cse.cemk. you.netlab.cse.cemk. (
2 ; Serial
28800 ; Refresh
7200 ; Retry
604800 ; Expire
86400) ; Minimum TTL
NS parichayak.netlab.cse.cemk.
1 PTR localhost.
100 PTR localhost. ; not needed, for testing only
;
; This file has three types of resource records (RR)
; SOA Start Of Authority RR
; NS Name Server RR
; PTR Domain Name Pointer RR
; The following line means that the host at address 1 in the network
; 0.0.127.in-addr.arpa is called localhost.
;1 PTR localhost.
;...................end of /etc/bind/local.rev ......................
# named-checkzone -d netlab.cse.cemk. /etc/bind/local.rev
loading "netlab.cse.cemk." from "/etc/bind/local.rev" class "IN"
zone netlab.cse.cemk/IN: loaded serial 2
OK
;.................. /etc/bind/netlab.cse.cemk.db ....................
; Authoritative data for netlab.cse.cemk
$TTL 3D
@ SOA netlab.cse.cemk. you.netlab.cse.cemk. (
200402206 ; serial, todays date + todays serial
8H ; refresh, seconds
2H ; retry, seconds
4W ; expire, seconds
1D ) ; minimum, seconds
IN NS parichayak
MX 10 mail ; Primary Mail Exchanger
parichayak A 172.16.2.10
localhost A 127.0.0.1
www CNAME mail
; www is another name of mail. In your
; Lab. www server is on mail server.
mail A 210.212.4.3
pc-01 IN A 172.16.2.1
pc-02 IN A 172.16.2.2
pc-03 IN A 172.16.2.3
pc-04 IN A 172.16.2.4
pc-05 IN A 172.16.2.5
pc-06 IN A 172.16.2.6
pc-07 IN A 172.16.2.7
pc-08 IN A 172.16.2.8
pc-09 IN A 172.16.2.9
pc-10 IN A 172.16.2.10
pc-11 IN A 172.16.2.11
pc-12 IN A 172.16.2.12
pc-13 IN A 172.16.2.13
pc-14 IN A 172.16.2.14
pc-15 IN A 172.16.2.15
pc-16 IN A 172.16.2.16
pc-17 IN A 172.16.2.17
pc-18 IN A 172.16.2.18
pc-19 IN A 172.16.2.19
pc-20 IN A 172.16.2.20
pc-21 IN A 172.16.2.21
pc-22 IN A 172.16.2.22
cemkftp IN A 172.16.1.50
;................ end of /etc/bind/netlab.cse.cemk.db ...............
The above zone file is checked with the following command. Expected
output is also shown.
# named-checkzone -d netlab.cse.cemk. /etc/bind/netlab.cse.cemk.db
loading "netlab.cse.cemk." from "/etc/bind/netlab.cse.cemk.db" class
"IN" zone netlab.cse.cemk/IN: loaded serial 200402206
OK
;................. /etc/bind/172.16.2 ..............................
; Reverse zone for 172.16.2.0 subnet
$TTL 3D
@ IN SOA netlab.cse.cemk. you.netlab.cse.cemk. (
200402152 ; Serial, todays date + todays serial
8H ; Refresh
2H ; Retry
4W ; Expire
1D) ; Minimum TTL
NS parichayak.netlab.cse.cemk.
1 PTR pc-01.netlab.cse.cemk.
2 PTR pc-02.netlab.cse.cemk.
3 PTR pc-03.netlab.cse.cemk.
4 PTR pc-04.netlab.cse.cemk.
5 PTR pc-05.netlab.cse.cemk.
6 PTR pc-06.netlab.cse.cemk.
7 PTR pc-07.netlab.cse.cemk.
8 PTR pc-08.netlab.cse.cemk.
9 PTR pc-09.netlab.cse.cemk.
10 PTR pc-10.netlab.cse.cemk.
11 PTR pc-11.netlab.cse.cemk.
12 PTR pc-12.netlab.cse.cemk.
13 PTR pc-13.netlab.cse.cemk.
14 PTR pc-14.netlab.cse.cemk.
15 PTR pc-15.netlab.cse.cemk.
16 PTR pc-16.netlab.cse.cemk.
17 PTR pc-17.netlab.cse.cemk.
18 PTR pc-18.netlab.cse.cemk.
19 PTR pc-19.netlab.cse.cemk.
20 PTR pc-20.netlab.cse.cemk.
21 PTR pc-21.netlab.cse.cemk.
22 PTR pc-22.netlab.cse.cemk.
;............. end of /etc/bind/172.16.2 .........................
The above zone file is checked with the following command. The
expected output is also shown.
# named-checkzone -d 2.16.172.in-addr.arpa ./172.16.2
loading "2.16.172.in-addr.arpa" from "./172.16.2" class "IN"
zone 2.16.172.in-addr.arpa/IN: loaded serial 200402152
OK
Stop Light weight resolver daemon [ lwresd ] with
# /etc/init.d/lwresd stop
Try to stop named with
# /etc/init.d/bind9 stop
If it fails to stop, due to absence of some file/files, kill the
[named] with smallest PID.
Start [ named ] with
# /usr/sbin/named -d0
Note: -d0 is dee-zero not dee-oh
See the PID of the first [named]
# cat /etc/bind/you-pid
Check with [ ps -ax ]
The debug file [ ./named.run ] is not created with dee-zero option.
During initial stages of configuration -d2 or so can be used.
Kill [named]. Run it with
# /usr/sbin/named -d10
>From the [/etc/bind/named.run] find out
[named] listening on IPv4 interface lo --> (IP address#port)
[named] listening on IPv4 interface eth0 --> (IP address#port)
zone 0.0.127.in-addr.arpa/IN: number of nodes in database ->
zone 2.16.172.in-addr.arpa/IN: number of nodes in database ->
zone netlab.cse.cemk/IN: number of nodes in database -------->
For a correctly configured [ named ] the following commands should run
with the typical output.
$ host pc-1
pc-1.netlab.cse.cemk has address 172.16.2.1
You should also try verbose output
$ host -v pc-1
$ host parichayak
parichayak.netlab.cse.cemk has address 172.16.2.10
$ host cemkftp
cemkftp.netlab.cse.cemk is an alias for pc-6.netlab.cse.cemk.
pc-6.netlab.cse.cemk has address 172.16.2.6
$ host mail
mail.netlab.cse.cemk has address 210.212.4.3
$ host www
www.netlab.cse.cemk is an alias for mail.netlab.cse.cemk.
mail.netlab.cse.cemk has address 210.212.4.3
The output of the following command is not shown
$ host -a pc-1 parichayak
pc-1 is looked up in name server parichayak
The output of the following command is not shown
$ host -a pc-1 172.16.2.12
pc-1 is looked up in name server running at 172.16.2.12
Address to name look-up.
$ host 127.0.0.1
1.0.0.127.in-addr.arpa domain name pointer localhost.
$ host 172.16.2.5
5.2.16.172.in-addr.arpa domain name pointer pc-5.netlab.cse.cemk.
List all hosts in the domain
$ host -l netlab.cse.cemk
See Optional Assignment-1. ( Full zone transfer - type AXFR)
Also try [ $ host -lv netlab.cse.cemk]
Some commands and their typical output are given below
$ host -t MX netlab.cse.cemk
netlab.cse.cemk mail is handled by 10 mail.netlab.cse.cemk.
$ host -t NS netlab.cse.cemk
netlab.cse.cemk name server parichayak.netlab.cse.cemk.
$ host -t SOA netlab.cse.cemk
netlab.cse.cemk SOA netlab.cse.cemk. you.netlab.cse.cemk. 200402206
28800 7200 2419200 86400
$ host -t CNAME www.netlab.cse.cemk
www.netlab.cse.cemk is an alias for mail.netlab.cse.cemk.
Edit [/etc/resolv.conf] to use name server of your friend's PC.
Test your friend's name server.
Note: [dig] is a better tool to check configuration of a name server.
You may read manual of [ dig ]. [dig] can be used to query a specific
name server, such as
$ dig www.netlab.cse.cemk @172.16.2.18
Some simple [dig] commands are
$ dig pc-2.cemk.ac.in
$ dig any cemk.ac.in
$ dig www.cemk.ac.in
$ dig -x 172.16.2.21
-----------------------
Optional Assignment-1:
Sniff loopback interface
# tethereal -i lo -w xxx
>From another terminal do full zone transfer
$ host -lv netlab.cse.cemk
Go back to [ tethereal ] terminal, exit [ tethereal ] and prepare the
result.
# tethereal -V -r xxx > yyy
# nano yyy
How many packets were captured ? -->
( UDP / TCP ) protocol was used for DNS query and answer.
Strike out the wrong protocol.
Optional Assignment-2:
Activate forwarder in [/etc/bind/named.conf]
Kill [named] and restart it.
Use the following command in two different terminals
$ host web11101.mail.yahoo.com
Were the answers slightly different ?
Optional Assignment-3:
Download the root name servers and save it in
[DNS] directory of your account.
Feedback: Please point out mistakes/corrections and suggest which
portions should be removed, added, expanded etc etc.....bkc
------------------------- end of file dns.txt ------------------------
DNS Configuration
