荔园在线

荔园之美,在春之萌芽,在夏之绽放,在秋之收获,在冬之沉淀

[回到开始] [上一篇][下一篇]


发信人: Lg (创造人生的传奇), 信区: Linux
标  题: Setting up DNS servers
发信站: BBS 荔园晨风站 (Tue Feb 20 14:25:15 2001), 站内信件

Setting up DNS servers

By Bhavin Patel



The Basics:
The core of domain name system (DNS) is the invention of a hierarchical,
domain-based naming scheme and a distributed database system for implementing
this scheme. This allows local control of segments of the overall database, yet
the data is available across the entire network through a client-server scheme.
This database of domains is maintained by interNIC (Network Information Center)
. Robustness and adequate performance are achieved through replication and
caching.



Program called name server constitutes the server half of DNS's client-server
mechanism. Name servers contain information about some segment of the database
make it available to clients called resolvers. Resolvers are just library
routines that create queries and send them across a network to a name server.



Conceptually, the Internet is divided into several hundred top-level domains
where each domain covers many hosts. The top-level domains come in two flavors:
generic and countries. The generic domains are com(commercial),edu(education),
mil(military),int(international),org(organization) ,net(network providers). The
country domains include one entry for each country.



The whole database is a pictured as an inverted tree with root node at the top.
Each node is a basic top-level domain and each top-level domain has many nodes.
For example the com node may have child nodes as abc and abc may have a child
node bhavin ( a sub domain of abc.com ) and so on. Thus we can say that each
node is also a root of a new sub tree of the overall tree. Thus when we want to
access bhavin we type http://bhavin.abc.com in our browsers.





Need of DNS File:



Originally, all domain name resolution occurred on one computer, which
contained a text file called HOSTS.TXT. However, as time went on, the HOSTS.TXT
file required update after update. The computer containing this file was also
being overrun with name resolution requests.
Managing millions of constantly changing sets of name became a serious problem,
so each domain that is registered now has its own DNS file. Very briefly the
way DNS is used is as follows:



To map a name onto an IP address, an application program calls a library
procedure called the resolver, passing it the name as parameter the resolver
sends a UDP (User Datagram Protocol) packets to a local DNS server, which then
looks up the name and returns the IP address to the resolver, which then
returns it to caller. Armed with IP address the program can establish a TCP
(Transmission Control Protocol) connection with the destination, or send it UDP
packets.





Resource Records (RR):



Each domain, whether it is a single host or a top-level domain, can have a set
of resource records associated with it. For a single host, the most common
record is just its IP address, but many other kinds of resource records also
exist. When a resolver gives a domain name to DNS, what it gets back are
resource records associated with that name. So the real function of DNS is to
map domain names onto the resource records.



The different types of Resource Records and their brief description is as
follows:



Number / Code / Description Function

1.   A     Network Address: Stores the host name and IP address of individual
hosts in the domain.This is the record used to translate host names to IP
addresses.


2.   NS     Authoritative Name Server: Stores information used to identify the
name servers in the domain that store information for that domain.


3.   MD     Mail Destination; Now replaced by MX


4.   MF     Mail Forwarder; Now replaced by MX


5.   CNAME     Canonical Name: Stores additional host names, or aliases, for
hosts in the domain.


6.   SOA     Start Of Authority: Required for every domain. Stores information
about DNS itself for the domain

7.   MB     Mailbox domain name


8.   MG     Mailbox member


9.   MR     Mail Rename Domain


10.   NULL     Null Resource Record


11.   WKS     Well-known service: Stores information about the various network
services available from hosts in the domain.


12.   PTR     Pointer to a domain name: Stores the IP address and host name of
individual hosts in the domain. Used to translate IP addresses into host names.


13.   HINFO     Host Information: Stores information about the hardware for
specific hosts.


14.   MINFO     Mailbox Information


15.   MX     Mail Exchange - Stores information about where mail for the domain
should be delivered.


16.   TXT     Text string: Stores up to 256 characters of text per line.

17.   RP     Responsible person: Stores information about the person
responsible for the domain.


18.   AFSDB     AFS-type services


19.   X.25     X.25 Address


20.   ISDN     ISDN Address


21.   RT     Route through





Configuring a UNIX DNS server:



