<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Admin&#039;s Choice &#187; Domain Name Service</title>
	<atom:link href="http://adminschoice.com/tag/domain-name-service/feed" rel="self" type="application/rss+xml" />
	<link>http://adminschoice.com</link>
	<description>Unix adminstrators documents , tip and more</description>
	<lastBuildDate>Fri, 03 Jun 2011 17:27:12 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Domain Name Service</title>
		<link>http://adminschoice.com/domain-name-service</link>
		<comments>http://adminschoice.com/domain-name-service#comments</comments>
		<pubDate>Mon, 21 Dec 2009 06:20:36 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[DNS]]></category>
		<category><![CDATA[Domain Name Service]]></category>

		<guid isPermaLink="false">http://adminschoice.com/wp28/?p=139</guid>
		<description><![CDATA[The following article describes in simple step the how to setup a DNS server. Though the article focus on Solaris but any operating system which uses BIND the procedure will remain the same.]]></description>
			<content:encoded><![CDATA[<p><strong>DNS Server Setup &#038; Configuration in Unix </strong></p>
<p>Domain name services resolves  names  to the ip addresses of clients and vice verse. Domain name system provides a convenient way of finding computer systems in network based on  its name and ip address . With increased internet usage and globalization of  companies setting up of DNS servers has become a major responsibility of system administrators worldwide . </p>
<p>The following article describes in simple step the how to setup a DNS server. Though the article focus on Solaris but any operating system which uses BIND the procedure will remain the same.<br />
<strong>Contents  </strong><br />
1.0 Introduction to dns<br />
2.0 Requirements for setting up dns server<br />
3.0 DNS server Installation<br />
4.0 named.conf file in dns server configuration<br />
4.1 options statement in dns server configuration<br />
4.2 Zone in dns server configuration<br />
4.3 Logging in dns server<br />
5.0 Zone File in dns server<br />
6.0 Dns Client configuration<br />
7.0 Signals in dns server process &#8211; named </p>
<p><strong>1.0 Introduction</strong><br />
Domain name system is a  hierarchical   system  where we have a top level domain serving sub domain and clients with names &#038; ip address.</p>
<p>The system that runs the name services to resolve names into ip addresses is called name server and the software  is generally BIND (Berkley Internet Domain)  .</p>
<p>Core process of DNS is a daemon called named . Depending on the role assigned the name servers can be a primary, secondary, caching or forwarding only. Secondary server takes over when primary is down and is updated automatically. Caching server provide only the caching information  to the clients and forwarding dns simply forwards the requests to another dns.</p>
<p>DNS Forwarding is can be used for  two main scenario<br />
<strong>1. Creating a large site wide cache</strong> on different servers thereby  using less network bandwidth.<br />
<strong>2. For servers which do not have a direct access to the internet</strong>  but have to lookup for the external names.<br />
Forwarding occurs only for names for which the server is not authoritative, and it does not have the answer in its cache.</p>
<p>Each of domain or sub domain have information (in zone files or data files)  about its clients   and  is  called authoritative for these clients . For other clients for which it doesn&#8217;t have any information or it is not   authoritative,  it passes query to its higher domain .</p>
<p>The client knows about their name servers through a file called resolve.conf  which contains addresses of   the name servers (Primary secondary and Caching) along with their domain name.</p>
<p>The main files in serve are named.conf  which contains  server parameters and reference to other data files containing client information.</p>
<p><strong>2.0 Requirements</strong></p>
<p><strong>1)  BIND (Berkely Internet Domain)  software</strong>.<br />
 Source code can be downloaded and compiled for your platform from internet at <a href="https://www.isc.org/downloadables/11"> isc.org/downloadables</a>  However BIND may be available in pre compiled version along with OS so check your OS if it is already there . The situation you may want to compile from source code is that you want to customize it differently by giving different configuration options at compiling time</p>
<p>2)  <strong>Root cache file</strong> from internic  at ftp://internic.com/pub/root</p>
<p>3)<strong> C Compiler</strong>  to compile the bind source  distribution .</p>
<p><strong>3.0 Installation and configuration</strong><br />
Download the BIND software from from www.isc.org if you want to build it from source code.<br />
Make a directory to store and compile dns distribution source say  /usr/dns/src </p>
<p>Unzip the distribution  using gzip  command</p>
<p>#gzip -d bind-9.2.5.tar.gz<br />
unpack using tar<br />
#tar  xvf   bind-9.2.5.tar<br />
compilation require a c compiler if you don&#8217;t have one you can download from gnu site (www.gnu.org).<br />
#./configure<br />
#make<br />
#make install<br />
make install   will ultimately place named , configuration file  named.conf  and related commands in  /etc and   /usr/local/bin directory .</p>
<p><strong>4.0 named.conf file</strong><br />
This is the main configuration file in BIND  which defines the name servers  and zones with the name and ip address of the hosts.</p>
<p>The named.conf has a number of options for starting the name server which can be configured as per requirement. A list of  complete options can be seen using  man named command.</p>
<p>By default you will find zone files for local host   by the name localhost and  127.0.0.in-addr.arpa . For additional zones you need to create the   the files and put a reference in  named.conf  .</p>
<p>Below is a basic functional named.conf file which is installed after the BIND 8..2.P5 is installed This can be used   for starting name server , all you  need to do is to put your hosts entries in the zone files  referenced here .You will  find explanation of terms used in this  configuration file  after this listing of named.conf.  </p>
<p>// This is a configuration file for named (from BIND 8.1 or later).<br />
// It would normally be installed as /etc/named.conf.</p>
<p>options { directory &#8220;/var/named&#8221;;<br />
    check-names master warn; /* default. */<br />
    datasize 20M;<br />
    deallocate-on-exit yes;<br />
    listen-on {10.20.30.100;<br />
              };<br />
    forward first;<br />
       };<br />
