|
@@ -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"
|
|
<!DOCTYPE sect1 PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
<!ENTITY % general-entities SYSTEM "../general.ent">
|
|
@@ -8,7 +8,7 @@
|
|
<sect1 id="ch-scripts-network" revision="sysv">
|
|
<sect1 id="ch-scripts-network" revision="sysv">
|
|
<?dbhtml filename="network.html"?>
|
|
<?dbhtml filename="network.html"?>
|
|
|
|
|
|
- <title>General Network Configuration</title>
|
|
|
|
|
|
+ <title>一般网络配置</title>
|
|
|
|
|
|
<indexterm zone="ch-scripts-network">
|
|
<indexterm zone="ch-scripts-network">
|
|
<primary sortas="d-network">network</primary>
|
|
<primary sortas="d-network">network</primary>
|
|
@@ -25,9 +25,9 @@
|
|
installed in <xref linkend="ch-scripts-bootscripts"/>.</para>
|
|
installed in <xref linkend="ch-scripts-bootscripts"/>.</para>
|
|
-->
|
|
-->
|
|
<sect2>
|
|
<sect2>
|
|
- <title>Creating Network Interface Configuration Files</title>
|
|
|
|
|
|
+ <title>创建网络接口配置文件</title>
|
|
|
|
|
|
- <para>Which interfaces are brought up and down by the network script
|
|
|
|
|
|
+ <!--para>Which interfaces are brought up and down by the network script
|
|
usually depends on the files in <filename
|
|
usually depends on the files in <filename
|
|
class="directory">/etc/sysconfig/</filename>. This directory should
|
|
class="directory">/etc/sysconfig/</filename>. This directory should
|
|
contain a file for each interface to be configured, such as
|
|
contain a file for each interface to be configured, such as
|
|
@@ -35,17 +35,31 @@
|
|
the network card. The interface name (e.g. eth0) is usually appropriate.
|
|
the network card. The interface name (e.g. eth0) is usually appropriate.
|
|
Inside this file are attributes to this interface, such as its IP
|
|
Inside this file are attributes to this interface, such as its IP
|
|
address(es), subnet masks, and so forth. It is necessary that the stem of
|
|
address(es), subnet masks, and so forth. It is necessary that the stem of
|
|
- the filename be <emphasis>ifconfig</emphasis>.</para>
|
|
|
|
-
|
|
|
|
- <note><para>If the procedure in the previous section was not used, Udev
|
|
|
|
|
|
+ the filename be <emphasis>ifconfig</emphasis>.</para-->
|
|
|
|
+ <para>负责网络的启动脚本根据
|
|
|
|
+ <filename class="directory">/etc/sysconfig</filename> 中配置文件的内容,
|
|
|
|
+ 决定应该启用或禁用哪些网络接口。对于每个需要配置的网络接口,
|
|
|
|
+ 该目录中都应该包含一个文件,文件名类似
|
|
|
|
+ <filename>ifconfig.xyz</filename>,
|
|
|
|
+ 这里<quote>xyz</quote>应该能够描述该网卡,
|
|
|
|
+ 使用接口名(如 eth0)一般比较合适。
|
|
|
|
+ 文件内部是该网络接口的属性,如 IP 地址、子网掩码等。
|
|
|
|
+ 文件名必须以 <emphasis>ifconfig</emphasis> 开头。</para>
|
|
|
|
+
|
|
|
|
+ <!--note><para>If the procedure in the previous section was not used, Udev
|
|
will assign network card interface names based on system physical
|
|
will assign network card interface names based on system physical
|
|
characteristics such as enp2s1. If you are not sure what your interface
|
|
characteristics such as enp2s1. If you are not sure what your interface
|
|
name is, you can always run <command>ip link</command> or <command>ls
|
|
name is, you can always run <command>ip link</command> or <command>ls
|
|
/sys/class/net</command> after you have booted your system.
|
|
/sys/class/net</command> after you have booted your system.
|
|
- </para></note>
|
|
|
|
|
|
+ </para></note-->
|
|
|
|
+ <note><para>如果没有使用前一节描述的自定义命名策略,
|
|
|
|
+ udev 会根据系统物理特征命名网卡接口,例如 enp2s1。
|
|
|
|
+ 如果您不能确定接口名,可以在引导您的 LFS 系统后使用
|
|
|
|
+ <command>ip link</command> 或 <command>ls /sys/class/net</command>
|
|
|
|
+ 命令确认。</para></note>
|
|
|
|
|
|
- <para>The following command creates a sample file for the
|
|
|
|
- <emphasis>eth0</emphasis> device with a static IP address:</para>
|
|
|
|
|
|
+ <para>作为示例,以下命令为
|
|
|
|
+ <emphasis>eth0</emphasis> 设备创建一个静态 IP 地址配置:</para>
|
|
|
|
|
|
<screen><userinput>cd /etc/sysconfig/
|
|
<screen><userinput>cd /etc/sysconfig/
|
|
cat > ifconfig.eth0 << "EOF"
|
|
cat > ifconfig.eth0 << "EOF"
|
|
@@ -58,32 +72,46 @@ PREFIX=24
|
|
BROADCAST=192.168.1.255</literal>
|
|
BROADCAST=192.168.1.255</literal>
|
|
EOF</userinput></screen>
|
|
EOF</userinput></screen>
|
|
|
|
|
|
- <para>The values of these variables must be changed in every file to match
|
|
|
|
- the proper setup.</para>
|
|
|
|
|
|
+ <para>您必须修改文件中的变量,使配置与您的网络环境相匹配。</para>
|
|
|
|
|
|
- <para>If the <envar>ONBOOT</envar> variable is set to <quote>yes</quote> the
|
|
|
|
|
|
+ <!--para>If the <envar>ONBOOT</envar> variable is set to <quote>yes</quote> the
|
|
System V network script will bring up the Network Interface Card (NIC) during
|
|
System V network script will bring up the Network Interface Card (NIC) during
|
|
booting of the system. If set to anything but <quote>yes</quote> the NIC
|
|
booting of the system. If set to anything but <quote>yes</quote> the NIC
|
|
will be ignored by the network script and not be automatically brought up.
|
|
will be ignored by the network script and not be automatically brought up.
|
|
The interface can be manually started or stopped with the
|
|
The interface can be manually started or stopped with the
|
|
- <command>ifup</command> and <command>ifdown</command> commands.</para>
|
|
|
|
-
|
|
|
|
- <para>The <envar>IFACE</envar> variable defines the interface name,
|
|
|
|
|
|
+ <command>ifup</command> and <command>ifdown</command> commands.</para-->
|
|
|
|
+ <para>如果 <envar>ONBOOT</envar> 变量被设置为<quote>yes</quote>,
|
|
|
|
+ 则 System V 网络脚本会在引导系统时启用该网络接口卡(NIC)。
|
|
|
|
+ 否则,网络脚本会忽略该 NIC,不自动启用它。
|
|
|
|
+ 您可以使用 <command>ifup</command> 和 <command>ifdown</command>
|
|
|
|
+ 命令,手动启用或禁用网络接口。</para>
|
|
|
|
+
|
|
|
|
+ <!--para>The <envar>IFACE</envar> variable defines the interface name,
|
|
for example, eth0. It is required for all network device configuration
|
|
for example, eth0. It is required for all network device configuration
|
|
- files. </para>
|
|
|
|
|
|
+ files. </para-->
|
|
|
|
+ <para><envar>IFACE</envar> 变量指定网络接口名,例如 eth0。
|
|
|
|
+ 所有网络设备配置文件都需要它。</para>
|
|
|
|
|
|
- <para>The <envar>SERVICE</envar> variable defines the method used for
|
|
|
|
|
|
+ <!--para>The <envar>SERVICE</envar> variable defines the method used for
|
|
obtaining the IP address. The LFS-Bootscripts package has a modular IP
|
|
obtaining the IP address. The LFS-Bootscripts package has a modular IP
|
|
assignment format, and creating additional files in the <filename
|
|
assignment format, and creating additional files in the <filename
|
|
class="directory">/lib/services/</filename> directory allows other IP
|
|
class="directory">/lib/services/</filename> directory allows other IP
|
|
assignment methods. This is commonly used for Dynamic Host Configuration
|
|
assignment methods. This is commonly used for Dynamic Host Configuration
|
|
- Protocol (DHCP), which is addressed in the BLFS book.</para>
|
|
|
|
-
|
|
|
|
- <para>The <envar>GATEWAY</envar> variable should contain the default
|
|
|
|
|
|
+ Protocol (DHCP), which is addressed in the BLFS book.</para-->
|
|
|
|
+ <para><envar>SERVICE</envar> 变量定义获取 IP 地址的方法。
|
|
|
|
+ LFS-Bootscripts 软件包使用模块化 IP 分配格式,在
|
|
|
|
+ <filename class="directory">/lib/services/</filename>
|
|
|
|
+ 目录中新建一些文件,即可使用其他 IP 分配方法,这一般被用于
|
|
|
|
+ 动态主机配置协议(DHCP)配置,具体方法在 BLFS 手册中说明。</para>
|
|
|
|
+
|
|
|
|
+ <!--para>The <envar>GATEWAY</envar> variable should contain the default
|
|
gateway IP address, if one is present. If not, then comment out the
|
|
gateway IP address, if one is present. If not, then comment out the
|
|
- variable entirely.</para>
|
|
|
|
|
|
+ variable entirely.</para-->
|
|
|
|
+ <para>如果默认网关存在,
|
|
|
|
+ <envar>GATEWAY</envar> 变量应该包含默认网关的 IP 地址。
|
|
|
|
+ 如果默认网关不存在,应该将这一行完全注释掉。</para>
|
|
|
|
|
|
- <para>The <envar>PREFIX</envar> variable contains the number of
|
|
|
|
|
|
+ <!--para>The <envar>PREFIX</envar> variable contains the number of
|
|
bits used in the subnet. Each octet in an IP address is 8 bits. If the
|
|
bits used in the subnet. Each octet in an IP address is 8 bits. If the
|
|
subnet's netmask is 255.255.255.0, then it is using the first three octets
|
|
subnet's netmask is 255.255.255.0, then it is using the first three octets
|
|
(24 bits) to specify the network number. If the netmask is 255.255.255.240,
|
|
(24 bits) to specify the network number. If the netmask is 255.255.255.240,
|
|
@@ -91,53 +119,61 @@ EOF</userinput></screen>
|
|
commonly used by DSL and cable-based Internet Service Providers (ISPs).
|
|
commonly used by DSL and cable-based Internet Service Providers (ISPs).
|
|
In this example (PREFIX=24), the netmask is 255.255.255.0. Adjust the
|
|
In this example (PREFIX=24), the netmask is 255.255.255.0. Adjust the
|
|
<envar>PREFIX</envar> variable according to your specific subnet.
|
|
<envar>PREFIX</envar> variable according to your specific subnet.
|
|
- If omitted, the PREFIX defaults to 24.</para>
|
|
|
|
-
|
|
|
|
- <para>For more information see the <command>ifup</command> man page.</para>
|
|
|
|
|
|
+ If omitted, the PREFIX defaults to 24.</para-->
|
|
|
|
+ <para><envar>PREFIX</envar> 变量应该包含子网使用的 IP 地址位数。
|
|
|
|
+ IP 地址中的每一段都是二进制为 8 位的数,如果子网掩码是
|
|
|
|
+ 255.255.255.0,说明 IP 地址中前三段(24 位)表示子网编号。如果子网掩码是
|
|
|
|
+ 255.255.255.240,则使用了前 28 位表示子网编号。
|
|
|
|
+ 子网前缀比 24 长的情况一般见于基于 DSL 或同轴电缆的 Internet 服务提供商
|
|
|
|
+ (ISP)。在我们的例子中,子网掩码是 255.255.255.0。
|
|
|
|
+ 您应该根据您所处的子网调整 <envar>PREFIX</envar> 变量。
|
|
|
|
+ 如果不指定它,则它默认为 24。</para>
|
|
|
|
+
|
|
|
|
+ <para>参考 <command>ifup</command> 的 man 页面获得更多信息。</para>
|
|
|
|
|
|
</sect2>
|
|
</sect2>
|
|
<sect2 id="resolv.conf">
|
|
<sect2 id="resolv.conf">
|
|
- <title>Creating the /etc/resolv.conf File</title>
|
|
|
|
|
|
+ <title>创建 /etc/resolv.conf 文件</title>
|
|
|
|
|
|
<indexterm zone="resolv.conf">
|
|
<indexterm zone="resolv.conf">
|
|
<primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
|
|
<primary sortas="e-/etc/resolv.conf">/etc/resolv.conf</primary>
|
|
</indexterm>
|
|
</indexterm>
|
|
|
|
|
|
- <para>The system will need some means of obtaining 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>. Create the file by running the
|
|
|
|
- following:</para>
|
|
|
|
|
|
+ <para>系统需要某种方式,获取域名服务(DNS),
|
|
|
|
+ 以将 Internet 域名解析成 IP 地址,或进行反向解析。
|
|
|
|
+ 为了达到这一目的,最好的方法是将 ISP 或网络管理员提供的 DNS
|
|
|
|
+ 服务器的 IP 地址写入
|
|
|
|
+ <filename>/etc/resolv.conf</filename>。执行下列命令创建该文件:</para>
|
|
|
|
|
|
<screen><userinput>cat > /etc/resolv.conf << "EOF"
|
|
<screen><userinput>cat > /etc/resolv.conf << "EOF"
|
|
<literal># Begin /etc/resolv.conf
|
|
<literal># Begin /etc/resolv.conf
|
|
|
|
|
|
-domain <replaceable><Your Domain Name></replaceable>
|
|
|
|
-nameserver <replaceable><IP address of your primary nameserver></replaceable>
|
|
|
|
-nameserver <replaceable><IP address of your secondary nameserver></replaceable>
|
|
|
|
|
|
+domain <replaceable><您的域名></replaceable>
|
|
|
|
+nameserver <replaceable><您的主要域名服务器 IP 地址></replaceable>
|
|
|
|
+nameserver <replaceable><您的次要域名服务器 IP 地址></replaceable>
|
|
|
|
|
|
# End /etc/resolv.conf</literal>
|
|
# End /etc/resolv.conf</literal>
|
|
EOF</userinput></screen>
|
|
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><IP address of the nameserver></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><域名服务器的 IP 地址></replaceable>
|
|
|
|
+ 替换为您的网络环境下最合适的 DNS 服务器 IP 地址。
|
|
|
|
+ 这里往往会写入不止一个 DNS 服务器(需要提供后备功能的次要服务器)。
|
|
|
|
+ 如果您只需要或只希望使用一个 DNS 服务器,可以删除文件中的第二个
|
|
|
|
+ <emphasis>nameserver</emphasis> 行。也可以写入本地路由器的 IP 地址。
|
|
|
|
+ </para>
|
|
|
|
|
|
<note>
|
|
<note>
|
|
- <para>The Google Public IPv4 DNS addresses are 8.8.8.8 and 8.8.4.4.</para>
|
|
|
|
|
|
+ <para>Google 公用 DNS 服务器的 IP 地址是 8.8.8.8 和 8.8.4.4。</para>
|
|
</note>
|
|
</note>
|
|
|
|
|
|
</sect2>
|
|
</sect2>
|
|
|
|
|
|
- <sect2 id="ch-scripts-hostname">
|
|
|
|
|
|
+ <!--sect2 id="ch-scripts-hostname">
|
|
<title>Configuring the system hostname</title>
|
|
<title>Configuring the system hostname</title>
|
|
|
|
|
|
<indexterm zone="ch-scripts-hostname">
|
|
<indexterm zone="ch-scripts-hostname">
|
|
@@ -158,9 +194,9 @@ EOF</userinput></screen>
|
|
(FQDN) here. That information is put in the
|
|
(FQDN) here. That information is put in the
|
|
<filename>/etc/hosts</filename> file.</para>
|
|
<filename>/etc/hosts</filename> file.</para>
|
|
|
|
|
|
- </sect2>
|
|
|
|
|
|
+ </sect2-->
|
|
|
|
|
|
- <sect2 id="ch-scripts-hosts">
|
|
|
|
|
|
+ <!--sect2 id="ch-scripts-hosts">
|
|
<title>Customizing the /etc/hosts File</title>
|
|
<title>Customizing the /etc/hosts File</title>
|
|
|
|
|
|
<indexterm zone="ch-scripts-hosts">
|
|
<indexterm zone="ch-scripts-hosts">
|
|
@@ -222,7 +258,17 @@ EOF</userinput></screen>
|
|
<replaceable><HOSTNAME></replaceable> values need to be
|
|
<replaceable><HOSTNAME></replaceable> values need to be
|
|
changed for specific uses or requirements (if assigned an IP address by a
|
|
changed for specific uses or requirements (if assigned an IP address by a
|
|
network/system administrator and the machine will be connected to an
|
|
network/system administrator and the machine will be connected to an
|
|
- existing network). The optional alias name(s) can be omitted.</para>
|
|
|
|
|
|
+ existing network). The optional alias name(s) can be omitted.</para-->
|
|
|
|
+
|
|
|
|
+<!-- TRANSLATE: I didn't translate the same thing again. Just include
|
|
|
|
+ the systemd version. -->
|
|
|
|
+
|
|
|
|
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
+ href="networkd.xml"
|
|
|
|
+ xpointer="xpointer(//*[@id='ch-scripts-hostname'])"/>
|
|
|
|
+<xi:include xmlns:xi="http://www.w3.org/2001/XInclude"
|
|
|
|
+ href="networkd.xml"
|
|
|
|
+ xpointer="xpointer(//*[@id='ch-scripts-hosts'])"/>
|
|
|
|
|
|
<!-- This is not very useful
|
|
<!-- This is not very useful
|
|
|
|
|
|
@@ -241,6 +287,6 @@ ff02::2 ip6-allrouters
|
|
# End /etc/hosts (no network card version)</literal>
|
|
# End /etc/hosts (no network card version)</literal>
|
|
EOF</userinput></screen> -->
|
|
EOF</userinput></screen> -->
|
|
|
|
|
|
- </sect2>
|
|
|
|
|
|
+ <!--/sect2-->
|
|
|
|
|
|
</sect1>
|
|
</sect1>
|