浏览代码

chapter07: Translate network config for systemd

Xi Ruoyao 7 年之前
父节点
当前提交
55da4a35aa
共有 1 个文件被更改,包括 144 次插入121 次删除
  1. 144 121
      chapter07/networkd.xml

+ 144 - 121
chapter07/networkd.xml

@@ -1,4 +1,4 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
   "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
   <!ENTITY % general-entities SYSTEM "../general.ent">
@@ -8,83 +8,103 @@
 <sect1 id="ch-scripts-network" revision="systemd">
   <?dbhtml filename="network.html"?>
 
-  <title>General Network Configuration</title>
+  <title>一般网络配置</title>
 
   <indexterm zone="ch-scripts-network">
     <primary sortas="d-network">network</primary>
   <secondary>configuring</secondary></indexterm>
 
-  <para>This section only applies if a network card is to be
-  configured.</para>
+  <para>本节只适用于需要配置网卡的情况。</para>
 
   <sect2>
-    <title>Network Interface Configuration Files</title>
+    <title>网络接口配置文件</title>
 
-    <para>Starting with version 209, systemd ships a network configuration
-    daemon called <command>systemd-networkd</command> which can be used for
-    basic network configuration. Additionally, since version 213, DNS name
-    resolution can be handled by <command>systemd-resolved</command> in place
-    of a static <filename>/etc/resolv.conf</filename> file. Both services are
-    enabled by default.</para>
+	<para>从 209 版本开始,systemd 提供一个名为
+		<command>systemd-networkd</command> 的网络配置守护进程,
+		它能够用于基础网络配置。另外,自 213 版本起,可以用
+		<command>systemd-resolved</command> 代替静态
+		<filename>/etc/resolv.conf</filename> 文件处理域名解析。
+		这两个服务在默认情况下都是启用的。</para>
 
-    <para>Configuration files for <command>systemd-networkd</command> (and
-    <command>systemd-resolved</command>) can be placed in
+    <para><command>systemd-networkd</command> (以及
+    <command>systemd-resolved</command>)的配置文件可以放置在
     <filename class="directory">/usr/lib/systemd/network</filename>
-    or <filename class="directory">/etc/systemd/network</filename>. Files in
-    <filename class="directory">/etc/systemd/network</filename> have a
-    higher priority than the ones in
-    <filename class="directory">/usr/lib/systemd/network</filename>.
-    There are three types of configuration files:
-    <filename class="extension">.link</filename>,
-    <filename class="extension">.netdev</filename> and
-    <filename class="extension">.network</filename> files. For detailed
-    descriptions and example contents of these configuration files, consult 
-    the <filename>systemd-link(5)</filename>,
-    <filename>systemd-netdev(5)</filename> and
-    <filename>systemd-network(5)</filename> manual pages.</para>
+    或 <filename class="directory">/etc/systemd/network</filename> 中。
+    <filename class="directory">/etc/systemd/network</filename>
+    中的配置文件优先级高于
+    <filename class="directory">/usr/lib/systemd/network</filename>
+    中的配置文件。有三种类型的配置文件:
+    <filename class="extension">.link</filename>
+    <filename class="extension">.netdev</filename> 
+    <filename class="extension">.network</filename> 文件。
+    要获得它们的详细描述和内容示例,参阅
+    the <filename>systemd-link(5)</filename>
+    <filename>systemd-netdev(5)</filename> 
+    <filename>systemd-network(5)</filename> man 手册页面。</para>
 
     <sect3 id="systemd-network-devices">
-      <title>Network Device Naming</title>
+      <title>网络设备命名</title>
 
-      <para>
+      <!--para>
         Udev normally assigns network card interface names based
         on system physical characteristics such as enp2s1. If you are
         not sure what your interface name is, you can always run
         <command>ip link</command> after you have booted your system.
-      </para>
-
-      <para>
+      </para-->
+	  <para>
+		  Udev 一般根据系统物理特征为网卡分配接口名,例如 enp2s1。
+		  如果您不确定接口名是什么,可以在引导您的系统后,
+		  运行 <command>ip link</command> 命令。
+	  </para>
+
+      <!--para>
         For most systems, there is only one network interface for
         each type of connection.  For example, the classic interface
         name for a wired connection is eth0.  A wireless connection
         will usually have the name wifi0 or wlan0. 
