From Gentoo Wiki
Jump to: navigation, search
This page is a translated version of the page Wifi and the translation is 100% complete.

Other languages:
English • ‎español • ‎русский • ‎中文(中国大陆)‎ • ‎日本語 • ‎한국어




如果Gentoo最小安装光盘没有包含您需要设置的网卡驱动或者您需要wpa_supplicant的图形界面来设置,可以选择其他的live CD,例如System Rescue CD。需要提醒一下的是当使用non-Gentoo live CD的时候可能需要这些特殊步骤


首先检测wifi驱动。lspci 或者 lsusb这两个命令能查看到相应的wifi驱动。

如果是你的wifi能够在Linux LiveCD或者USB连接成功:

root #lspci -k

则你的驱动能在相应的以Kernel driver in use:开头的输出信息中找到。


root #lspci -n



user $lsusb

这个命令会生成对应的PCI ID,生产商(manufacturer),make,模型(model),还有USB设备对应的系统的芯片组(chipset)。在所有的信息中,可能芯片组(chipset)是最有用的信息。Google搜索一下"linuxwireless.org <对应的chipset>" 通常是最找到对应的USB NIC驱动和固件(firmware)名字的最快方式。


root #lshw | grep -i driver




IEEE 802.11

Activate at least cfg80211 and mac80211.

KERNEL linux-4.1
[*] 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 and its 802.11n support is a rate control algorithm. Some wireless drivers might require it enabled.


The "cfg80211 wireless extensions compatibility" option aka WEXT will support old wireless-tools and 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.



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.



Network device names such as eth0 or wlan0 as provided by the kernel are normally changed on system boot (see dmesg) by the /lib/udev/rules.d/80-net-name-slot.rules udev rule.

To keep the classic naming this rule can be overwritten with an equally named empty file in the /etc/udev/rules.d directory:

root #touch /etc/udev/rules.d/80-net-name-slot.rules

WPA supplicant

如果用WPA或WPA2设置无线网络设, then wpa_supplicant needs to be used. For more information on configuring wireless networking in Gentoo Linux, please read the Wireless networking chapter in the Gentoo Handbook.


After a reboot with the new kernel or after loading the modules, the device can be checked for availability by using following methods:

/sys 文件系统

通过使用 ls -altree 命令(由app-text/tree 包提供))列出 /sys/class/net 目录内容来获取设备名称:

user $tree /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


To obtain the device name and verify that the wireless card is detected, execute the following ip command:

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).


If the wireless network card driver supports the nl80211 stack, then the iw command as offered by the net-wireless/iw package can show the detected wireless cards:

root #iw dev
	Interface wlan0
		ifindex 4
		type managed


检查 dmesg 的输出。

user $dmesg | grep -i -E 'xx:xx.x|wlan|iwl|80211'

Be sure to replace