English Chinese (Simplified) (zh_CN)
Connecting a computer to an existing wireless network is a very common situation. This procedure shows the steps required. 将计算机连接到无线网络是十分常见的操作,本章将介绍如何将计算机连接到无线网络。
Add entries to [.filename]#/etc/rc.conf# to configure the network on startup: 接下来, 在 <filename>/etc/rc.conf</filename> 中, 我们将指定无线设备的配置, 令其采用 WPA, 并通过 DHCP 来获取 IP 地址:
To use wireless networking, a wireless networking card is needed and the kernel needs to be configured with the appropriate wireless networking support. The kernel is separated into multiple modules so that only the required support needs to be configured. 要使用无线网络, 您需要一块无线网卡, 并适当地配置内核令其提供无线网络支持。 后者被分成了多个模块, 因此您只需配置使用您所需要的软件就可以了。
if_ath_load="YES"
if_ath_load="YES"
if_wi_load="YES"
if_wi_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
wlan_wep_load="YES"
wlan_ccmp_load="YES"
wlan_tkip_load="YES"
device wlan # 802.11 support
device wlan_wep # 802.11 WEP support
device wlan_ccmp # 802.11 CCMP support
device wlan_tkip # 802.11 TKIP support
device wlan_amrr # AMRR transmit rate control algorithm
device ath # Atheros pci/cardbus NIC's
device ath_hal # pci/cardbus chip support
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
device ath_rate_sample # SampleRate tx rate control for ath
device wlan # 802.11 support
device wlan_wep # 802.11 WEP support
device wlan_ccmp # 802.11 CCMP support
device wlan_tkip # 802.11 TKIP support
device wlan_amrr # AMRR transmit rate control algorithm
device ath # Atheros pci/cardbus NIC's
device ath_hal # pci/cardbus chip support
options AH_SUPPORT_AR5416 # enable AR5416 tx/rx descriptors
device ath_rate_sample # SampleRate tx rate control for ath
Infrastructure (BSS) mode is the mode that is typically used. In this mode, a number of wireless access points are connected to a wired network. Each wireless network has its own name, called the SSID. Wireless clients connect to the wireless access points. 通常的情形中使用的是 infrastructure 模式或称 BSS 模式。 在这种模式中, 有一系列无线访问点接入了有线网络。 每个无线网都会有自己的名字, 这个名字称作网络的 SSID。 无线客户端都通过无线访问点来完成接入。
This information may be updated automatically by the adapter or manually with a `scan` request. Old data is automatically removed from the cache, so over time this list may shrink unless more scans are done. 这些信息可能会由无线适配器自动更新, 也可使用 <option>scan</option> 手动更新。 快取缓存中的旧数据会自动删除, 因此除非进行更多扫描, 这个列表会逐渐缩小。
This section provides a simple example of how to make the wireless network adapter work in FreeBSD without encryption. Once familiar with these concepts, it is strongly recommend to use <<network-wireless-wpa,WPA>> to set up the wireless network. 在这一节中我们将展示一个简单的例子来介绍如何让无线网络适配器在 FreeBSD 中以不加密的方式工作。 在您熟悉了这些概念之后, 我们强烈建议您在实际的使用中采用 <link linkend="network-wireless-wpa">WPA</link> 来配置网络。
There are three basic steps to configure a wireless network: select an access point, authenticate the station, and configure an IP address. The following sections discuss each step. 配置无线网络的过程可分为三个基本步骤: 选择无线访问点、 验证您的通讯站身份, 以及配置 IP 地址。 下面的几节中将分步骤地介绍它们。
Most of the time, it is sufficient to let the system choose an access point using the builtin heuristics. This is the default behavior when an interface is marked as up or it is listed in [.filename]#/etc/rc.conf#: 多数时候让系统以内建的探测方式选择无线访问点就可以了。 这是在您将网络接口置为 up 或在 <filename>/etc/rc.conf</filename> 中配置 IP 地址时的默认方式, 例如:
wlans_ath0="wlan0"
ifconfig_wlan0="DHCP"
wlans_ath0="wlan0"
ifconfig_wlan0="DHCP"
In an environment where there are multiple access points with the same SSID, which is often done to simplify roaming, it may be necessary to associate to one specific device. In this case, the BSSID of the access point can be specified, with or without the SSID: 在某些环境中, 多个访问点可能会使用同样的 SSID (通常, 这样做的目的是简化漫游), 这时可能就需要与某个具体的设备关联了。 这种情况下, 您还应指定无线访问点的 BSSID (这时可以不指定 SSID):
There are other ways to constrain the choice of an access point, such as limiting the set of frequencies the system will scan on. This may be useful for a multi-band wireless card as scanning all the possible channels can be time-consuming. To limit operation to a specific band, use the `mode` parameter: 除此之外, 还有一些其它的方法能够约束查找无线访问点的范围, 例如限制系统扫描的频段, 等等。 如果您的无线网卡支持多个频段, 这样做可能会非常有用, 因为扫描全部可用频段是一个十分耗时的过程。 要将操作限制在某个具体的频段, 可以使用 <option>mode</option> 参数; 例如:
Once an access point is selected, the station needs to authenticate before it can pass data. Authentication can happen in several ways. The most common scheme, open authentication, allows any station to join the network and communicate. This is the authentication to use for test purposes the first time a wireless network is setup. Other schemes require cryptographic handshakes to be completed before data traffic can flow, either using pre-shared keys or secrets, or more complex schemes that involve backend services such as RADIUS. Open authentication is the default setting. The next most common setup is WPA-PSK, also known as WPA Personal, which is described in <<network-wireless-wpa-wpa-psk>>. 一旦您选定了无线访问点, 您的通讯站就需要完成身份验证, 以便开始发送和接收数据。 身份验证可以通过许多方式进行, 最常用的一种方式称为开放式验证, 它允许任意通讯站加入网络并相互通信。 这种验证方式只应在您第一次配置无线网络进行测试时使用。 其它的验证方式则需要在进行数据通讯之前, 首先进行密钥协商握手; 这些方式要么使用预先分发的密钥或密码, 要么是用更复杂一些的后台服务, 如 RADIUS。 绝大多数用户会使用默认的开放式验证, 而第二多的则是 WPA-PSK, 它也称为个人 WPA, 在 <xref linkend="network-wireless-wpa-wpa-psk"/> 中将进行介绍。
WPA-PSK, also known as WPA Personal, is based on a pre-shared key (PSK) which is generated from a given password and used as the master key in the wireless network. This means every wireless user will share the same key. WPA-PSK is intended for small networks where the use of an authentication server is not possible or desired. WPA-PSK 也称作 个人-WPA, 它基于预先分发的密钥 (PSK), 这个密钥是根据作为无线网络上使用的主密钥的密码生成的。 这表示每个无线用户都会使用同样的密钥。 WPA-PSK 主要用于小型网络, 在这种网络中, 通常不需要或没有办法架设验证服务器。
network={
ssid="freebsdap"
psk="freebsdmall"
}
network={
ssid="freebsdap"
psk="freebsdmall"
}
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
wlans_ath0="wlan0"
ifconfig_wlan0="WPA DHCP"
# service netif start
Starting wpa_supplicant.
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
DHCPOFFER from 192.168.0.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.254 -- renewal in 300 seconds.
wlan0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUAL
<prompt>#</prompt> <userinput>service netif start</userinput>
Starting wpa_supplicant.
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 6
DHCPOFFER from 192.168.0.1
DHCPREQUEST on wlan0 to 255.255.255.255 port 67
DHCPACK from 192.168.0.1
bound to 192.168.0.254 -- renewal in 300 seconds.
wlan0: flags=8843&lt;UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST&gt; mtu 1500
ether 00:11:95:d5:43:62
inet 192.168.0.254 netmask 0xffffff00 broadcast 192.168.0.255
media: IEEE 802.11 Wireless Ethernet OFDM/36Mbps mode 11g
status: associated
ssid freebsdap channel 1 (2412 Mhz 11g) bssid 00:11:95:c3:0d:ac
country US ecm authmode WPA2/802.11i privacy ON deftxkey UNDEF
AES-CCM 3:128-bit txpower 21.5 bmiss 7 scanvalid 450 bgscan
bgscanintvl 300 bgscanidle 250 roam:rssi 7 roam:rate 5 protmode CTS
wme burst roaming MANUAL