-      </para>
-
-      <para>
+      </para-->
+	  <para>
+		  对于多数系统,每种连接类型只有一个网络接口。
+		  例如,有线连接的经典接口名是 eth0,而无线连接的接口名一般是
+		  wifi0 或 wlan0。
+	  </para>
+
+      <!--para>
         If you prefer to use the classic or customized network interface names,
-        there are three alternative ways to do that:</para>
+        there are three alternative ways to do that:</para-->
+	  <para>
+		  如果您偏爱经典或自定义网络接口名,可以使用三种不同方式:
+	  </para>
 
       <itemizedlist>
         <listitem>
           <para>
-            Mask udev's .link file for the default policy:
+            覆盖 udev 提供默认策略的 .link 文件:
 <screen role="nodump"><userinput>ln -s /dev/null /etc/systemd/network/99-default.link</userinput></screen>
           </para>
         </listitem>
 
         <listitem>
-          <para>
+          <!--para>
              Create a manual naming scheme, for example by naming the
              interfaces something like "internet0", "dmz0", or "lan0". 
              For that, create .link
              files in /etc/systemd/network/, that choose an explicit name or a
              better naming scheme for one, some, or all of your interfaces. 
              For example:
-          </para>
+          </para-->
+		  <para>
+			  手动创建命名架构,例如将网络接口命名为
+			  <quote>internet0</quote>、<quote>dmz0</quote> 或
+			  <quote>lan0</quote>。为此,在 /etc/systemd/network
+			  中创建 .link 文件,为您的一个、
+			  一些或全部网络接口直接选择名称,或选择更好的命名架构。
+			  例如:
+		  </para>
 
 <screen role="nodump"><userinput>cat &gt; /etc/systemd/network/10-ether0.link &lt;&lt; "EOF"
 <literal>[Match]
-# Change the MAC address as appropriate for your network device
+# 将 MAC 地址替换为适用于您的网络设备的值
 MACAddress=12:34:45:78:90:AB
 
 [Link]
@@ -92,25 +112,24 @@ Name=ether0</literal>
 EOF</userinput></screen>
 
           <para>
-             See the man page systemd.link(5) for more information. 
+             参阅 man 页面 systemd.link(5) 获得更多信息。
           </para>
         </listitem>
 
         <listitem>
           <para>
-            In /boot/grub/grub.cfg, pass the option net.ifnames=0 on the 
-            kernel command line.
+            在 /boot/grub/grub.cfg 的内核命令行中传递选项
+            net.ifnames=0。
           </para>
         </listitem>
       </itemizedlist>
     </sect3>
 
     <sect3 id="systemd-networkd-static">
-      <title>Static IP Configuration</title>
+      <title>静态 IP 配置</title>
 
-      <para>The command below creates a basic configuration file for a
-      Static IP setup (using both systemd-networkd and
-      systemd-resolved):</para>
+      <para>下列命令为静态 IP 设置创建一个基本的配置文件
+      (使用 systemd-networkd 和 systemd-resolved)。</para>
 
 <screen><userinput>cat &gt; /etc/systemd/network/10-eth-static.network &lt;&lt; "EOF"
 <literal>[Match]
@@ -123,17 +142,16 @@ DNS=192.168.0.1
 Domains=<replaceable>&lt;Your Domain Name&gt;</replaceable></literal>
 EOF</userinput></screen>
 
-      <para>Multiple DNS entries can be added if you have more than one DNS
-      server. Do not include DNS or Domains entries if you intend to use a
-      static <filename>/etc/resolv.conf</filename> file.</para>
+      <para>如果您有多个 DNS 服务器,可以在配置文件中创建多个 DNS 项。
+      如果您希望使用静态 <filename>/etc/resolv.conf</filename> 文件,
+      则不要在配置文件中包含 DNS 和 Domains 项。</para>
 
     </sect3>
 
     <sect3 id="systemd-networkd-dhcp">
-      <title>DHCP Configuration</title>
+      <title>DHCP 配置</title>
 