Configuring a DNS server requires several files and databases to be modified or
created. The process is time-consuming, but luckily has to be done only once
for each server. First I'll assume you already have a copy of the Domain Name
Server software. It is probably called named or in. named depending on your
flavor of Unix. If you intend on using the package called BIND (the Berkeley
Internet Name Domain), then you should be sure that you get version 4.9.x,
which is the most recent version at this point in time. The files involved in
most DNS setups and their and their purpose are as follows:



1) named.hosts: Defines the domain with host name to IP mapping. (Forward
mapping)
2) named.rev: Uses IN-ADDR-ARPA for IP to Hostname mapping. (Reverse mapping)
3) named.local: Used to resolve the loop back driver.
4) named.ca: Lists root domain servers.
5) named. Boot: Used to set file and database locations.



These filenames are used by convention but they cab be changed to suit your own
needs. The primary file in the list is named. Boot, which is read when the
system boots up and defines other files in the set. Therefore, any filename
changes are reflected in named. Boot. Each of the files listed here is a
database with entries in form of a resource record.



Before configuring the files let us assume a domain whose DNS files we will
create; let the domain be abc.com

The Boot File - named. Boot:
(Triggers the loading of DNS daemons)


First step is to create the file named. Boot. This describes to named (we'll
dispense with the in. named. Take them to be the same) where the information
that it requires can be found. This file is normally found in /etc/named. Boot
and leave it there because then you know where to find it. If you don't want to
leave it there but place it in a directory with the rest of your named files,
then there is usually an option on named to specify the location of the boot
file. If named. Boot exists, the DNS daemon named starts.





Your typical boot file will look like this :



; named. boot
directory /usr/lib/named
primary abc.com named.hosts
primary 25.143.in-addr.arpa named.rev
primary 0.0.127.in-addr.arpa named.local
cache . named.ca



The lines in the named.boot file have the following meanings.
directory
This is the path that named will place in front of all file names referenced
from here on. If no directory is specified, it looks for files relative to
/etc.
cache



This is the information that named uses to get started. Named must know the IP
number of some other name servers at least to get started. Information in the
cache is treated differently depending on your version of named. Some versions
of named use the information included in the cache permanently and others
retain but ignore the cache information once up and running. The name cache
information is in named.ca



Take care you get an up-to-date cache-file. An obsolete cache file is a good
source of problems.
primary
The line primary abc.com named.hosts
sets named.hosts as the file for locating the primary server of abc.com.
The IN-ADDR-ARPA information is kept in the file named named.rev for 143.25
subnet. The local host information is in named.local





The named.host File



The named.host file contains the the SOA ,NS, and A resource records. All the
entries in the named.hosts file must begin in the first character position of
each line.
Here's a sample named . hosts file with comments added to show the records:



; named .hosts files
;start of authority RR
abc.com . IN SOA bhavin.abc.com
                root. bhavin.abc.com(
                2 ; Serial number
                7200;Refresh )2 hrs)
                3600 ; Retry (1hr)
               151200 ;Expire (1 week)
               86400 ); min TTL


;
; Name Service RRs
abc.com IN NS bhavin.abc.com
subnet1.abc.com IN NS jack.subnet1.abc.com
;
; Address RRs
sumi IN A 143.23.25.7
bhavin IN A 143.23.25.9
mary IN A 143.23.25.12
jay IN A 143.23.25.23
solly IN A 143.23.25.43
pepper IN A 143.23.25.72


The first section sets the SOA records.
The SOA record is the Start Of Authority record. It contains the information
that other name servers will learn about this domain and how to treat the
information they are given about it. The SOA record has 5 magic numbers. First
magic number is the serial number. If you change the file, change the serial
number. If you don't, no other name servers will update their information. The
old information will sit around for a very long time.



Refresh is the time between refreshing information about the SOA.
 Retry is the frequency of retrying if an authority server cannot be contacted.
Expire is how long a secondary name server will keep information about a zone
without successfully updating it or confirming that the data is up to date.



This is to help the information withstand fairly lengthy downtimes of machines
or connections in the network without having to recollect all the information.
Minimum is the default time to live value handed out by a name server for all
records in a zone without an explicit TTL value.



