WiFi
Warning: Display title "WiFi" overrides earlier display title "无线网络(Wifi)".
这篇文章介绍了 wifi (无线)网卡的设置
安装系统时的WiFi设置
如果在安装Gentoo过程中需要设置WiFi连接,需要提醒一下的是Gentoo最小安装光盘只支持一部分的无线网卡驱动,并且只提供wpa_cli命令(不提供wpa_gui)来设置WPA/WPA2/Enterprise等无线连接。
如果Gentoo最小安装光盘没有包含您需要设置的网卡驱动或者您需要 wpa_supplicant 的图形界面来设置,可以选择其他的live CD,例如System Rescue CD。需要提醒一下的是当使用non-Gentoo live CD的时候可能需要这些特殊步骤。
硬件检测
如果是你的wifi能够在Linux LiveCD或者USB连接成功:
root #
lspci -k
则你的驱动能在相应的以Kernel driver in use:
开头的输出信息中找到。
如果你不能在启动盘中连接wifi,则需要保存当前系统所有的硬件信息列表。该列表能让你后面找到相对应的硬件驱动:
root #
lspci -n
复制以上命令输出的对应的PCIID部分,然后把它粘贴到 http://kmuto.jp/debian/hcl/。
对于USB网卡来说,过程也是大致相同的。首先拿到系统中所有的USB设备信息:
user $
lsusb
这个命令会生成对应的PCI ID,生产商(manufacturer),make,模型(model),还有USB设备对应的系统的芯片组(chipset)。在所有的信息中,可能芯片组(chipset)是最有用的信息。网上搜索一下 "linuxwireless.org <对应的chipset>" 通常是最找到对应的USB NIC驱动和固件 (firmware) 名字的最快方式。
另外,lshw也能用于获取相应的信息:
root #
lshw | grep -i driver | perl -pe 's/^.*driver=(\S+).*$/$1/g;' | sort -u
这个命令会生成所有驱动信息的列表,无论是PCI网卡还是USB网卡。
内核
确定了驱动程序之后,现在是配置Linux内核的时候了。
IEEE 802.11
[*] Networking support ---> [*] Wireless ---> <M/*> cfg80211 - wireless configuration API [ ] nl80211 testmode command [ ] enable developer warnings [ ] cfg80211 regulatory debugging [ ] cfg80211 certification onus [*] enable powersave by default [ ] cfg80211 DebugFS entries [ ] use statically compiled regulatory rules database [ ] cfg80211 wireless extensions compatibility <M/*> Generic IEEE 802.11 Networking Stack (mac80211) [*] Minstrel [*] Minstrel 802.11n support [ ] Minstrel 802.11ac support Default rate control algorithm (Minstrel) ---> [ ] Enable mac80211 mesh networking (pre-802.11s) support -*- Enable LED triggers [ ] Export mac80211 internals in DebugFS [ ] Trace all mac80211 debug messages [ ] Select mac80211 debugging features ----
Minstrel 和 its 802.11n 支持 rate control algorithm. 一些无线设备可能需要开启这个选项。
In case the wireless configuration API (CONFIG_CFG80211) is built into the kernel (
<*>
) instead as a module (<M>
), the driver won't be able to load regulatory.db from /lib/firmware resulting in broken regulatory domain support. Please set CONFIG_CFG80211=m or add regulatory.db and regulatory.db.p7s to CONFIG_EXTRA_FIRMWARE.
WEXT
"cfg80211 wireless extensions compatibility" 选项又称 WEXT 支持老旧的 无线工具和iwconfig.
[*] Networking support ---> [*] Wireless ---> [*] cfg80211 wireless extensions compatibility
设备驱动程序
接下来,需要根据先前检测到的驱动程序和硬件启用相应内核选项的正确集合。 The recommendation is to build drivers as modules. 如果无线网络使用WPA或WPA2加密,还要确保在内核中启用AES密码支持。
Device Drivers ---> [*] Network device support ---> [*] Wireless LAN ---> Select the driver for your Wifi network device, e.g.: <M> Broadcom 43xx wireless support (mac80211 stack) (b43) [M] Support for 802.11n (N-PHY) devices [M] Support for low-power (LP-PHY) devices [M] Support for HT-PHY (high throughput) devices <M> Intel Wireless WiFi Next Gen AGN - Wireless-N/Advanced-N/Ultimate-N (iwlwifi) <M> Intel Wireless WiFi DVM Firmware support <M> Intel Wireless WiFi MVM Firmware support <M> Intel Wireless WiFi 4965AGN (iwl4965) <M> Intel PRO/Wireless 3945ABG/BG Network Connection (iwl3945) <M> Ralink driver support ---> <M> Ralink rt27xx/rt28xx/rt30xx (USB) support (rt2800usb) -*- Cryptographic API ---> -*- AES cipher algorithms -*- AES cipher algorithms (x86_64) <*> AES cipher algorithms (AES-NI)
In case the driver is built into the kernel (
<*>
) instead of as a module (<M>
), then the firmware needs to be built into the kernel as well.
Do not forget to rebuild the kernel after changing its configuration.
LED支持
要启用不同数据包接收/发送事件的LED触发器,请使用以下选项编译内核:
Device Drivers ---> [*] LED Support ---> <*> LED Class Support [*] Networking support ---> [*] Wireless ---> [*] Enable LED triggers
硬件
除了内核驱动程序,一些芯片组还需要固件。如果需要,请在以下列表中找到它并安装它:
root #
emerge --ask sys-kernel/linux-firmware
Wifi device | Driver | Firmware | Note |
---|---|---|---|
Atheros AR9271 & AR7010 | ath9k_htc | sys-kernel/linux-firmware | |
Broadcom 43xx wireless support | b43 / b43legacy | sys-firmware/b43-firmware | Aircrack-ng ready, most probably the best choice if your bcm43xx device is supported |
Broadcom PCIe and SDIO/USB devices | brcmsmac / brcmfmac | sys-kernel/linux-firmware | Lacks powersaving, LED support and other features |
Broadcom 43xx wireless support | wl | net-wireless/broadcom-sta | Proprietary, no AP or Monitor modes, Comparison of bcm43xx drivers |
Intel PRO/Wireless 2200BG | ipw2200 | sys-firmware/ipw2200-firmware | |
Intel PRO/Wireless 3945ABG/BG | iwlegacy | sys-kernel/linux-firmware | |
Intel Wireless WiFi 4965AGN | iwl4965 | sys-kernel/linux-firmware | |
All other Intel Wireless devices | iwlwifi | sys-kernel/linux-firmware | See the iwlwifi article for detailed instructions. |
Qualcomm Atheros QCA6174 | ath10k_pci | ath10k-firmware | See Qualcomm_Atheros_QCA6174#Firmware |
Ralink/MediaTek USB devices | e.g. rt2800usb | sys-kernel/linux-firmware | |
Realtek RTL8191SE & RTL8192SE | rtl8192se | sys-kernel/linux-firmware | |
Realtek 8723AU/8723BU/8191EU/8192EU/8188EU/8188RU | rtl8xxxu | sys-kernel/linux-firmware | May need the CONFIG_RTL8XXXU_UNTESTED kernel option to find all devices. Only those verified by kernel developers are enabled by default. |
如果驱动所需固件没有在列表中,那么需要您手动去下载并把它放在/lib/firmware下。
网络设备名称
内核提供的网络设备名称列入eth0 或 wlan0 等通常可以通过 /lib/udev/rules.d/80-net-name-slot.rules udev 规则在系统启动时更改参见 dmesg 。
为了保持传统命名,这个规则可以用 /etc/udev/rules.d 目录中用同样命名的空文件覆盖:
root #
touch /etc/udev/rules.d/80-net-name-slot.rules
WPA supplicant
如果用WPA或WPA2设置无线网络, 需要使用 wpa_supplicant。若要获取更多在 Gentoo Linux 中配置无线网络的信息,请阅读 Gentoo 手册中的无线网络章节。
测试
使用新内核重新引导后或加载模块后,可以使用以下方法检查设备的可用性:
- Using the /sys 文件系统
- Using the ip 命令
- Using the ifconfig 命令
- Using the iw 命令
/sys 文件系统
通过使用 ls -al 或 tree 命令(由app-text/tree 包提供))列出 /sys/class/net 目录内容来获取设备名称:
user $
tree /sys/class/net
/sys/class/net/ ├── enp2s14 -> ../../devices/pci0000:00/0000:00:1e.0/0000:02:0e.0/net/enp2s14 ├── lo -> ../../devices/virtual/net/lo ├── sit0 -> ../../devices/virtual/net/sit0 └── wlp8s0 -> ../../devices/pci0000:00/0000:00:1c.0/0000:08:00.0/net/wlp8s0
ip命令
要获取设备名称并验证是否检测到无线网卡,执行下面的 ip 命令:
user $
ip addr
3: wlan0: ...
ifconfig 命令
ifconfig 命令是 sys-apps/net-tools 包提供的。使用 ifconfig -a 列出所有检测到的网卡,包括那些尚未启用/尚未活动的网卡:
user $
ifconfig -a
wlan0 ...
网卡可以用下面的方法激活:
root #
ifconfig -v wlan0 up
SIOCSIFFLAGS: Operation not possible due to RF-kill WARNING: at least one error occurred. (-1)
In this example, enabling the wireless card failed as a radio frequency kill state is set (usually to keep power consumption at bay and not connect by accident to a wireless network).
iw命令
如果无线网卡支持 nl80211 stack,net-wireless/iw 软件包提供的 iw 命令可以显示检测到的无线卡:
root #
iw dev
phy#0 Interface wlan0 ifindex 4 type managed
dmesg
检查 dmesg 的输出。
user $
dmesg | grep -i -E 'xx:xx.x|wlan|iwl|80211'
确保
- 用从 lspci 的标识符 (PCIID) 替换了
xx:xx.x
, - 网络接口名称 替换了
wlan
以及 - 用
Kernel driver in use
的名字替换了iwl
。
故障排除
- 论坛帖子:无线网络不能从 ap(access point) 中获取 ip 地址 解释了对于 169.254.x.x (链路本地地址) 是错误的IP地址
- 论坛帖子: iwlwifi 升级到 3.17.0 之后会加载失败
- 论坛帖子:我的网络在哪里!?
另请参阅
外部资源
- ArchLinux 无线网络配置