-      <para>The command below creates a basic configuration file for an IPv4
-      DHCP setup:</para>
+      <para>下列命令为 IPv4 DHCP 配置创建基本配置文件:</para>
 
 <screen role="nodump"><userinput>cat &gt; /etc/systemd/network/10-eth-dhcp.network &lt;&lt; "EOF"
 <literal>[Match]
@@ -151,100 +169,109 @@ EOF</userinput></screen>
   </sect2>
 
   <sect2 id="resolv.conf">
-    <title>Creating the /etc/resolv.conf File</title>
+    <title>创建 /etc/resolv.conf 文件</title>
 
     <indexterm zone="resolv.conf">
       <primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
     </indexterm>
 
-    <para>If the system is going to be connected to the Internet, it will
+    <!--para>If the system is going to be connected to the Internet, it will
     need some means of Domain Name Service (DNS) name resolution to
     resolve Internet domain names to IP addresses, and vice versa. This is
     best achieved by placing the IP address of the DNS server, available
     from the ISP or network administrator, into
-    <filename>/etc/resolv.conf</filename>.</para>
+    <filename>/etc/resolv.conf</filename>.</para-->
+    <para>如果要将系统连接到 Internet ,它需要某种域名服务(DNS)
+      名称解析方式,以将 Internet 域名解析为 IP 地址,
+      或将 IP 地址解析为域名。最好的方法是将 ISP 或网络管理员提供的
+      DNS 服务器 IP 地址写入 <filename>/etc/resolv.conf</filename>。</para>
 
     <sect3 id="resolv-conf-systemd-resolved">
-      <title>systemd-resolved Configuration</title>
+      <title>systemd-resolved 配置</title>
 
-      <note><para>If using another means to configure your network
+      <!--note><para>If using another means to configure your network
       interfaces (ex: ppp, network-manager, etc.), or if using any type of
       local resolver (ex: bind, dnsmasq, etc.), or any other software that
       generates an <filename>/etc/resolv.conf</filename> (ex: resolvconf), the
       <command>systemd-resolved</command> service should not be
-      used.</para></note>
-
-      <para>When using <command>systemd-resolved</command> for DNS
-      configuration, it creates the file
-      <filename>/run/systemd/resolve/resolv.conf</filename>. Create a
-      symlink in <filename>/etc</filename> to use the generated file:</para>
+      used.</para></note-->
+      <note><para>如果使用其他方式配置网络接口(例如 ppp 或 network-manager
+          等),或使用了某种本地解析器(如 bind 或 dnsmasq 等),
+          或其他任何生成 <filename>/etc/resolv.conf</filename>
+          的软件(如 resolvconf),则不应使用
+          <command>systemd-resolved</command> 服务。</para></note>
+
+      <para>在使用 <command>systemd-resolved</command> 进行 DNS
+      配置时,它创建文件
+      <filename>/run/systemd/resolve/resolv.conf</filename>。在
+      <filename>/etc</filename> 中创建符号链接以使用生成的文件:</para>
 
 <screen><userinput>ln -sfv /run/systemd/resolve/resolv.conf /etc/resolv.conf</userinput></screen>
 
     </sect3>
 
     <sect3 id="resolv-conf-static">
-      <title>Static resolv.conf Configuration</title>
+      <title>静态 resolv.conf 配置</title>
 
-      <para>If a static <filename>/etc/resolv.conf</filename> is desired,
-      create it by running the following command:</para>
+      <para>如果希望使用静态的 <filename>/etc/resolv.conf</filename>
+      执行下列命令创建它:</para>
 
 <screen role="nodump"><userinput>cat &gt; /etc/resolv.conf &lt;&lt; "EOF"
 <literal># Begin /etc/resolv.conf
 
-domain <replaceable>&lt;Your Domain Name&gt;</replaceable>
-nameserver <replaceable>&lt;IP address of your primary nameserver&gt;</replaceable>
-nameserver <replaceable>&lt;IP address of your secondary nameserver&gt;</replaceable>
+domain <replaceable>&lt;您的域名&gt;</replaceable>
+nameserver <replaceable>&lt;您的主要域名服务器 IP 地址&gt;</replaceable>
+nameserver <replaceable>&lt;您的次要域名服务器 IP 地址&gt;</replaceable>
 
 # End /etc/resolv.conf</literal>
 EOF</userinput></screen>
 