This is how long the data will live after being handed out.
The two pieces of information before the 5 magic numbers are the machine that
is considered the origin of all of this information. Generally the machine that
is running you're named is a good one for here.



The above example sets the name server for the abc.com domain to bhavin.abc.com
. The second is an email address for someone who can fix any problems that may
occur with the DNS. Good ones here are postmaster, host master or root. NOTE:
You use dots and not '@' for the email address. In the above example if root@
bhavin.abc.com would have been the root or postmaster's email ; in this file it
would be root.bhavin.abc.com



The second section uses NS resources records to define the name server for the
abc.com domain as bhavin.abc.com(the same as the SOA) and a subnet of abc
called subnet1, for which the name server is jack. Subnet1.abc.com



The third section has a list of the address ( A )-record-name -to IP-address
mapping . There is an entry in this section for each machine on the network .
these records are used for actual mapping of hostname to its IP address.



The hostname are not given as fully qualified domain names because servers can
deduce the full name. If you want to use the full domain name, you must follow
the name with a period. The machines shown in preceding example would be given
like this using fully qualified names :


sumi.abc.com. IN A 143.23.25.7
bhavin.abc.com. IN A 143.23.25.9
mary .abc.com. IN A 143.23.25.12
jay.abc.com. IN A 143.23.25.23
solly.abc.com. IN A 143.23.25.43
pepper.abc.com. IN A 143.23.25.72




The named.rev File :



The named.rev file provides the reverse mapping of IP address to machine name
and is composed of pointer resource records. The same format as the named.hosts
file is followed, except for the swapping of name and IP address and conversion
of their address to IN-ADDR-ARPA style.
The equivalent named.rev file for the named.hosts file for the example taken
above looks like this :



; named.rev files
; start of Authority RR
23.143.in-addr.arpa IN SOA bhavin.abc.com
                        root.bhavin.abc.com (
                        2 ; serial number
                        7200 ; refresh ( 2 hrs )
                        3600 ; retry ( 1 hr )
                        151200 ; expire ( 1 week )
                        86400 ) ; min TTL


; Name Service RRs
23.143.in-addr.arpa IN NS bhavin.abc.com
100.23.143.in-addr.arpa IN NS jack.subnet1.abc.com
;
; Address RRs
7.25.23.143.in-addr.arpa IN PTR sumi
9.25.23.143.in-addr.arpa IN PTR bhavin
12.25.23.143.in-addr.arpa IN PTR mary
23.25.23.143.in-addr.arpa IN PTR jay
43.25.23.143.in-addr.arpa IN PTR solly
72.25.23.143.in-addr.arpa IN PTR pepper



There must be a separate named.rev file for each zone or sub domain on the
network. These files can have different names or be placed in different
directories. If you have a single zone only one named.rev file is needed.



The named.local file :
; named.local files
;start of authority RR
abc.com . IN SOA bhavin.abc.com
                root. bhavin.abc.com(
                2 ; Serial number
                7200;Refresh )2 hrs)
                3600 ; Retry (1hr)
               151200 ;Expire (1 week)
               86400 ); min TTL

;
; Name Service RR
0.0.127.in-addr.arpa IN NS bhavin.abc.com
;
; Address RR
1.0.0.127.in-adr.arpa IN PTR local host

This file then provides the mapping from the machine local host to the IP
address 127.0.0.1





The named.ca file :
The named.ca file is used to specify name servers that the system can resort
to. The machines specified in the named.ca file should be stable and absolutely
not subject to rapid change. A sample named.ca file looks like this :

; named.ca
; servers for root domain
;
. 99999999 IN NS ns.internic.net
; servers by address
;
ns.internic.net 99999999 IN A 198.41.0.4
;



Once these files are configured you can say that you have now setup your own
DNS server.
I may not be able to cover the entire details for configuring a DNS sever due
to the vastness of the topic; but if you need any help or have any questions
regarding "Setting a DNS server " feel free to write at bhavin@123ofnet.com .

February 16, 2001


--
☆ 来源:.BBS 荔园晨风站 bbs.szu.edu.cn.[FROM: bbs@210.51.121.39]


[回到开始] [上一篇][下一篇]

荔园在线首页 友情链接:深圳大学 深大招生 荔园晨风BBS S-Term软件 网络书店