Handbook:Parts/Installation/Networking/zh-cn

自动网络检测
它能够自动检测到么？

如果系统接入到一个有DHCP服务器的以太网络，网络配置非常可能会自动设置. 这样的话，安装CD所包含的很多网络命令，比如、、、、、，以及其他的一些, 都将立即可以工作.

如果网络被配置过，命令将会围绕着lo列出一些网络接口，比如：

系统的接口名字可以和很不一样. 近期的安装媒介可能显示常规网络接口名字像是、或. 只要在输出中找到有你本地网络相关的IP地址的接口.

在本文档的其余部分，我们假设接口叫作.

可选：配置代理
如果要通过代理访问互联网，则在安装过程中需要设置代理信息. 定义一个代理十分容易：只需要定义一个包含代理服务器信息的变量即可.

大多数情况下，只要将这个变量定义为代理服务器主机名. 作为示例，我们假定代理叫作proxy.gentoo.org并且端口为8080.

设置一个HTTP代理（用于HTTP或HTTPS流量）:

设置一个FTP代理：

设置一个RSYNC代理：

如果代理要求用户名和密码，针对变量使用下面语言：

测试网络
尝试ping你的ISP的DNS服务器（可在中找到）和选择一个网站. 这可确信网络正常工作并且网络包可以到达网络，DNS域名能正常解析等等.

如果这些都工作，则本章节中其余的部分可跳过，直接跳到安装介绍的下一步骤（准备磁盘）.

自动网络配置
如果网络没有立即工作，一些安装媒介允许用户使用（针对常规或无线网络），（针对ADSL用户）或（针对PPTP用户）.

如果安装媒介没有包含这些工具，继续手动配置网络.


 * 常规以太网用户应该继续默认：使用net-setup
 * ADSL用户应该继续备选：使用PPP
 * PPTP用户应该继续备选：使用PPTP

默认：使用net-setup
如果网络没有自动配置，最简单的方式是运行脚本来设置：

将会询问关于网络环境的一些问题. 当所有这些完成后，网络连接就应该工作. 以前面的方式测试网络连接. 如果测试通过，恭喜！跳过本章节剩余部分并继续准备磁盘.

如果网络还是不能工作，继续手动配置网络.

可选：使用PPP
假设需要使用PPPoE连接到互联网，安装CD（任何版本）包含ppp来使这件事变得容易. 使用提供的脚本来配置连接. 设置过程中将询问已连接到你的ADSL调制解调器的以太网设备、用户名和密码、DNS服务器的IP地址，以及是否需要一个简单的防火墙.

如果还是有什么错误，再次在或中检查用户名和密码都是正确的，并且确保使用了正确的以太网设备. 如果以太网设备不存在，则需要加载合适的网络模块. 如果是那样，继续手动网络配置将解释如何加载合适的网络模块.

如果所有事都还，继续准备磁盘.

可选：使用PPTP
如果需要PPTP支持，使用安装CD提供的. 但是首先确保配置是正确的. 编辑或让它包含正确的用户名/密码组合：

如果需要，继续调整：

当所有事都已完成，运行（带着一些无法设定的选项）来连接到服务器：

现在继续准备磁盘.

加载适当的网络模块
安装光盘在启动时，会尝试检测所有硬件设备并加载适当的内核模块（驱动程序）以支持你的硬件. 绝大多数情况下，它都做得非常好. 尽管如此，在某些情况下它可能还是无法自动载入你所需要的内核模块.

如果或都失败，则可能是网络没有立即被找到. 也就是说用户可能需要手动加载合适的内核模块.

要找出什么内核模块提供网络，使用命令：

如果找到一个针对网络设备的驱动，使用来加载内核模块. 比如，要加载模块：

要检查网卡现在是否检测到，使用. 一个检测到的网卡应该在结果中像这样（再一次，这里的只是一个示例）：

不过如果你得到如下错误信息，说明没有检测到网卡：

系统中可用网络接口命名可以通过文件系统列出.

在上面的示例中，找到了6个接口. 是最像（有线）以太网络适配器，而wlan0是无线的.

假设现在网络已经检测到了，重新尝试或（现在应该工作了），但是对于铁杆的人，我们还是要解释如何手动配置网络.