-      <para>The <varname>domain</varname> statement can be omitted
-      or replaced with a <varname>search</varname> statement.  See the man page
-      for resolv.conf for more details.</para>
+      <para>可以省略 <varname>domain</varname> 语句,
+      或使用一条 <varname>search</varname> 语句代替它。
+      阅读 resolv.conf 的 man 页面了解更多细节。</para>
 
-      <para>Replace
-      <replaceable>&lt;IP address of the nameserver&gt;</replaceable>
-      with the IP address of the DNS most appropriate for the setup. There will
-      often be more than one entry (requirements demand secondary servers for
-      fallback capability). If you only need or want one DNS server, remove the
-      second <emphasis>nameserver</emphasis> line from the file. The IP address
-      may also be a router on the local network.</para>
+      <para>
+      <replaceable>&lt;域名服务器的 IP 地址&gt;</replaceable>
+      替换为您的网络环境下最合适的 DNS 服务器 IP 地址。
+	  这里往往会写入不止一个 DNS 服务器(需要提供后备功能的次要服务器)。
+	  如果您只需要或只希望使用一个 DNS 服务器,可以删除文件中的第二个
+      <emphasis>nameserver</emphasis> 行。也可以写入本地路由器的 IP 地址。
+      </para>
 
-      <note><para>The Google Public IPv4 DNS addresses are
-      <parameter>8.8.8.8</parameter> and <parameter>8.8.4.4</parameter>
-      for IPv4, and <parameter>2001:4860:4860::8888</parameter> and
-      <parameter>2001:4860:4860::8844</parameter> for IPv6.</para></note>
+      <note><para>Google 公用 DNS 服务器的 IPv4 地址是
+      <parameter>8.8.8.8</parameter>  <parameter>8.8.4.4</parameter>
+      IPv6 地址是 <parameter>2001:4860:4860::8888</parameter> 和
+      <parameter>2001:4860:4860::8844</parameter></para></note>
 
     </sect3>
 
   </sect2>
 
   <sect2 id="ch-scripts-hostname">
-    <title>Configuring the system hostname</title>
+    <title>配置系统主机名</title>
 
     <indexterm zone="ch-scripts-hostname">
       <primary sortas="d-hostname">hostname</primary>
       <secondary>configuring</secondary>
     </indexterm>
 
-     <para>During the boot process, the file <filename>/etc/hostname</filename>
-     is used for establishing the system's hostname.</para>
+     <para>在引导过程中,<filename>/etc/hostname</filename>
+     被用于设定系统主机名。</para>
 
-     <para>Create the <filename>/etc/hostname</filename> file and enter a
-     hostname by running:</para>
+     <para>执行下列命令,创建 <filename>/etc/hostname</filename>
+     文件,并输入一个主机名:</para>
 
 <screen><userinput>echo "<replaceable>&lt;lfs&gt;</replaceable>" &gt; /etc/hostname</userinput></screen>
 
-     <para><replaceable>&lt;lfs&gt;</replaceable> needs to be replaced with the
-     name given to the computer. Do not enter the Fully Qualified Domain Name
-     (FQDN) here. That information is put in the
-     <filename>/etc/hosts</filename> file.</para>
+     <para><replaceable>&lt;lfs&gt;</replaceable>
+     需要被替换为赋予该计算机的名称。
+     不要在这里输入全限定域名 (FQDN) ,它应该被写入
+	 <filename>/etc/hosts</filename> 文件。</para>
 
   </sect2>
 
   <sect2 id="ch-scripts-hosts">
-     <title>Customizing the /etc/hosts File</title>
+     <title>自定义 /etc/hosts 文件</title>
 
      <indexterm zone="ch-scripts-hosts">
        <primary sortas="e-/etc/hosts">/etc/hosts</primary>
@@ -260,35 +287,33 @@ EOF</userinput></screen>
        <secondary>/etc/hosts</secondary>
      </indexterm>
 
-     <para>Decide on a fully-qualified domain name (FQDN), and possible aliases
-     for use in the <filename>/etc/hosts</filename> file. If using static
-     addresses, you'll also need to decide on an IP address. The syntax
-     for a hosts file entry is:</para>
+     <para>选择一个全限定域名 (FQDN),和可能的别名,以供
+     <filename>/etc/hosts</filename> 文件使用。如果使用静态 IP 地址,
+     您还需要确定要使用的 IP 地址。
+     hosts 文件条目的语法是:</para>
 
 <screen><literal>IP_address myhost.example.org aliases</literal></screen>
 