zone &#8220;localhost&#8221; IN {<br />
    type master;<br />
    file &#8220;/var/named/localhost.zone&#8221;;<br />
    check-names fail;<br />
    allow-update { none; };<br />
    allow-transfer { any; };<br />
    };<br />
zone &#8220;0.0.127.in-addr.arpa&#8221; IN {<br />
    type master;<br />
    file &#8220;/var/named/127.0.0.zone&#8221;;<br />
    check-names fail;<br />
    allow-update { none; };<br />
    allow-transfer { any; };<br />
    };<br />
zone &#8220;.&#8221; IN {<br />
    type hint;<br />
    file &#8220;/var/named/root.hint&#8221;;<br />
    };<br />
logging {<br />
    channel xfer-log {<br />
    file &#8220;/var/tmp/bind-xfer.log&#8221; versions unlimited size 10m;<br />
    print-category yes;<br />
    print-severity yes;<br />
    print-time yes;<br />
    severity info;<br />
     };<br />
    category xfer-in { xfer-log; };<br />
    category xfer-out { xfer-log; };<br />
    category notify { xfer-log; }</p>
<p>category load { xfer-log; };<br />
    };<br />
zone &#8220;30.20.10.in-addr.arpa&#8221; IN {<br />
    type master;<br />
    file &#8220;/var/named/100.30.20.10.zone&#8221;;<br />
    check-names fail;<br />
    allow-update { none; };<br />
    allow-transfer { any; };<br />
    };<br />
zone &#8220;mydomain.com&#8221; {<br />
    type master;<br />
    file &#8220;/var/named/mydomain.com.hosts&#8221;;<br />
    };</p>
<p>Explanation of the terms used in named.conf above</p>
<p><strong>4.1 options statement</strong><br />
 The options lists working directory for the named &#8211; the name server daemon to read the configurations files and port to listen on (default is port 53)  .</p>
