diff options
author | Xin LI <delphij@FreeBSD.org> | 2006-06-03 15:34:25 +0000 |
---|---|---|
committer | Xin LI <delphij@FreeBSD.org> | 2006-06-03 15:34:25 +0000 |
commit | 226a77678a3345584c78794e122aec72c922360e (patch) | |
tree | 296183b71b92f01a573d8d15a6823d21a2dc7628 /zh_CN.GB2312/books/handbook/network-servers/chapter.sgml | |
parent | e76e00aba4e8c2e6ea7b0399c1928e0071d73418 (diff) |
Notes
Diffstat (limited to 'zh_CN.GB2312/books/handbook/network-servers/chapter.sgml')
-rw-r--r-- | zh_CN.GB2312/books/handbook/network-servers/chapter.sgml | 1128 |
1 files changed, 368 insertions, 760 deletions
diff --git a/zh_CN.GB2312/books/handbook/network-servers/chapter.sgml b/zh_CN.GB2312/books/handbook/network-servers/chapter.sgml index 8381b1e070..6d8610a501 100644 --- a/zh_CN.GB2312/books/handbook/network-servers/chapter.sgml +++ b/zh_CN.GB2312/books/handbook/network-servers/chapter.sgml @@ -2,7 +2,7 @@ The FreeBSD Documentation Project The FreeBSD Simplified Chinese Project - Original Revision: 1.79 + Original Revision: 1.86 $FreeBSD$ --> @@ -501,17 +501,10 @@ server-program-arguments</programlisting> 以及至少一台客户机, 客户机远程地访问保存在服务器上的数据。 要让这一切运转起来, 需要配置并运行几个程序。</para> - <note><para>在 &os; 4.X 中, <application>portmap</application> - 工具将发挥后续版本中 - <application>rpcbind</application> 工具的作用。 因此, - 在 &os; 4.X 中, 您可能需要把后续例子中的 - <application>rpcbind</application> 改成 - <application>portmap</application> 以便使用。</para></note> - <para>服务器必须运行以下服务:</para> <indexterm> <primary>NFS</primary> - <secondary>server</secondary> + <secondary>server (服务)</secondary> </indexterm> <indexterm> <primary>文件服务器</primary> @@ -522,9 +515,6 @@ server-program-arguments</programlisting> <primary><application>rpcbind</application></primary> </indexterm> <indexterm> - <primary><application>portmap</application></primary> - </indexterm> - <indexterm> <primary><application>mountd</application></primary> </indexterm> <indexterm> @@ -669,14 +659,21 @@ mountd_flags="-r"</programlisting> /exports -alldirs -maproot=root client01 client02 /exports/obj -ro</programlisting> - <para>一旦修改 <filename>/etc/exports</filename> 了之后, - 为了让变动生效,您必须重启 <application>mountd</application>。 - 可以通过对<command>mountd</command> 进程发送HUP信号重启:</para> + <para>在修改了 <filename>/etc/exports</filename> 文件之后, + 就必须让 <application>mountd</application> 服务重新检查它, + 以便使修改生效。 一种方法是通过给正在运行的服务程序发送 HUP + 信号来完成:</para> <screen>&prompt.root; <userinput>kill -HUP `cat /var/run/mountd.pid`</userinput></screen> - <para>另外,系统重启动可以让FreeBSD把一切都弄好。尽管如此,重启不是必须的。 - 以 <username>root</username> 身份执行下面的命令可以搞定一切。</para> + <para>或指定适当的参数来运行 <command>mountd</command> &man.rc.8; 脚本:</para> + + <screen>&prompt.root; <userinput>/etc/rc.d/mountd reload</userinput></screen> + + <para>关于使用 rc 脚本的细节, 请参见 <xref linkend="configtuning-rcd">。</para> + + <para>另外, 系统重启动可以让 FreeBSD 把一切都弄好。 尽管如此, + 重启不是必须的。 以 <username>root</username> 身份执行下面的命令可以搞定一切。</para> <para>在 <acronym>NFS</acronym> 服务器端:</para> @@ -1031,9 +1028,7 @@ Exports list on foobar: 用到的一种网络协议)。 如果没有运行 <application>rpcbind</application>, 则没有办法运行 NIS 服务器, - 或作为 NIS 客户机 (对于 &os; 4.X, - <application>portmap</application> 完成 - <application>rpcbind</application> 的功能)。</entry> + 或作为 NIS 客户机。</entry> </row> <row> <entry><application>ypbind</application></entry> @@ -2284,13 +2279,11 @@ nis_client_flags="-S <replaceable>NIS domain</replaceable>,<replaceable>server</ <listitem> <para>您的内核中, 必须包含 <devicename>bpf</devicename> 设备。 如果需要这样做, 需要将 - <literal>device bpf</literal> (对于 &os; 4.X - 来说, 则应该是 <literal>pseudo-device - bpf</literal>) 添加到内核的编译配置文件中, 并重新编译内核。 + <literal>device bpf</literal> 添加到内核的编译配置文件中, 并重新编译内核。 要了解关于编译内核的进一步信息, 请参见 <xref linkend="kernelconfig">。</para> <para><devicename>bpf</devicename> 设备已经是 FreeBSD 发行版中默认的 <filename>GENERIC</filename> - 内核的一部分了,, 因此如果您没有对内核进行定制, + 内核的一部分了, 因此如果您没有对内核进行定制, 则不用创建一份新的内核配置文件, DHCP 就能工作了。</para> <note> <para>对于那些安全意识很强的人来说, @@ -2407,14 +2400,13 @@ dhcp_flags=""</programlisting> </indexterm> <para>为了在您的 FreeBSD 系统上进行配置以便作为 DHCP 服务器来使用, 需要把 &man.bpf.4; 设备编译进内核。 要完成这项工作, 需要将 - <literal>device bpf</literal> (如果使用 &os; 4.X 的话, 则写作 - <literal>pseudo-device bpf</literal>) 加入到您的内核配置文件中, + <literal>device bpf</literal> 加入到您的内核配置文件中, 并重新联编内核。 要得到关于如何联编内核的进一步信息, 请参见 <xref linkend="kernelconfig">。</para> <para><devicename>bpf</devicename> 设备是 FreeBSD 所附带的 <filename>GENERIC</filename> 内核中已经联入的组件, - 因此您并不需要为了让 DHCP 正常工作而特地定制内核。</para> + 因此您并不需要为了让 DHCP 正常工作而特别地定制内核。</para> <note> <para>如果您有较强的安全意识, 应该注意 @@ -2515,8 +2507,18 @@ host mailhost { </callout> </calloutlist> - <para>一旦您撰写完 - <filename>dhcpd.conf</filename>, 就可以用下面的命令来启动服务:</para> + <para>在配制好 + <filename>dhcpd.conf</filename> 之后, 应在 + <filename>/etc/rc.conf</filename> 中启用 DHCP 服务器, + 也就是增加:</para> + + <programlisting>dhcpd_enable="YES" +dhcpd_ifaces="dc0"</programlisting> + + <para>此处的 <literal>dc0</literal> 接口名应改为 DHCP + 服务器需要监听 DHCP 客户端请求的接口 (如果有多个, 则用空格分开)。</para> + + <para>接下来, 可以用下面的命令来启动服务:</para> <screen>&prompt.root; <userinput>/usr/local/etc/rc.d/isc-dhcpd.sh start</userinput></screen> @@ -2579,58 +2581,59 @@ host mailhost { <surname>Lee</surname> <contrib>Contributed by </contrib> </author> + + <author> + <firstname>Tom</firstname> + <surname>Rhodes</surname> + </author> + + <author> + <firstname>Daniel</firstname> + <surname>Gerzo</surname> + </author> </authorgroup> </sect1info> - <title>域名系统 (DNS)</title> + <title>域名系统 (<acronym>DNS</acronym>)</title> <sect2> <title>纵览</title> <indexterm><primary>BIND</primary></indexterm> - <para>FreeBSD 在默认情况下使用一个版本的 BIND (Berkeley - Internet Name Domain), 这是目前最为流行的 DNS 协议实现。 - DNS 是一种协议, 可以通过它将域名同 IP 地址相互对应。 + <para>&os; 在默认情况下使用一个版本的 BIND (Berkeley + Internet Name Domain), 这是目前最为流行的 <acronym>DNS</acronym> 协议实现。 + <acronym>DNS</acronym> 是一种协议, 可以通过它将域名同 <acronym>IP</acronym> 地址相互对应。 例如, 查询 <hostid role="fqdn">www.FreeBSD.org</hostid> - 将得到 FreeBSD Project 的 web 服务器的 IP 地址, 而查询 <hostid - role="fqdn">ftp.FreeBSD.org</hostid> 则将得到响应的 FTP 机器的 - IP 地址。 类似地, 也可以做相反的事情。 查询 IP - 地址可以得到其主机名。 当然, 完成 DNS - 查询并不需要在系统中运行域名服务器。 - </para> - - <indexterm><primary>DNS</primary></indexterm> - <para>DNS 在 Internet 上通过一组略显复杂的权威根域名服务器来组织, - 它的其余部分则由较小规模的域名服务器组成, - 这些服务器提供少量的域名解析服务, 并对域名信息进行缓存。 - </para> + 将得到 &os; Project 的 web 服务器的 <acronym>IP</acronym> 地址, 而查询 <hostid + role="fqdn">ftp.FreeBSD.org</hostid> 则将得到响应的 <acronym>FTP</acronym> 机器的 + <acronym>IP</acronym> 地址。 类似地, 也可以做相反的事情。 查询 <acronym>IP</acronym> + 地址可以得到其主机名。 当然, 完成 <acronym>DNS</acronym> + 查询并不需要在系统中运行域名服务器。</para> - <para> - 这份文档介绍的是 BIND 8.x, 因为它是 &os; 中使用的稳定版本。 - &os; 5.3 以及更高版本则包含了 - <acronym>BIND</acronym>9 及其配置的说明可以在这一章的后一部分找到。 - 使用 &os; 5.2 以及更早版本的用户, - 可以通过 <filename role="package">net/bind9</filename> port - 来安装 <acronym>BIND</acronym>9。</para> + <para>目前, 默认情况下&os; 使用的是 <acronym>BIND</acronym>9 + <acronym>DNS</acronym> 服务软件。 我们内建于系统中的版本提供了增强的安全特性、 + 新的文件目录结构, 以及自动的 &man.chroot.8; 配置。</para> - <para> - RFC1034 和 RFC1035 定义了 DNS 协议。 - </para> - - <para> - 目前, BIND 由 - Internet Software Consortium <ulink url="http://www.isc.org/"></ulink> - 维护。 - </para> + <indexterm><primary>DNS</primary></indexterm> + <para>在 Internet 上的 <acronym>DNS</acronym> 是通过一套较为复杂的权威根域名系统, + 顶级域名 (<acronym>TLD</acronym>), 以及一系列小规模的, + 提供少量域名解析服务并对域名信息进行缓存的域名服务器组成的。</para> + + <para>目前, BIND 由 + Internet Software Consortium + <ulink url="http://www.isc.org/"></ulink> + 维护。</para> </sect2> <sect2> <title>术语</title> - <para>要理解这份文档, 需要首先了解一些相关的 DNS 术语。</para> + <para>要理解这份文档, 需要首先了解一些相关的 + <acronym>DNS</acronym> 术语。</para> + + <indexterm><primary>resolver (解析器)</primary></indexterm> + <indexterm><primary>reverse DNS (反向 DNS)</primary></indexterm> + <indexterm><primary>root zone (根域)</primary></indexterm> - <indexterm><primary>解析器 (resolver)</primary></indexterm> - <indexterm><primary>反向 DNS (reverse DNS)</primary></indexterm> - <indexterm><primary>根域 (root zone)</primary></indexterm> <informaltable frame="none" pgwide="1"> <tgroup cols="2"> <colspec colwidth="1*"> @@ -2645,7 +2648,7 @@ host mailhost { <tbody> <row> - <entry>正向 DNS (Forward DNS)</entry> + <entry>正向 <acronym>DNS</acronym></entry> <entry>将域名映射到 IP 地址</entry> </row> @@ -2655,8 +2658,8 @@ host mailhost { </row> <row> - <entry><application>named</application>, BIND, 域名服务器(name server)</entry> - <entry>在 FreeBSD 中 BIND 域名服务器软件包的常见叫法</entry> + <entry><application>named</application>, BIND, 域名服务器</entry> + <entry>在 &os; 中 BIND 域名服务器软件包的常见叫法。</entry> </row> <row> @@ -2665,8 +2668,8 @@ host mailhost { </row> <row> - <entry>反向 DNS (Reverse DNS)</entry> - <entry>与正向 DNS 相对; 将 IP 地址映射为主机名</entry> + <entry>反向 <acronym>DNS</acronym></entry> + <entry>与正向 <acronym>DNS</acronym> 相对; 将 <acronym>IP</acronym> 地址映射为主机名</entry> </row> <row> @@ -2678,7 +2681,7 @@ host mailhost { <row> <entry>域 (Zone)</entry> - <entry>独立的域, 子域, 或者由同一机构管理的 DNS 的一部分。</entry> + <entry>独立的域, 子域, 或者由同一机构管理的 <acronym>DNS</acronym> 的一部分。</entry> </row> </tbody> </tgroup> @@ -2689,39 +2692,39 @@ host mailhost { <secondary>例子</secondary> </indexterm> - <para>域的例子: - </para> + <para>域的例子:</para> + <itemizedlist> - <listitem> - <para><hostid>.</hostid> 是根域。</para> - </listitem> - <listitem> - <para><hostid>org.</hostid> 是一个根域下的域。</para> - </listitem> - <listitem> - <para><hostid role="domainname">example.org.</hostid> 是 - <hostid>org.</hostid> 之下的域。</para> - </listitem> - <listitem> - <para><hostid role="domainname">foo.example.org.</hostid> 是 - <hostid role="domainname">example.org.</hostid> 域的子域。</para> - </listitem> - <listitem> - <para> - <hostid>1.2.3.in-addr.arpa</hostid> 是用于表达 <hostid - role="ipaddr">3.2.1.*</hostid> IP 地址空间之下所有 - IP 地址的域。 - </para> - </listitem> - </itemizedlist> + <listitem> + <para><hostid>.</hostid> 是根域。</para> + </listitem> - <para>如您所见, 域名中最细节的部分在它的左边。 - 举例来说, <hostid - role="domainname">example.org.</hostid> 要比 - <hostid>org.</hostid> 更小, 就像 <hostid>org.</hostid> - 要比根域更小一样。 主机名的格局和文件系统类似: - <filename>/dev</filename> 目录在根目录中, 等等。</para> + <listitem> + <para><hostid>org.</hostid> 是根域之下的一个顶级域名 + (<acronym>TLD</acronym>)。</para> + </listitem> + + <listitem> + <para><hostid role="domainname">example.org.</hostid> 是在 + <hostid>org.</hostid> + <acronym>TLD</acronym> 之下的一个域。</para> + </listitem> + + <listitem> + <para><hostid>1.168.192.in-addr.arpa</hostid> 是一个表示所有 + <hostid role="ipaddr">192.168.1.*</hostid> + <acronym>IP</acronym> 地址空间中 <acronym>IP</acronym> + 地址的域。</para> + </listitem> + </itemizedlist> + <para>如您所见, 域名中越细节的部分会越靠左出现。 + 例如, <hostid + role="domainname">example.org.</hostid> 就比 + <hostid>org.</hostid> 范围更小, 而 <hostid>org.</hostid> 又比根域更小。 + 域名各个部分的格局与文件系统十分类似: + <filename role="directory">/dev</filename> 目录在根目录中, + 等等。</para> </sect2> <sect2> @@ -2734,46 +2737,45 @@ host mailhost { <itemizedlist> <listitem> - <para>想要向全世界提供 DNS 信息, + <para>想要向全世界提供 <acronym>DNS</acronym> 信息, 并对请求给出权威应答。</para> </listitem> + <listitem> <para>注册了类似 <hostid role="domainname">example.org</hostid> - 的域, 而需要将 IP 指定到其下的主机名上。</para> + 的域, 而需要将 <acronym>IP</acronym> 指定到其下的主机名上。</para> </listitem> + <listitem> - <para>某个 IP 地址块需要反向 DNS 项 (IP 到主机名)。</para> + <para>某个 <acronym>IP</acronym> 地址块需要反向 + <acronym>DNS</acronym> 项 (<acronym>IP</acronym> 到主机名)。</para> </listitem> + <listitem> - <para>需要备份服务器, 或常说的从 (slave) 服务器, - 在主服务器出现问题或无法访问时来应答查询请求。</para> - </listitem> + <para>备份服务器, 或常说的从 (slave) 服务器, + 会在主服务器出现问题或无法访问时来应答查询请求。</para> + </listitem> </itemizedlist> <para>下列情况需要有缓存域名服务器:</para> <itemizedlist> <listitem> - <para>本地的 DNS 服务器能够缓存, + <para>本地的 <acronym>DNS</acronym> 服务器能够缓存, 并比直接向外界的域名服务器请求更快地得到应答。</para> </listitem> - <listitem> - <para>减少所需的总体网络流量 (DNS - 流量通常占全部 Internet 流量的 5% 或更多)。</para> - </listitem> </itemizedlist> <para>当有人查询 <hostid role="fqdn">www.FreeBSD.org</hostid> 时,解析器通常会向上级 - ISP 的域名服务器发出请求, 并获得回应。 如果有本地的缓存 DNS - 服务器, 查询只有在第一次被缓存 DNS 服务器发到外部世界。 + <acronym>ISP</acronym> 的域名服务器发出请求, 并获得回应。 如果有本地的缓存 DNS + 服务器, 查询只有在第一次被缓存 <acronym>DNS</acronym> 服务器发到外部世界。 其他的查询不会发向局域网外, 因为它们已经有在本地的缓存了。</para> - </sect2> <sect2> <title>DNS 如何运作</title> - <para>在 FreeBSD 中, BIND 服务程序被称为 + <para>在 &os; 中, BIND 服务程序被称为 <application>named</application>, 其原因显而易见。</para> <informaltable frame="none" pgwide="1"> @@ -2787,12 +2789,12 @@ host mailhost { <tbody> <row> - <entry><application>named</application></entry> + <entry>&man.named.8;</entry> <entry>BIND 服务程序</entry> </row> <row> - <entry><command>ndc</command></entry> + <entry>&man.rndc.8;</entry> <entry>域名服务控制程序</entry> </row> @@ -2809,243 +2811,286 @@ host mailhost { </tgroup> </informaltable> - <para> - 域文件通常被放在 - <filename>/etc/namedb</filename> - 目录中, 它们包含域名服务器所提供的 DNS 域的信息。 - </para> + <para>随在服务器上配置的域的性质不同, 域的定义文件一般会存放到 + <filename role="directory">/etc/namedb</filename> 目录中的 <filename + role="directory">master</filename>、 <filename + role="directory">slave</filename>, 或 <filename + role="directory">dynamic</filename> 子目录里。 + 这些文件包含了在域名服务器发出回应时所需的 <acronym>DNS</acronym> 信息。</para> </sect2> <sect2> <title>启动 BIND</title> <indexterm> <primary>BIND</primary> - <secondary>启动</secondary> + <secondary>starting (启动)</secondary> </indexterm> - <para> - 由于 BIND 会在默认情况下安装, 因此配置它相对而言很简单。 - </para> - <para> - 要确保 <application>named</application> 服务程序在引导时被自动启动, - 把下面的行加到 <filename>/etc/rc.conf</filename> 中: - </para> + + <para>由于 BIND 是默认安装的, 因此配置它相对而言很简单。</para> + + <para>默认的 <application>named</application> 配置是在 + &man.chroot.8; 环境中提供基本的域名解析服务。 + 如果希望启动一下这种配置, 可以执行下面的命令:</para> + + <screen>&prompt.root; <userinput>/etc/rc.d/named forcestart</userinput></screen> + + <para>如果希望 <application>named</application> + 服务在每次启动的时候都能够启动, 需要在 + <filename>/etc/rc.conf</filename> 中加入:</para> + <programlisting>named_enable="YES"</programlisting> - <para>要手工启动服务 (在完成配置之后):</para> - <screen>&prompt.root; <userinput>ndc start</userinput></screen> + + <para>当然, 除了这份文档所介绍的配置选项之外, 在 + <filename>/etc/namedb/named.conf</filename> 中还有很多其它的选项。 + 不过, 如果您需要了解 &os; 中用于启动 <application>named</application> + 的那些选项的话, 则可以查看 + <filename>/etc/defaults/rc.conf</filename> 中的 + <literal>named_<replaceable>*</replaceable></literal> 参数, 并参考 + &man.rc.conf.5; 联机手册。 除此之外, + <xref linkend="configtuning-rcd"> 也是一个不错的起点。</para> </sect2> <sect2> <title>配置文件</title> <indexterm> - <primary>BIND</primary> - <secondary>配置文件</secondary> + <primary>BIND</primary> + <secondary>configuration files (配置文件)</secondary> </indexterm> + + <para>目前, <application>named</application> 的配置文件存放于 + <filename role="directory">/etc/namedb</filename> 目录中, + 在使用前需要根据需要进行修改, + 除非只打算用它来完成简单的域名解析任务。 + 同时这个目录也是进行绝大多数配置的地方。</para> + <sect3> - <title>使用 <command>make-localhost</command></title> - <para>一定要: - </para> - <screen>&prompt.root; <userinput>cd /etc/namedb</userinput> -&prompt.root; <userinput>sh make-localhost</userinput></screen> - <para>以便创建正确的本地 DNS 反向解析域文件 - <filename>/etc/namedb/master/localhost.rev</filename>. - </para> + <title>使用 <command>make-localhost</command></title> + + <para>要为 localhost 配置主域, 需要进入 + <filename role="directory">/etc/namedb</filename> 目录, + 并运行下面的命令:</para> + + <screen>&prompt.root; <userinput>sh make-localhost</userinput></screen> + + <para>如果一切正常的话, 在 + <filename class="directory">master</filename> 子目录中会增加一组文件。 + 本地域名对应的文件是 <filename>localhost.rev</filename>, + 而 <acronym>IPv6</acronym> 对应的配置则是 <filename>localhost-v6.rev</filename>。 + 作为默认配置, 所需的信息已经放到了 + <filename>named.conf</filename> 文件中。</para> </sect3> <sect3> - <title><filename>/etc/namedb/named.conf</filename></title> + <title><filename>/etc/namedb/named.conf</filename></title> - <programlisting>// $FreeBSD$ + <programlisting>// $FreeBSD$ // -// Refer to the named(8) manual page for details. If you are ever going -// to setup a primary server, make sure you've understood the hairy -// details of how DNS is working. Even with simple mistakes, you can -// break connectivity for affected parties, or cause huge amount of -// useless Internet traffic. +// Refer to the named.conf(5) and named(8) man pages, and the documentation +// in /usr/share/doc/bind9 for more details. +// +// If you are going to set up an authoritative server, make sure you +// understand the hairy details of how DNS works. Even with +// simple mistakes, you can break connectivity for affected parties, +// or cause huge amounts of useless Internet traffic. options { - directory "/etc/namedb"; + directory "/etc/namedb"; + pid-file "/var/run/named/pid"; + dump-file "/var/dump/named_dump.db"; + statistics-file "/var/stats/named.stats"; + +// If named is being used only as a local resolver, this is a safe default. +// For named to be accessible to the network, comment this option, specify +// the proper IP address, or delete this option. + listen-on { 127.0.0.1; }; + +// If you have IPv6 enabled on this system, uncomment this option for +// use as a local resolver. To give access to the network, specify +// an IPv6 address, or the keyword "any". +// listen-on-v6 { ::1; }; // In addition to the "forwarders" clause, you can force your name // server to never initiate queries of its own, but always ask its // forwarders only, by enabling the following line: // -// forward only; +// forward only; // If you've got a DNS server around at your upstream provider, enter // its IP address here, and enable the line below. This will make you -// benefit from its cache, thus reduce overall DNS traffic in the -Internet. +// benefit from its cache, thus reduce overall DNS traffic in the Internet. /* - forwarders { - 127.0.0.1; - }; + forwarders { + 127.0.0.1; + }; */</programlisting> - <para> - 如注视所说, 要从上级的缓存中受益, 可以在此处启用 - <literal>forwarders</literal>。 在一般情况下, 域名服务器会逐级地查询 - Internet 来找到特定的域名服务器, 直到得到答案为止。 - 启用这个将让它首先查询上级域名服务器 (或另外提供的域名服务器), - 从而从它们的缓存中得到结果。 如果上级域名服务器的负载很重, - 在更快的域名服务器上启用它将有助于改善服务品质。 - </para> + <para>正如注释所言, 如果希望从上级缓存中受益, + 可以在此处启用 <literal>forwarders</literal>。 + 正常情况下, 域名服务器会逐级地查询 + Internet 来找到特定的域名服务器, 直到得到答案为止。 + 这个选项将让它首先查询上级域名服务器 (或另外提供的域名服务器), + 从而从它们的缓存中得到结果。 如果上级域名服务器是一个繁忙的高速域名服务器, + 则启用它将有助于改善服务品质。</para> <warning><para><hostid role="ipaddr">127.0.0.1</hostid> <emphasis>不会</emphasis> 正常工作。 - 一定要把地址改为您上级服务器的 IP 地址。</para> + 一定要把地址改为您上级服务器的 <acronym>IP</acronym> 地址。</para> </warning> - <programlisting> /* - * If there is a firewall between you and name servers you want - * to talk to, you might need to uncomment the query-source - * directive below. Previous versions of BIND always asked - * questions using port 53, but BIND 8.1 uses an unprivileged - * port by default. - */ - // query-source address * port 53; - - /* - * If running in a sandbox, you may have to specify a different - * location for the dumpfile. - */ - // dump-file "s/named_dump.db"; -}; - -// Note: the following will be supported in a future release. -/* -host { any; } { - topology { - 127.0.0.0/8; - }; + <programlisting> /* + * If there is a firewall between you and nameservers you want + * to talk to, you might need to uncomment the query-source + * directive below. Previous versions of BIND always asked + * questions using port 53, but BIND versions 8 and later + * use a pseudo-random unprivileged UDP port by default. + */ + // query-source address * port 53; }; -*/ -// Setting up secondaries is way easier and the rough picture for this -// is explained below. -// // If you enable a local name server, don't forget to enter 127.0.0.1 -// into your /etc/resolv.conf so this server will be queried first. +// first in your /etc/resolv.conf so this server will be queried. // Also, make sure to enable it in /etc/rc.conf. zone "." { - type hint; - file "named.root"; + type hint; + file "named.root"; }; zone "0.0.127.IN-ADDR.ARPA" { - type master; - file "localhost.rev"; + type master; + file "master/localhost.rev"; +}; + +// RFC 3152 +zone "1.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" { + type master; + file "master/localhost-v6.rev"; }; // NB: Do not use the IP addresses below, they are faked, and only // serve demonstration/documentation purposes! // -// Example secondary config entries. It can be convenient to become -// a secondary at least for the zone where your own domain is in. Ask +// Example slave zone config entries. It can be convenient to become +// a slave at least for the zone your own domain is in. Ask // your network administrator for the IP address of the responsible // primary. // // Never forget to include the reverse lookup (IN-ADDR.ARPA) zone! -// (This is the first bytes of the respective IP address, in reverse +// (This is named after the first bytes of the IP address, in reverse // order, with ".IN-ADDR.ARPA" appended.) // -// Before starting to setup a primary zone, better make sure you fully -// understand how DNS and BIND works, however. There are sometimes -// unobvious pitfalls. Setting up a secondary is comparably simpler. +// Before starting to set up a primary zone, make sure you fully +// understand how DNS and BIND works. There are sometimes +// non-obvious pitfalls. Setting up a slave zone is simpler. // // NB: Don't blindly enable the examples below. :-) Use actual names // and addresses instead. -// -// NOTE!!! FreeBSD runs BIND in a sandbox (see named_flags in rc.conf). -// The directory containing the secondary zones must be write accessible -// to BIND. The following sequence is suggested: -// -// mkdir /etc/namedb/s -// chown bind:bind /etc/namedb/s -// chmod 750 /etc/namedb/s</programlisting> - <para>For more information on running BIND in a sandbox, see - <link linkend="network-named-sandbox">Running named in a sandbox</link>. - </para> +/* An example master zone +zone "example.net" { + type master; + file "master/example.net"; +}; +*/ - <programlisting>/* -zone "example.com" { - type slave; - file "s/example.com.bak"; - masters { - 192.168.1.1; - }; +/* An example dynamic zone +key "exampleorgkey" { + algorithm hmac-md5; + secret "sf87HJqjkqh8ac87a02lla=="; +}; +zone "example.org" { + type master; + allow-update { + key "exampleorgkey"; + }; + file "dynamic/example.org"; }; +*/ -zone "0.168.192.in-addr.arpa" { - type slave; - file "s/0.168.192.in-addr.arpa.bak"; - masters { - 192.168.1.1; - }; +/* Examples of forward and reverse slave zones +zone "example.com" { + type slave; + file "slave/example.com"; + masters { + 192.168.1.1; + }; +}; +zone "1.168.192.in-addr.arpa" { + type slave; + file "slave/1.168.192.in-addr.arpa"; + masters { + 192.168.1.1; + }; }; */</programlisting> - <para>在 <filename>named.conf</filename> 中, 这是一些转发用的从域以及反向域的例子。</para> - <para>对于每一个新域, 域对应的项必须加到 - <filename>named.conf</filename> 中。</para> + <para>在 <filename>named.conf</filename> 中, + 还给出了从域、转发域和反解析域的例子。</para> + + <para>如果新增了域, 就必需在 <filename>named.conf</filename> 中加入对应的项目。</para> - <para>例如, 最简单的用于 - <hostid role="domainname">example.org</hostid> 域的条目类似下面的样子:</para> + <para>例如, 用于 + <hostid role="domainname">example.org</hostid> 的域文件的描述类似下面这样:</para> - <programlisting>zone "example.org" { + <programlisting>zone "example.org" { type master; - file "example.org"; + file "master/example.org"; };</programlisting> - <para>这是一个主域, 它由 <option>type</option> 语句标识出来, - 而信息则在 - <filename>/etc/namedb/example.org</filename> 域文件中, - 这是由 <option>file</option> 语句指定的。</para> + <para>如 <option>type</option> 语句所标示的那样, + 这是一个主域, 其信息保存在 + <filename>/etc/namedb/master/example.org</filename> + 中, 如 <option>file</option> 语句所示。</para> - <programlisting>zone "example.org" { + <programlisting>zone "example.org" { type slave; - file "example.org"; + file "slave/example.org"; };</programlisting> - <para>在从域的例子中, 域的信息从该域的某个主服务器传送过来, - 并保存在指定的文件中。 如果主服务器死掉了或不可达, - 从域名服务器将使用这些传过来的域信息, 从而完成应答。</para> + <para>在从域的情形中, 所指定的域的信息会从主域名服务器传递过来, + 并保存到对应的文件中。 当主域服务器发生问题或不可达时, + 从域名服务器就有一份可用的域名信息, 从而能够对外提供服务。</para> </sect3> <sect3> - <title>域信息文件</title> - <para> - 以下是一个用于 <hostid - role="domainname">example.org</hostid> 域的主域文件 (保存为 - <filename>/etc/namedb/example.org</filename>): - </para> + <title>域文件</title> + <indexterm> + <primary>BIND</primary> + <secondary>zone files (域文件)</secondary> + </indexterm> + + <para>下面的例子展示了用于 <hostid + role="domainname">example.org</hostid> 的主域文件 (存放于 + <filename>/etc/namedb/master/example.org</filename>):</para> + + <programlisting>$TTL 3600 ; 1 hour +example.org. IN SOA ns1.example.org. admin.example.org. ( + 2006051501 ; Serial + 10800 ; Refresh + 3600 ; Retry + 604800 ; Expire + 86400 ; Minimum TTL + ) - <programlisting>$TTL 3600 +; DNS Servers + IN NS ns1.example.org. + IN NS ns2.example.org. -example.org. IN SOA ns1.example.org. admin.example.org. ( - 5 ; Serial - 10800 ; Refresh - 3600 ; Retry - 604800 ; Expire - 86400 ) ; Minimum TTL +; MX Records + IN MX 10 mx.example.org. + IN MX 20 mail.example.org. -; DNS Servers -@ IN NS ns1.example.org. -@ IN NS ns2.example.org. + IN A 192.168.1.1 ; Machine Names localhost IN A 127.0.0.1 -ns1 IN A 3.2.1.2 -ns2 IN A 3.2.1.3 -mail IN A 3.2.1.10 -@ IN A 3.2.1.30 +ns1 IN A 192.168.1.2 +ns2 IN A 192.168.1.3 +mx IN A 192.168.1.4 +mail IN A 192.168.1.5 ; Aliases -www IN CNAME @ - -; MX Record -@ IN MX 10 mail.example.org.</programlisting> +www IN CNAME localhost</programlisting> <para> 请注意以 <quote>.</quote> 结尾的主机名是全称主机名, 而结尾没有 @@ -3111,7 +3156,7 @@ www IN CNAME @ <programlisting> example.org. IN SOA ns1.example.org. admin.example.org. ( - 5 ; Serial + 2006051501 ; Serial 10800 ; Refresh after 3 hours 3600 ; Retry after 1 hour 604800 ; Expire after 1 week @@ -3143,54 +3188,49 @@ example.org. IN SOA ns1.example.org. admin.example.org. ( </varlistentry> <varlistentry> - <term><literal>5</literal></term> + <term><literal>2006051501</literal></term> <listitem><para>文件的序号。 每次修改域文件时都必须增加这个数字。 现今, 许多管理员会考虑使用 <literal>yyyymmddrr</literal> 这样的格式来表示序号。 - <literal>2001041002</literal> 通常表示上次修改于 - 04/10/2001, 而后面的 - <literal>02</literal> 则表示在那天的第几次修改。 + <literal>2006051501</literal> 通常表示上次修改于 + 05/15/2006, 而后面的 + <literal>01</literal> 则表示在那天的第一次修改。 序号非常重要, 它用于通知从域服务器更新数据。</para> </listitem> </varlistentry> </variablelist> <programlisting> -@ IN NS ns1.example.org.</programlisting> + IN NS ns1.example.org.</programlisting> <para> 这是一个 NS 项。 每个准备提供权威应答的服务器都必须有一个对应项。 - 这里的 <literal>@</literal> 表示 - <hostid role="domainname">example.org.</hostid>。 - <literal>@</literal> 会被理解为原点。 </para> <programlisting> localhost IN A 127.0.0.1 -ns1 IN A 3.2.1.2 -ns2 IN A 3.2.1.3 -mail IN A 3.2.1.10 -@ IN A 3.2.1.30</programlisting> +ns1 IN A 192.168.1.2 +ns2 IN A 192.168.1.3 +mx IN A 192.168.1.4 +mail IN A 192.168.1.5</programlisting> <para> - A 记录代表及其名。 如上面看到的, + A 记录指明了机器名。 正如在前面所按倒的, <hostid role="fqdn">ns1.example.org</hostid> 将解析为 - <hostid role="ipaddr">3.2.1.2</hostid>。 在此再次使用了原点符, - <literal>@</literal>, 它表示 - <hostid role="domainname">example.org</hostid> 应解析为 - <hostid role="ipaddr">3.2.1.30</hostid>。 + <hostid role="ipaddr">192.168.1.2</hostid>。 </para> <programlisting> -www IN CNAME @</programlisting> +www IN CNAME localhost</programlisting> <para> - 正规名记录通常用于对某台机器的别名给出对应的正式名字。 - 在这个例子中, <hostid>www</hostid> 是名字为原点, 或者说 - <hostid role="domainname">example.org</hostid> - (<hostid role="ipaddr">3.2.1.30</hostid>) 那台机器的别名。 - CNAMEs 可以用来提供主机的别名, 或将同一名字在多台机器上作轮询。 + 正规名 (CNAME) 记录通常用于为某台机器指定别名。 在这个例子中, + <hostid>www</hostid> 是 + <hostid role="domainname">localhost.example.org</hostid> + (<hostid role="ipaddr">127.0.0.1</hostid>) 的别名。 + CNAME 也可以用来提供主机别名, + 或将一个主机名以轮转 (round robin) 方式指定到多台服务器。 </para> <indexterm> @@ -3198,7 +3238,7 @@ www IN CNAME @</programlisting> </indexterm> <programlisting> -@ IN MX 10 mail.example.org.</programlisting> + IN MX 10 mail.example.org.</programlisting> <para> MX 记录表示哪个邮件服务器负责接收发到这个域的邮件。 @@ -3207,10 +3247,11 @@ www IN CNAME @</programlisting> </para> <para> - 可以有多台邮件服务器, 其优先级分别是 3, 2, - 1。 向 <hostid - role="domainname">example.org</hostid> 进行投递的邮件服务器首先会尝试优先级最高 - (数字最小) 的 MX, 然后是较低优先级的, 等等, 直到成功地投递了邮件为止。 + 可以有多台邮件服务器, 其优先级分别是 10、 + 20 等等。 尝试向 <hostid + role="domainname">example.org</hostid> 投递邮件的服务器, + 会首先尝试优先级最高的 MX (优先级数值最低的记录)、 + 接着尝试次高的, 并重复这一过程直到邮件递送到达为止。 </para> <para> @@ -3220,20 +3261,21 @@ www IN CNAME @</programlisting> <programlisting>$TTL 3600 -1.2.3.in-addr.arpa. IN SOA ns1.example.org. admin.example.org. ( - 5 ; Serial +1.168.192.in-addr.arpa. IN SOA ns1.example.org. admin.example.org. ( + 2006051501 ; Serial 10800 ; Refresh 3600 ; Retry 604800 ; Expire 3600 ) ; Minimum -@ IN NS ns1.example.org. -@ IN NS ns2.example.org. + IN NS ns1.example.org. + IN NS ns2.example.org. +1 IN PTR example.org. 2 IN PTR ns1.example.org. 3 IN PTR ns2.example.org. -10 IN PTR mail.example.org. -30 IN PTR example.org.</programlisting> +4 IN PTR mx.example.org. +5 IN PTR mail.example.org.</programlisting> <para>这个文件给出了上述假想域中 IP 地址到域名的映射关系。</para> </sect3> @@ -3252,269 +3294,6 @@ www IN CNAME @</programlisting> 而不配置域就可以了。</para> </sect2> - <sect2 id="network-named-sandbox"> - <title>在沙盒中运行 <application>named</application></title> - <indexterm> - <primary>BIND</primary> - <secondary>在沙盒中运行</secondary> - </indexterm> - - <indexterm> - <primary><command>chroot</command></primary> - </indexterm> - <para>要更安全地运行 &man.named.8;, 应该以非特权用户来运行它, - 并配置为 &man.chroot.8; 到一个沙盒目录中。 - 这使得 <application>named</application> 服务无法访问任何沙盒外面的东西。 - 假如 <application>named</application> 被攻破, - 这将减少它所能带来的破坏。 默认情况下, FreeBSD 提供了名为 - <groupname>bind</groupname> 的用户和组来完成这样的目的。</para> - - <note><para>许多人建议不这样做, 而 - <application>named</application> 配置为 <command>chroot</command>, - 您应该在一个 &man.jail.8; 中运行 <application>named</application>。 - 这一节并不涵盖这种情形。</para> - </note> - - <para>由于 <application>named</application> 没有办法访问沙盒外面的任何东西 - (例如共享库, 日志 socket 等等), 您需要做许多事情来让 - <application>named</application> 正常工作。 下面的清单假定沙盒是 - <filename>/etc/namedb</filename> 而您没有事先改过这个目录中的内容。 - 以 <username>root</username> 的身份完成下列步骤:</para> - - <itemizedlist> - <listitem> - <para>创建 <application>named</application> - 需要访问的所有目录:</para> - - <screen>&prompt.root; <userinput>cd /etc/namedb</userinput> -&prompt.root; <userinput>mkdir -p bin dev etc var/tmp var/run master slave</userinput> -&prompt.root; <userinput>chown bind:bind slave var/*</userinput><co id="chown-slave"></screen> - - - - <calloutlist> - <callout arearefs="chown-slave"> - <para><application>named</application> 只需要写这些目录, - 这也是我们赋予它的全部权限。</para> - </callout> - </calloutlist> - </listitem> - - <listitem> - <para>重新组织基本的域和配置文件:</para> - <screen>&prompt.root; <userinput>cp /etc/localtime etc</userinput><co id="localtime"> -&prompt.root; <userinput>mv named.conf etc && ln -sf etc/named.conf</userinput> -&prompt.root; <userinput>mv named.root master</userinput> -<!-- I don't like this next bit --> -&prompt.root; <userinput>sh make-localhost</userinput> -&prompt.root; <userinput>cat > master/named.localhost -$ORIGIN localhost. -$TTL 6h -@ IN SOA localhost. postmaster.localhost. ( - 1 ; serial - 3600 ; refresh - 1800 ; retry - 604800 ; expiration - 3600 ) ; minimum - IN NS localhost. - IN A 127.0.0.1 -^D</userinput></screen> - - <calloutlist> - <callout arearefs="localtime"> - <para>这使得 <application>named</application> 能够将正确的时间传递给 - &man.syslogd.8;。</para> - </callout> - </calloutlist> - </listitem> - - <listitem> - - <indexterm><primary>syslog</primary></indexterm> - <indexterm><primary>日志文件</primary> - <secondary>named</secondary></indexterm> - - <para>如果您在运行 &os; 在 4.9-RELEASE 之前的版本, 需要联编一个静态连接的 - <application>named-xfer</application>, 并将其复制到沙盒中:</para> - - <screen>&prompt.root; <userinput>cd /usr/src/lib/libisc</userinput> -&prompt.root; <userinput>make cleandir && make cleandir && make depend && make all</userinput> -&prompt.root; <userinput>cd /usr/src/lib/libbind</userinput> -&prompt.root; <userinput>make cleandir && make cleandir && make depend && make all</userinput> -&prompt.root; <userinput>cd /usr/src/libexec/named-xfer</userinput> -&prompt.root; <userinput>make cleandir && make cleandir && make depend && make NOSHARED=yes all</userinput> -&prompt.root; <userinput>cp named-xfer /etc/namedb/bin && chmod 555 /etc/namedb/bin/named-xfer</userinput><co id="clean-cruft"></screen> - - <para>在把静态连接的 - <command>named-xfer</command> 装好之后需要清理一下, - 以免将过时的库或程序留在您的源代码副本中:</para> - - <screen>&prompt.root; <userinput>cd /usr/src/lib/libisc</userinput> -&prompt.root; <userinput>make cleandir</userinput> -&prompt.root; <userinput>cd /usr/src/lib/libbind</userinput> -&prompt.root; <userinput>make cleandir</userinput> -&prompt.root; <userinput>cd /usr/src/libexec/named-xfer</userinput> -&prompt.root; <userinput>make cleandir</userinput></screen> - - <calloutlist> - <callout arearefs="clean-cruft"> - <para>据说这一步有时会失败。 如果您遇到这样的问题, 执行下面的命令:</para> - - <screen>&prompt.root; <userinput>cd /usr/src && make cleandir && make cleandir</userinput></screen> - - <para>并删除 <filename>/usr/obj</filename> 目录:</para> - - <screen>&prompt.root; <userinput>rm -fr /usr/obj && mkdir /usr/obj</userinput></screen> - - <para>这将把任何 <quote>垃圾</quote> 从您的源代码目录中删除, - 而后续工作将得以正常进行。</para> - </callout> - </calloutlist> - - <para>如果您运行 &os; 的 4.9-RELEASE 或更新的版本, 则默认情况下 - <filename>/usr/libexec</filename> 中的 <command>named-xfer</command> - 副本已经是静态连接的了。 您可以简单地把它用 &man.cp.1; 复制到沙盒中。</para> - </listitem> - - <listitem> - <para>做一个 <application>named</application> - 能够看到并写入的 <filename>dev/null</filename>:</para> - - <screen>&prompt.root; <userinput>cd /etc/namedb/dev && mknod null c 2 2</userinput> -&prompt.root; <userinput>chmod 666 null</userinput></screen> - </listitem> - - <listitem> - <para>将 <filename>/var/run/ndc</filename> 符号链接到 - <filename>/etc/namedb/var/run/ndc</filename>:</para> - - <screen>&prompt.root; <userinput>ln -sf /etc/namedb/var/run/ndc /var/run/ndc</userinput></screen> - - <note> - <para>这个非常简单的措施有效地避免了您每次都必须指定 - <option>-c</option> 参数来启动 &man.ndc.8; 的麻烦。 由于 - <filename>/var/run</filename> 中的内容会在启动时被删除, - 把上述命令加入到 - <username>root</username> 的 &man.crontab.5; 中, 并指定 - <option>@reboot</option> 选项会很有用。</para> - </note> - - </listitem> - - <listitem> - - <indexterm><primary>syslog</primary></indexterm> - <indexterm><primary>日志文件</primary> - <secondary>named</secondary></indexterm> - - <para>配置 &man.syslogd.8; 来创建一个 <application>named</application> - 可以写的 <devicename>log</devicename> socket。 要完成它, 需要将 - <literal>-l /etc/namedb/dev/log</literal> 加到 - <filename>/etc/rc.conf</filename> 的 - <varname>syslogd_flags</varname> 变量中。</para> - </listitem> - - <listitem> - - <indexterm><primary><command>chroot</command></primary></indexterm> - - <para>启动 <application>named</application> 并让它自动地把自己 - <command>chroot</command> 到沙盒中, 方法是把下面的内容加到 - <filename>/etc/rc.conf</filename>:</para> - - <programlisting>named_enable="YES" -named_flags="-u bind -g bind -t /etc/namedb /etc/named.conf"</programlisting> - - <note> - <para>请注意配置文件 - <replaceable>/etc/named.conf</replaceable> 是以 - <emphasis>相对于沙盒</emphasis> 的完整路径来指定的, - 例如上面那一行, 文件所在的目录实际上是 - <filename>/etc/namedb/etc/named.conf</filename>。</para> - </note> - </listitem> - </itemizedlist> - - <para>下一步是编辑 - <filename>/etc/namedb/etc/named.conf</filename> 让 - <application>named</application> 直到需要加载哪些域, - 以及它们在磁盘上的位置。 您可以用注释掉的那个例子 - (没有明确地注释掉的哪些和不在沙盒中运行 DNS 服务器时的配置无异):</para> - - <programlisting>options { - directory "/";<co id="directory"> - named-xfer "/bin/named-xfer";<co id="named-xfer"> - version ""; // Don't reveal BIND version - query-source address * port 53; -}; -// ndc control socket -controls { - unix "/var/run/ndc" perm 0600 owner 0 group 0; -}; -// Zones follow: -zone "localhost" IN { - type master; - file "master/named.localhost";<co id="master"> - allow-transfer { localhost; }; - notify no; -}; -zone "0.0.127.in-addr.arpa" IN { - type master; - file "master/localhost.rev"; - allow-transfer { localhost; }; - notify no; -}; -zone "." IN { - type hint; - file "master/named.root"; -}; -zone "private.example.net" in { - type master; - file "master/private.example.net.db"; - allow-transfer { 192.168.10.0/24; }; -}; -zone "10.168.192.in-addr.arpa" in { - type slave; - masters { 192.168.10.2; }; - file "slave/192.168.10.db";<co id="slave"> -};</programlisting> - - <calloutlist> - <callout arearefs="directory"> - <para> - <literal>directory</literal> 语句被指定为 - <filename>/</filename>, 因为所有的 - <application>named</application> 需要在这个文件中 - (这相当于在 <quote>普通</quote> 模式下运行时的 - <filename>/etc/namedb</filename>)。</para> - </callout> - - <callout arearefs="named-xfer"> - <para>指定到 <command>named-xfer</command> 执行文件的完整路径 (相对 - <application>named</application> 的参照系)。 这是必须的步骤, - 因为 <application>named</application> 在默认情况下会从 - <filename>/usr/libexec</filename> 查找 <command>named-xfer</command>。</para> - </callout> - <callout arearefs="master"><para>指定文件名 (相对于前面的 - <literal>directory</literal> 语句指定的目录), - <application>named</application> 将在这里查找域信息文件。</para> - </callout> - <callout arearefs="slave"><para>指定文件名 (相对于前面的 - <literal>directory</literal> 语句指定的目录), - <application>named</application> 将在这里写入成功地从主服务器拿到的域信息文件副本。 - 这使为什么我们在前面的步骤中将 <filename>slave</filename> 的属主改为 - <groupname>bind</groupname> 的原因。</para> - </callout> - </calloutlist> - - <para>完成这些配置之后, 您可以重新启动服务器, 或重启 - &man.syslogd.8; 服务并启动 &man.named.8;, 以确认 - <varname>syslogd_flags</varname> 和 - <varname>named_flags</varname> 的新值生效了。 - 现在您应该已经在沙盒中运行 <application>named</application> 了!</para> - - </sect2> - <sect2> <title>安全</title> @@ -3522,22 +3301,27 @@ zone "10.168.192.in-addr.arpa" in { 时常会有人发现一些可能的甚至可以利用的安全漏洞。 </para> - <para> - 经常阅读 <ulink - url="http://www.cert.org/">CERT</ulink> 的安全公告并订阅 - &a.security-notifications; 会是一个帮助您时刻了解最新 - Internet 和 FreeBSD 安全问题的好习惯。 - </para> + <para>尽管 &os; 会自动将 + <application>named</application> 放到 &man.chroot.8; + 环境中运行, 但仍有一些其它可用的安全机制来帮助您规避潜在的针对 + <acronym>DNS</acronym> 服务的攻击。</para> + + <para>阅读 <ulink + url="http://www.cert.org/">CERT</ulink> 的安全公告, + 并订阅 the &a.security-notifications; 是一个有助于帮助您了解最新 + Internet 及 &os; 安全问题的好习惯。</para> - <tip><para>如果出现了问题, 将代码升级到最新版本并重新联编 - <application>named</application> 不会带来任何麻烦。</para></tip> + <tip> + <para>如果发现了问题, 确保源代码是最新的, + 并重新联编一份 <application>named</application> 不会给您带来任何麻烦。</para> + </tip> </sect2> <sect2> <title>进一步阅读</title> <para>BIND/<application>named</application> 联机手册: - &man.ndc.8; &man.named.8; &man.named.conf.5;</para> + &man.rndc.8; &man.named.8; &man.named.conf.5;</para> <itemizedlist> <listitem> @@ -3548,13 +3332,19 @@ zone "10.168.192.in-addr.arpa" in { <listitem> <para><ulink - url="http://www.nominum.com/getOpenSourceResource.php?id=6"> - BIND FAQ</ulink></para> + url="http://www.isc.org/sw/guild/bf/">Official ISC BIND + Forum</ulink></para> + </listitem> + + <listitem> + <para><ulink + url="http://www.nominum.com/getOpenSourceResource.php?id=6"> + BIND FAQ</ulink></para> </listitem> <listitem> - <para><ulink url="http://www.oreilly.com/catalog/dns4/">O'Reilly - DNS 和 BIND 第4版</ulink></para> + <para><ulink url="http://www.oreilly.com/catalog/dns5/">O'Reilly + DNS 和 BIND 第 5 版</ulink></para> </listitem> <listitem> @@ -3572,183 +3362,6 @@ zone "10.168.192.in-addr.arpa" in { </sect2> </sect1> - <sect1 id="network-bind9"> - <sect1info> - <authorgroup> - <author> - <firstname>Tom</firstname> - <surname>Rhodes</surname> - <contrib>撰写者 </contrib> - </author> - </authorgroup> - </sect1info> - <title><acronym>BIND</acronym>9 和 &os;</title> - -<!-- This section is here to get users up with BIND9 configurations! It - does not cover the terminology, theoretical discussion (why run a name - server) or the further reading which is still in the previous section. - I did things this way to avoid repetition of content and obviously we - cannot just remove the previous section since other supported releases - use it. When the previous section is removed then those comments - should be moved here. // Tom Rhodes --> - - <indexterm><primary>bind9</primary> - <secondary>安装</secondary></indexterm> - - <para>随着 &os; 5.3 版本的发布, - <acronym>BIND</acronym>9 <acronym>DNS</acronym> - 服务软件正式成为了发行版本的一部分。 新的安全特性,文件布局, - 以及自动的 &man.chroot.8; 配置也加入进来。 这一节分成两部分, - 第一部分讨论了新增特性以及如何配置它们; 后一部分则讲述了升级过程, - 帮助用户迁移到 &os; 5.3。 从现在起, 服务器将被简单地写作 - &man.named.8; 或 <acronym>BIND</acronym>。 - 这一节跳过了前一节所介绍的那些术语, 以及一些理论上的讨论; - 因此, 建议您在继续阅读之前首先看一看前面的章节。</para> - - <para>目前, <application>named</application> 的配置文件存放在 - <filename class="directory">/var/named/etc/namedb/</filename>, - 在使用之前需要进行一些修改。 这也是进行绝大多数相关配置的地方。</para> - - <sect2> - <title>主域的配置</title> - - <para>要配置主域, 应首先进入 - <filename class="directory">/var/named/etc/namedb/</filename> - 并执行下面的命令:</para> - - <screen>&prompt.root; <userinput>sh make-localhost</userinput></screen> - - <para>如果一切正常, 则在 - <filename class="directory">master</filename> 目录中将出现两个新文件。 - 它们的名字应该是用于本地域名解析的 <filename>localhost.rev</filename>, - 以及用于 <acronym>IPv6</acronym> 配置的 - <filename>localhost-v6.rev</filename>。 作为默认的配置文件, - 关于它们的配置已经在 <filename>named.conf</filename> 文件中定义了。</para> - </sect2> - - <sect2> - <title>从域的配置</title> - - <para>可以通过配置从域来提供额外的域或子域的解析。 - 多数情况下, <filename>master/localhost.rev</filename> - 文件可以直接复制到 <filename class="directory">slave</filename> - 目录中并进行修改。 此后, - 这些文件应该加入到 <filename>named.conf</filename>, 类似下面的 - <hostid role="domainname">example.com</hostid> - 配置:</para> - - <programlisting>zone "example.com" { - type slave; - file "slave/example.com"; - masters { - 10.0.0.1; - }; -}; - -zone "0.168.192.in-addr.arpa" { - type slave; - file "slave/0.168.192.in-addr.arpa"; - masters { - 10.0.0.1; - }; -};</programlisting> - - <para>请注意在这个例子中, 主服务器的 - <acronym>IP</acronym> 地址指明了我们要从哪里把域传过来; - 那台服务器本身并不一定要作为对外的 - <acronym>DNS</acronym> 服务器来用。</para> - </sect2> - - <sect2> - <title>系统的初始配置</title> - - <para>为了让 <application>named</application> 服务能够在系统启动时自动加载, - 需要把下面的选项加到 <filename>rc.conf</filename> 文件中:</para> - - <programlisting>named_enable="YES"</programlisting> - - <para>尽管还有其他的一些可用选项, 这是运行域名服务器所需要的最小配置。 - 请参考 &man.rc.conf.5; 联机手册了解更多的选项。 如果不需要继续在 - <filename>rc.conf</filename> 文件中进行其他配置了, - 就可以通过下面的命令行来启动 <application>named</application>:</para> - - <screen>&prompt.root; <userinput>/etc/rc.d/named start</userinput></screen> - </sect2> - - <sect2> - <title><acronym>BIND</acronym>9 的安全</title> - - <para>尽管 &os; 会自动地将 <application>named</application> - 放到一个 &man.chroot.8; 环境中, - 您仍然可以采取一些更为严密的措施来防止潜在的针对 - <acronym>DNS</acronym> 服务的攻击。</para> - - <sect3> - <title>查询访问控制表</title> - - <para>查询访问控制表可以用来限制对于域的查询。 - 这些配置通过在 <literal>acl</literal> 语句中列出的 - <acronym>IP</acronym> 地址来发挥作用。 要允许一个子网查询 - example.org 中的主机, 可以做下面的定义:</para> - - <programlisting>acl "example.com" { - 192.168.0.0/24; -}; - -zone "example.com" { - type slave; - file "slave/example.com"; - masters { - 10.0.0.1; - }; - allow-query { example.com; }; -}; - -zone "0.168.192.in-addr.arpa" { - type slave; - file "slave/0.168.192.in-addr.arpa"; - masters { - 10.0.0.1; - }; - allow-query { example.com; }; -};</programlisting> - </sect3> - - <sect3> - <title>限制版本查询</title> - - <para>允许查询 <acronym>DNS</acronym> 服务的版本, - 可能会给攻击者敞开方便之门。 - 心存恶意的用户能够利用这一信息找到存在已知漏洞的服务器, - 并利用这些漏洞来实施攻击。</para> - - <warning> - <para>配置伪造的版本号并不能阻止服务器被使用已知的攻击手段进行攻击。 - 唯一能够确保安全的办法是将服务器升级到没有已知问题的版本。</para> - </warning> - - <para>伪造的版本号可以通过 <filename>named.conf</filename> 的 - <literal>options</literal> 小节来指定:</para> - - <programlisting>options { - directory "/etc/namedb"; - pid-file "/var/run/named/pid"; - dump-file "/var/dump/named_dump.db"; - statistics-file "/var/stats/named.stats"; - version "None of your business"; -};</programlisting> - </sect3> - -<!-- Here is where I stopped for now - <sect3> - <title>Authentication</title> - - <para> ... </para> - ---> - </sect2> - </sect1> - <sect1 id="network-apache"> <sect1info> <authorgroup> @@ -4622,11 +4235,6 @@ driftfile /var/db/ntp.drift</programlisting> 例如:</para> <screen>&prompt.root; <userinput>ntpd -p /var/run/ntpd.pid</userinput></screen> - - <note> - <para>在 &os; 4.X 中, - 需要把上述参数中的 <literal>ntpd</literal> - 改为 <literal>xntpd</literal>。</para></note> </sect2> <sect2> |