Handbook:Parts/Installation/Networking/zh-cn

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

If the system is plugged into an Ethernet network with a DHCP server, it is very likely that the networking configuration has already been set up automatically. If so, then the many included network-aware commands on the installation CD such as, , , , , and , among others, will work immediately.

If networking has been configured, the command should list some network interfaces besides lo, such as :

The interface name on the system can be quite different from. Recent installation media might show regular network interfaces names like, , or. Just seek the interface in the output that has an IP address related to the local network.

In the remainder of this document, we will assume that the interface is called.

可选:配置代理服务器
如果你是通过代理访问网络，就要在安装过程中设置代理信息. 设置代理很容易：只要定义一个包含代理服务器信息的变量即可.

通常情况下只要将这个变量定义为代理服务器主机名. 作为例子，我们假定代理名叫proxy.gentoo.org，端口为8080.

建立一个HTTP代理(HTTP或HTTPS):

设置FTP代理:

设置RSYNC代理:

如果代理要求用户名和密码，请使用以下格式的变量：

测试网络
Try pinging your ISP's DNS server (found in ) and a web site of choice. This ensures that the network is functioning properly and that the network packets are reaching the net, DNS name resolution is working correctly, etc.

If this all works, then the remainder of this chapter can be skipped to jump right to the next step of the installation instructions (Preparing the disks).

自动网络配置
If the network doesn't work immediately, some installation media allow the user to use (for regular or wireless networks),  (for ADSL users) or  (for PPTP users).

If the installation medium does not contain any of these tools, continue with the Manual network configuration.


 * Regular Ethernet users should continue with Default: Using net-setup
 * ADSL users should continue with Alternative: Using PPP
 * PPTP users should continue with Alternative: Using PPTP

默认：使用net-setup
The simplest way to set up networking if it didn't get configured automatically is to run the script:

will ask some questions about the network environment. When all is done, the network connection should work. Test the network connection as stated before. If the tests are positive, congratulations! Skip the rest of this section and continue with Preparing the disks.

If the network still doesn't work, continue with Manual network configuration.

可选：使用PPP
Assuming PPPoE is needed to connect to the Internet, the installation CD (any version) has made things easier by including ppp. Use the provided script to configure the connection. During the setup the Ethernet device that is connected to your ADSL modem, the username and password, the IPs of the DNS servers and if a basic firewall is needed or not will be asked.

If something goes wrong, double-check that the username and password are correct by looking at or  and make sure to use the right Ethernet device. If the Ethernet device does not exist, the appropriate network modules need to be loaded. In that case continue with Manual network configuration as it will explain how to load the appropriate network modules there.

If everything worked, continue with Preparing the disks.

可选：使用PPTP
If PPTP support is needed, use which is provided by the installation CDs. But first make sure that the configuration is correct. Edit or  so it contains the correct username/password combination:

Then adjust if necessary:

When all that is done, run (along with the options that couldn't be set in ) to connect the server:

Now continue with Preparing the disks.

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

If or  failed, then it is possible that the network card wasn't found immediately. This means users may have to load the appropriate kernel modules manually.

To find out what kernel modules are provided for networking, use the command:

If a driver is found for the network device, use to load the kernel module. For instance, to load the module:

To check if the network card is now detected, use. A detected network card would result in something like this (again, here is just an example):

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

The available network interface names on the system can be listed through the file system:

In the above example, 6 interfaces are found. The one is most likely the (wired) Ethernet adapter whereas wlan0 is the wireless one.

Assuming that the network card is now detected, retry or  again (which should work now), but for the hardcore people we explain how to configure the network manually as well.

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.