<p><em>{ directory &#8220;/var/named&#8221;;</em></p>
<p>This directive defines the working directory of the name server where main configuration file named.conf will be located  </p>
<p><em>check-names master warn; /* default. */</em></p>
<p>The &#8220;check-names&#8221; directive tells BIND to check names in master zone  and give a warning   in system&#8217;s  log files if there is any discrepancy. Names are considered good if they match RFC 952&#8217;s expectations (if they are host names), or if they consist only of printable ASCII characters (if they are not host names).</p>
<p>Other options are fail and ignore in that case bind will follow these directives</p>
<p><em>datasize 20M;</em></p>
<p>datasize The maximum amount of data memory the server may<br />
use. The default is system dependent.</p>
<p><em>deallocate-on-exit yes;</em></p>
<p>deallocate the memory on exit  otherwise it will be left to os to clear the memory.</p>
<p><em>listen-on {10.20.30.100}; </em></p>
<p>Host address and port for listening ; if port is not mentioned it is default 53.</p>
<p><em>forward first</em></p>
<p><em>forward</em><br />
This option specify where to query the name first   &#8211; &#8216;first&#8217;  directive  will cause query to send to  forwarder  first  and check itself if it fails .&#8217;Only&#8217;  &#8211; directive will query the forwarders only .<br />
forwarders<br />
Specifies the IP addresses to be used for forwarding. The default is no forwarding.</p>
<p><strong>4.2 Zones  statements</strong></p>
<p>zone &#8220;localhost&#8221; IN {<br />
    type master;<br />
    file &#8220;/var/named/localhost.zone&#8221;;<br />
    check-names fail;<br />
    allow-update { none; };<br />
    allow-transfer { any; };<br />
    };</p>