-     <para>Unless the computer is to be visible to the Internet (i.e., there is
-     a registered domain and a valid block of assigned IP addresses&mdash;most
-     users do not have this), make sure that the IP address is in the private
-     network IP address range. Valid ranges are:</para>
+     <para>除非该计算机可以从 Internet 访问 (即拥有一个注册域名,
+     并分配了一个有效的 IP 地址段 —— 多数用户没有分配有效 IP),
+	 确认使用的 IP 地址属于私网 IP 范围。有效的范围是:</para>
 
-<screen><literal>Private Network Address Range      Normal Prefix
+<screen><literal>私网地址范围      公共前缀长度
 10.0.0.1 - 10.255.255.254           8
 172.x.0.1 - 172.x.255.254           16
 192.168.y.1 - 192.168.y.254         24</literal></screen>
 
-     <para>x can be any number in the range 16-31. y can be any number in the
-     range 0-255.</para>
+     <para>x 可以是 16-31 之间的任何数字,y 可以是 0-255 之间的任何数字。
+     </para>
 
-     <para>A valid private IP address could be 192.168.1.1. A valid FQDN for
-     this IP could be lfs.example.org.</para>
+     <para>有效的私网 IP 地址的一个例子是 192.168.1.1。
+     与之对应的 FQDN 可以是 lfs.example.org。</para>
 
-     <para>Even if not using a network card, a valid FQDN is still required.
-     This is necessary for certain programs to operate correctly.</para>
+     <para>即使没有网卡,也要提供一个有效的 FQDN,
+     某些程序需要它才能正常工作。</para>
 
-     <para>If using DHCP, DHCPv6, IPv6 Autoconfiguration, or if a network card
-     is not going to be configured, create the <filename>/etc/hosts</filename>
-     file by running the following command:</para>
+     <para>如果使用 DHCP、DHCPv6 或 IPv6 自动配置,或者不准备配置网卡,
+     执行下列命令创建 <filename>/etc/hosts</filename> 文件:</para>
 
 <screen role="nodump"><userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"
 <literal># Begin /etc/hosts
@@ -302,12 +327,10 @@ ff02::2   ip6-allrouters
 # End /etc/hosts</literal>
 EOF</userinput></screen>
 
-     <para>The ::1 entry is the IPv6 counterpart of 127.0.0.1 and represents
-     the IPv6 loopback interface. 127.0.1.1 is a loopback entry reserved
-     specifically for the FQDN.</para>
+     <para>::1 是 127.0.0.1 在 IPv6 中的对应,即 IPv6 回环接口。 </para>
 
-     <para>If using a static address, create the <filename>/etc/hosts</filename>
-     file by running this command instead:</para>
+	 <para>如果使用静态地址,执行下列命令创建
+     <filename>/etc/hosts</filename> 文件:</para>
 
 <screen><userinput>cat &gt; /etc/hosts &lt;&lt; "EOF"
 <literal># Begin /etc/hosts
@@ -322,12 +345,12 @@ ff02::2   ip6-allrouters
 # End /etc/hosts</literal>
 EOF</userinput></screen>
 
-     <para>The <replaceable>&lt;192.168.0.2&gt;</replaceable>,
-     <replaceable>&lt;FQDN&gt;</replaceable>, and
-     <replaceable>&lt;HOSTNAME&gt;</replaceable> values need to be
-     changed for specific uses or requirements (if assigned an IP address by a
-     network/system administrator and the machine will be connected to an
-     existing network). The optional alias name(s) can be omitted.</para>
+     <para>其中 <replaceable>&lt;192.168.0.2&gt;</replaceable>、
+     <replaceable>&lt;FQDN&gt;</replaceable>
+	 <replaceable>&lt;HOSTNAME&gt;</replaceable>
+	 值需要为特定使用环境和需求进行修改
+	 (如果系统或网络管理员分配了 IP 地址,且本机将被连接到现有的网络中)。
+     可以跳过别名(alias),它们不是必要的。</para>
    
    </sect2>