Select one of the following sections based on your network setup:


 * Using DHCP for automatic IP retrieval
 * Preparing for wireless access if a wireless network is used
 * Understanding network terminology explains the basics about networking
 * Using ifconfig and route explains how to set up networking manually

使用DHCP
DHCP (Dynamic Host Configuration Protocol) makes it possible to automatically receive networking information (IP address, netmask, broadcast address, gateway, nameservers etc.). This only works if a DHCP server is in the network (or if the ISP provider provides a DHCP service). To have a network interface receive this information automatically, use :

一些网络管理员要求你使用DHCP服务器所提供的主机名和域名. 这种情况下请用：

If this works (try pinging some Internet server, like Google), then everything is set and ready to continue. Skip the rest of this section and continue with Preparing the disks.

准备无线网络链接
When using a wireless (802.11) card, the wireless settings need to be configured before going any further. To see the current wireless settings on the card, one can use. Running might show something like:

For most users, there are only two settings that might be important to change, the ESSID (aka wireless network name) or the WEP key. If the ESSID and Access Point address listed are already those of the environment's access point and the environment is not not using WEP, then the wireless configuration is already working.

To change the ESSID, or add a WEP key, issue the following commands.


 * To set the network name to GentooNode:




 * To set a hex WEP key:




 * To set an ASCII WEP key, prefix the key with :



Confirm the wireless settings again by using. Once wireless is working,continue configuring the IP level networking options as described in the next section (Understanding network terminology) or use the tool as described previously.

网络术语解读
如果以上所做的全部失败，你将不得不手动配置你的网络. 这其实一点也不难. 不过，你需要熟悉一些网络术语，才能配置好网络令自己满意. 读完本节之后，你将了解到什么是网关，子网掩码是作什么用的，广播地址是如何形成的，以及为什么需要域名服务器.

In a network, hosts are identified by their IP address (Internet Protocol address). Such an address is perceived as a combination of four numbers between 0 and 255. Well, at least when using IPv4 (IP version 4). In reality, such an IPv4 address consists of 32 bits (ones and zeros). Let's view an example:

在所有可访问到的网络里，这样的IP地址跟主机是一一对应的（比如你能够连接到的每台主机必须拥有一个唯一的IP地址）. 为了区别一个网络内部和外部的主机，IP地址被分为两个部分：网络部分和主机部分.

The separation is written down with the netmask, a collection of ones followed by a collection of zeros. The part of the IP that can be mapped on the ones is the network-part, the other one is the host-part. As usual, the netmask can be written down as an IP address.

In other words, 192.168.0.14 is part of the example network, but 192.168.1.2 is not.

The broadcast address is an IP address with the same network-part as the network, but with only ones as host-part. Every host on the network listens to this IP address. It is truly meant for broadcasting packets.

To be able to surf on the Internet, each computer in the network must know which host shares the Internet connection. This host is called the gateway. Since it is a regular host, it has a regular IP address (for instance 192.168.0.1).

Previously we stated that every host has its own IP address. To be able to reach this host by a name (instead of an IP address) we need a service that translates a name (such as dev.gentoo.org) to an IP address (such as 64.5.62.82). Such a service is called a name service. To use such a service, the necessary name servers need to be defined in.

In some cases, the gateway also serves as a nameserver. Otherwise the nameservers provided by the ISP need to be entered in this file.

To summarize, the following information is needed before continuing:

使用ifconfig和route
Setting up the network consists of three steps:


 * 1) Assign an IP address using
 * 2) Set up routing to the gateway using
 * 3) Finish up by placing the nameserver IPs in

To assign an IP address, the IP address, broadcast address and netmask are needed. Then execute the following command, substituting ${IP_ADDR} with the right IP address, ${BROADCAST} with the right broadcast address and ${NETMASK} with the right netmask:

Set up routing using. Substitute ${GATEWAY} with the right gateway IP address:

Now open :

Fill in the nameserver(s) using the following as a template. Make sure to substitute ${NAMESERVER1} and ${NAMESERVER2} with the appropriate nameserver addresses:

That's it. Now test the network by pinging some Internet server (like Google). If this works, congratulations then. Continue with Preparing the disks.