<p> Zone  statement    declares  a   zone name ,  its type  &#8211; master , slave  or  stub, files  containing the zone  data and options relating to zone &#8211; update , checking , transfer etc.</p>
<p>localhost  and  0.0.127.in-addr.arpa  are default for the localhost and points to file of this name </p>
<p><strong>Zone types   </strong></p>
<p>There are three types of zone  .</p>
<p><strong>Master </strong><br />
This is the  master copy of the data in a zone.<br />
<strong>Slave </strong><br />
This is a replica of a master zone. The masters list specifies one or more IP addresses that the slave contacts to update its copy of the zone. If file is specified then the replica will be written to the file. Use of file is recommended, since it often speeds server start up and eliminates a needless waste of bandwidth.</p>
<p><strong>stub</strong><br />
A stub zone is like a slave zone, except that it replicates only the NS records of a master zone instead of the entire zone.</p>
<p><strong>Hint</strong><br />
The initial set of root name servers is specified  using a hint zone. When the server starts up, it uses the root hints to find a root name server and get the most recent list of root name servers.<br />
previous releases of BIND used the term primary for a master zone, secondary for a slave zone, and cache for a hint zone.</p>
<p><strong>Zone  Directives</strong><br />
allow-update<br />
Specifies which hosts are allowed to submit dynamic DNS updates to the server. The default is to deny updates from all hosts.<br />
allow-transfer<br />
Specifies which hosts are allowed to receive zone transfers from the server. allow-transfer may also be specified in the zone section, in which case it overrides the options allow-transfer statement. If not specified, the default is to allow transfers from all hosts.</p>
<p>zone &#8220;.&#8221;  refers to the root file for the domains &#8211; and contains references to the root servers at network solutions to resolve the names which are beyond the current domain . you can download  the root cache file from ftp://internic.com/pub/root</p>
<p><strong>4.3 Logging statement</strong></p>
<p><code>logging {<br />
    channel xfer-log {<br />
    file "/var/tmp/bind-xfer.log" versions unlimited size 10m;<br />
    print-category yes;<br />
    print-severity yes;<br />
    print-time yes;<br />
    severity info;<br />
     };</code></p>
<p>The logging statement specifies  logging channel/s  which logs various categories of messages. In statement above a channel xfer-log &#8211; a user defined name , is defined. Each time name server is started it starts writing to the defined log file , size limits the maximum size of log file and once the limit is reached it stops writing the file. Each   individual start or restart of named causes a new version of log file to be created. Version statement defines how many  versions are allowed for the log file , unlimited option will allow any number of version, </p>
<p>Only one logging statement is used to  define as many channels and categories as are wanted. If there are multiple logging statements in a configuration, the first   definition  determines the logging  and  warnings are issued for the other logging statements . </p>
<p>If there is no logging statement, the default logging configuration is used which is</p>
<p>logging {<br />
category default { default syslog; default_debug;};<br />
category panic  { default syslog; default_stderr;};<br />
category packet { default_debug;};<br />
category eventlib { default_debug;};<br />
};</p>
<p>The default debug file is named.run .</p>
<p><strong>Channel Phrase</strong></p>
<p>All log output goes to one or more &#8220;channels&#8221;; you can make as many of them as you want. Every channel definition must include a clause that says whether messages selected for the channel go to a file, to a particular syslog facility, or are discarded. It can optionally also limit the message severity level that will be accepted by the channel (default is &#8220;info&#8221;), and whether to include a named-generated time stamp, the category name and/or severity level (default is not to include any). </p>
<p>The word null as the destination option for the channel will  cause all messages sent to it to be discarded; other options for the channel are meaningless.</p>
<p>The file clause defines size and versions of the file  which will be  saved each time the file is opened. if the  file ever exceeds the size, then named will just not write anything more to it . The default behavior is to not limit the size of  the file.</p>
<p>As per selection the log messages will either  go to  syslog() or a file and severity level determines which type of  messages goes there . Default severity level is  info. and it can be critical , error , debug and dynamic.</p>
<p>Note that only syslog messages can go to syslog  . </p>
<p>Print-time  , print-category  &#8211;  logs  the time &#038;  category of the messages . The print- options can be  used in any combination but  will always be printed in the following order: time, category, severity. </p>
<p>category xfer-in { xfer-log; };<br />
category xfer-out { xfer-log; };<br />
category notify { xfer-log; }</p>
<p>These directives put diffrent categories  of log messages in to xfer-log channel  </p>
<p>Category option mentions the category of the log and file name for logging</p>
<p>logging {<br />
    channel xfer-log {<br />
    file &#8220;/var/tmp/bind-xfer.log&#8221; versions unlimited size 10m;<br />
    print-category yes;<br />
    print-severity yes;<br />
    print-time yes;<br />
    severity info;<br />
     };</p>
<p>this defines a channel called xfer-log with various options.    </p>
<p>these categories directs  various types of logs into the channel     </p>
<p><strong>5.0 ZONE files</strong></p>
<p>Zone files are used to define the name and ip addresses of the  hosts in a domain .Generally two  zone files are defined for a  particular  zone  &#8211; one file maps  the the name to  the ipaddress of the host  machines and other is used for reverse lookup i.e. ipaddress to name .address   .</p>
<p>Each master zone file should begin with an SOA  (Start of Authority)   record for<br />
the zone. The SOA specifies a serial number, which should be changed<br />
each time the master file is changed. it is 32 bit size field . Slave  servers check the serial no. at refresh time and if the detect changed serial no  in master zone transfer  is carried out to keep its zone files updated.</p>
<p>If a master server cannot be contacted within the interval given by the expire time, all data from the zone is discarded by slave servers.<br />
The minimum value is the time-to-live (&#8220;TTL&#8221;) used by records in the file with no explicit time-to-live value.</p>
<p> The details of all   type of records used in a zone file are given below  </p>
<p><strong>Type of records</strong><br />
<strong>SOA</strong>     marks the start of a zone of authority (domain of  originating host, domain address of maintainer, a serial number and the following parameters in  seconds: refresh, retry, expire and minimum TTL. (see RFC 883)).<br />
<strong>NULL    </strong>a null resource record (no format or data)<br />
<strong>RP      </strong>a Responsible Person for some domain name<br />
<strong>PTR     </strong>a domain name pointer (domain)<br />
<strong>HINFO   </strong>host information (cpu_type OS_type)<br />
<strong>A</strong>       a host address (dotted quad)<br />
<strong>NS      </strong>an authoritative name server (domain)<br />
<strong>MX      </strong>a mail exchanger (domain), preceded by a preference value (0..32767), with lower numeric values  representing higher logical preferences.<br />
<strong>CNAME  </strong>the canonical name for an alias (domain)</p>
<p>Following are the three functional zone files representing local host  and a master  zone. </p>
<p>The explanation of the terms are at the end. </p>
<p>/var/named/localhost </p>
<p>localhost. 1D IN SOA localhost.mydomainr.com. hostmaster.mydomain.com. (<br />
                42 ; serial<br />
                3H ; refresh<br />
                15M ; retry<br />
                1W ; expiry<br />
                1D ) ; minimum<br />
localhost.         NS         dns<br />
localhost.         A         127.0.0.1</p>
<p>/var/named/ 0.0.127.in-addr.arpa</p>
<p>0.0.127.in-addr.arpa IN SOA localhost. root.localhost. (<br />
                42 ; serial<br />
                3H ; refresh<br />
                15M ; retry<br />
                1W ; expiry<br />
                1D ) ; minimum</p>
<p>0.0.127.in-addr.arpa    IN    NS     dns.mydomain.com<br />
1.0.0.127.in-addr.arpa. PTR          localhost</p>
<p>/var/named/mydomain.com</p>
<p>mydomain.com. IN SOA dns.mydomain.com hostmaster.dns. (<br />
            200010016 ;serial<br />
            10800<br />
            3600<br />
            3600<br />
            86400 )<br />
mydomain.com. 1D IN NS dns.mydomain.com.<br />
                  IN MX 20 mx1.domaingateway.net.<br />
                  IN MX 10 mail-in.mydomain.com.</p>
<p>;mydomain hosts below<br />
<code>www              IN CNAME mydomain.com.<br />
localhost        IN A     127.0.0.1<br />
mail               IN A     xxx.xxx.xxx.xxx<br />
ns1                IN A     xxx.xxx.xxx.xxx<br />
dns                IN A     xxx.xxx.xxx.xxx<br />
news              IN A     xxx.xxx.xxx.xxx</code></p>
<p>root cache file</p>
<p>localhost.         NS         dns</p>
<p>this is declaration of  the  type of localhost  it declares that  local host is a name server with hostname dns </p>
<p>localhost.         A         127.0.0.1</p>
<p>this declares the address of local host.</p>
<p><code>0.0.127.in-addr.arpa         IN    NS     dns.mydomain.com<br />
1.0.0.127.in-addr.arpa.     PTR          localhost</code></p>
<p>Similarly in reverse zone map file reverse address  is declared  as ns record of name  dns and a pointer record ptr  , points this rev address to the localhost.</p>
<p>Resource records normally end at the end of a line, but may be continued across lines between opening and closing parentheses. Comments are introduced by semicolons and continue to the end of the line.Note that there are other resource record types, not shown where. You should consult the BIND Operations Guide (BOG&#8217;) for the complete list. Some resource record types may have been standardized in newer RFC&#8217;s but not yet implemented in this version of BIND.</p>
<p><strong>6.0 Client Configuration</strong></p>
<p>Each client need a configuration file  /etc/resolv.conf  which informs it about the domain name server . This is a editable text file with following entries :</p>
<p><code>domainname  yourdomainname.com<br />
nameserver  10.20.30.40<br />
nameserver   10.20.30.41</code></p>
<p><strong>7.0 Signals</strong><br />
The following signals have the specified effect when sent to the server process named using the kill  command.</p>
<p><strong>SIGHUP </strong><br />
Causes server to read named.boot and reload the database. If the server is built with the FORCED_RELOAD compile-time option, then <strong>SIGHUP </strong>will also cause the server to check the serial number on all secondary zones. Normally the serial numbers<br />
are only checked at the SOA-specified intervals.<br />
<strong>SIGINT </strong>: Dumps the current data base and cache to /var/named/named_dump.db<br />
<strong>SIGIOT</strong>: Dumps statistics data into /var/named/named.stats .if the server is compiled with -DSTATS. Statistics data is appended to the file. Some systems use SIGABRT    rather than SIGIOT for this.<br />
<strong>SIGSYS </strong>: Dumps the profiling data in /var/named if the server is compiled with profiling (server forks, chdirs and exits).<br />
<strong>SIGTERM </strong>- Dumps the primary and secondary database files.<br />
Used to save modified data on shutdown if the<br />
server is compiled with dynamic updating enabled.<br />
<strong>SIGUSR1 </strong>- Turns on debugging; each SIGUSR1 increments debug level. (SIGEMT on older systems without SIGUSR1)<br />
<strong>SIGUSR2 </strong>- Turns off debugging completely. (SIGFPE on older<br />
systems without SIGUSR2)<br />
SIGWINCH &#8211; Toggles logging of all incoming queries via sys-<br />
log(8) (requires server to have been built with the<br />
QRYLOG option)</p>
]]></content:encoded>
			<wfw:commentRss>http://adminschoice.com/domain-name-service/feed</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
	</channel>
</rss>

