📄 505-508.html
字号:
<HTML>
<HEAD>
<TITLE>Special Edition Using Linux, Fourth Edition:Configuring Domain Name Service</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=0789717468//-->
<!--TITLE=Special Edition Using Linux, Fourth Edition//-->
<!--AUTHOR=Jack Tackett//-->
<!--AUTHOR=Jr.//-->
<!--AUTHOR=Steve Burnett//-->
<!--PUBLISHER=Macmillan Computer Publishing//-->
<!--IMPRINT=Que//-->
<!--CHAPTER=25//-->
<!--PAGES=505-508//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="503-505.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="508-510.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<P>The following is a sample /etc/resolv.conf file for <TT>tristar.com:</TT></P>
<!-- CODE SNIP //-->
<PRE>
# /etc/resolv.conf for tristar.com
#
# Set our local domain name
domain tristar.com
# Specify our primary name server
nameserver 166.82.1.3
</PRE>
<!-- END CODE SNIP //-->
<P>In this example, you specify the local domain via the <TT>domain</TT> option and list one name server to use for resolving host names.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>You need to specify the IP address of the DNS name server as an argument to the <TT>nameserver</TT> option—not the host name. If you specify the host name, DNS doesn’t know what host to contact to look up the host name of the name server.<HR></FONT>
</BLOCKQUOTE>
<P>You didn’t use the <TT>search</TT> option to specify the search order. This means that if you try to query the address of a machine—for example, skippy—the resolver tries to look up skippy first. If this fails, it looks up <TT>skippy.tristar.com</TT>, and then <TT>skippy.com</TT>.</P>
<P>DNS servers can and do go down unexpectedly. If you rely solely on a DNS server for name resolution, you may find yourself unable to work if it crashes. Make sure that you specify multiple servers and keep a good list of hosts in your local /etc/hosts file, just in case.</P>
<H3><A NAME="Heading6"></A><FONT COLOR="#000077">Using the <I>named</I> Daemon to Set Up the Server
</FONT></H3>
<P>Here is where the real magic starts. You’ve seen how to set up the basics of resolver configuration and how to tell your resolver which name servers to contact. In the following sections, you learn the mechanics of setting up a name server.
</P>
<P>The DNS name server under Linux is provided by the <TT>named</TT> (pronounced <I>name-deè</I> ) daemon. This daemon is typically started at boot time and reads its configuration information from a set of configuration files. <TT>named</TT> typically runs until the machine is shut down. After <TT>named</TT> starts and is initialized with its configuration information, it writes its process ID to the /etc/named.pid ASCII file. It then starts listening for DNS requests on the default network port specified in /etc/services.</P>
<H4 ALIGN="LEFT"><A NAME="Heading7"></A><FONT COLOR="#000077">The named.boot File</FONT></H4>
<P>The first file that <TT>named</TT> reads when it starts is typically /etc/named.boot. This very small file is the key to all the other configuration files used by <TT>named</TT>—it contains pointers to the various configuration files and to other name servers. In the named.boot file, comments start with a semicolon and continue to the end of the line. Several options can be listed in the named.boot file; Table 25.4 lists these options.</P>
<TABLE WIDTH="100%"><CAPTION ALIGN=LEFT><B>Table 25.4</B> Configuration Options for the named.boot File
<TR>
<TH COLSPAN="2"><HR>
<TR>
<TH WIDTH="25%" ALIGN="LEFT">Option
<TH WIDTH="75%" ALIGN="LEFT">Description
<TR>
<TD COLSPAN="2"><HR>
<TR>
<TD VALIGN="TOP"><TT>directory</TT>
<TD>Specifies the directory where the DNS zone files are located. You can specify several different directories by using the <TT>directory</TT> option repeatedly. You can give file path names as being relative to these directories.
<TR>
<TD VALIGN="TOP"><TT>primary</TT>
<TD>Takes a domain name and file name as arguments. The <TT>primary</TT> option declares <TT>named</TT> to be authoritative for the specified domain and causes <TT>named</TT> to load the zone information from the specified file.
<TR>
<TD VALIGN="TOP"><TT>secondary</TT>
<TD>Tells <TT>named</TT> to act as a secondary server for the specified domain. It takes a domain name, a list of addresses, and a file name as arguments. <TT>named</TT> tries to transfer the zone information from the hosts specified in the address list and then stores the zone information in the file specified on the option line. If <TT>named</TT> can’t contact any of the hosts, it tries to retrieve the information from the secondary zone file.
<TR>
<TD VALIGN="TOP"><TT>cache</TT>
<TD>Sets up caching information for <TT>named</TT>. Takes a domain name and a file name as arguments. The domain name is typically specified as <TT>.</TT> (dot). The file contains a set of records, known as <I>server hints</I>, which list information about the root name servers.
<TR>
<TD VALIGN="TOP"><TT>forwarders</TT>
<TD>Takes a list of name servers as arguments. Tells the local name server to try to contact the servers in this list if it can’t resolve an address from its local information.
<TR>
<TD VALIGN="TOP"><TT>slave</TT>
<TD>Turns the local name server into a slave server. If the <TT>slave</TT> option is given, the local server tries to resolve DNS names via recursive queries. It simply forwards the request to one of the servers listed in the <TT>forwarders</TT> option line.
<TR>
<TD COLSPAN="2"><HR>
</TABLE>
<P>In addition to these options, a few additional options aren’t commonly used. Refer to the <TT>named</TT> man page for more information on these options.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>Because <TT>tristar.com</TT> isn’t attached to the Internet, many of the IP host and network addresses in these examples are fake. When setting up your own name server, make sure that you use the correct addresses assigned to you.<HR></FONT>
</BLOCKQUOTE>
<P>The following is a sample named.boot file:
</P>
<!-- CODE SNIP //-->
<PRE>
; named.boot file
; A sample named.boot for tristar.com
;
directory /var/named
;
cache. named.ca
primary tristar.com named.hosts
primary 197.198.199.in-addr.arpa named.rev
</PRE>
<!-- END CODE SNIP //-->
<P>This example sets up the primary name server for <TT>tristar.com</TT>. As you can see, comments start with the <TT>;</TT> character. The <TT>directory</TT> statement in the file tells <TT>named</TT> that all its working files are located in the /var/named directory. Because none of the other files listed in the named.boot file have directory paths associated with them, they’re located in /var/named.</P>
<P>The next line sets up the caching information for this name server. This option should be present on almost every machine running as a name server. It tells <TT>named</TT> to enable caching and load the root server information from the file named.ca.</P>
<BLOCKQUOTE>
<P><FONT SIZE="-1"><HR><B>NOTE: </B>The <TT>cache</TT> entry is very important. Without it, no caching is enabled on the local name server. This can cause severe performance problems for name lookups. Also, the local server can’t contact any root name servers and, as a result, can’t resolve any non-local host names, unless it’s set up as a forwarding name server.<HR></FONT>
</BLOCKQUOTE>
<P>The next line in the named.boot file tells <TT>named</TT> that this server has primary authority for the domain tristar.com. The zone and host information records are in the file named.hosts. You learn about these zone authority records in detail in the following section.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="503-505.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="508-510.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -