網絡配置的主頁面是網絡配置。
配置無線網絡一般分兩步:第一步是識別硬體、安裝正確的驅動程序並進行配置,安裝盤中已經包含驅動,但是通常需要額外安裝;第二步是選擇一種管理無線連接的方式。這篇文章涵蓋了這兩方面,並提供了無線管理工具的連結地址。
#iw 段落描述了如何使用 iw包 來手動管理你的網絡接口/無線區域網連接。網絡配置#網絡管理器 段落介紹了幾個可以自動管理您無線網絡接口的程序。這些程序中的某些會包含一個圖形界面,而所有的程序都支持網絡配置文件(在頻繁切換網絡時有用,比如使用筆記本電腦的場合)。
設備驅動
默認的 Arch Linux 內核是模塊化的,硬體的設備驅動作為內核模塊保存在硬碟上。啟動時,udev 會根據硬體加載不同的驅動模塊,從而允許創建網絡接口。
除了相應的驅動程序之外,某些無線晶片組還需要固件。linux-firmware包 提供了很多固件,然而專有固件並不包含在內,需要另行安裝。這部分指南請參考 #安裝 driver/firmware。
檢查驅動狀態
根據設備的連接方式是 PCI(e) 或 USB,對應地執行 lspci -k
或 lsusb -v
可以檢查設備驅動是否已經加載:
$ lspci -k
06:00.0 Network controller: Intel Corporation WiFi Link 5100 Subsystem: Intel Corporation WiFi Link 5100 AGN Kernel driver in use: iwlwifi Kernel modules: iwlwifi
grep usbcore
的輸出應當類似於 usbcore: registered new interface driver rtl8187
。同時也要通過 ip link
命令來查看無線接口是否已經創建。通常來說,設備名以字母「w」開頭,例如wlan0
或 wlp2s1
。確認之後,使用以下命令使設備上線:
# ip link set <设备名> up
例如,接口設備名是 wlan0
,此命令就是 ip link set wlan0 up
。
- 如果你從命令中得到如下錯誤:
RTNETLINK answers: Operation not possible due to RF-kill
錯誤,請確保設備沒有被 軟鎖定 或 硬鎖定,詳情請參考 Rfkill 說明。 - 如果你從命令中得到如下錯誤:
SIOCSIFFLAGS: No such file or directory
, 那麼大概率您的無線晶片組需要額外的固件來運行。
檢查內核信息中關於已加載固件的信息:
# dmesg | grep firmware
[ 7.148259] iwlwifi 0000:02:00.0: loaded firmware version 39.30.4.1 build 35138 op_mode iwldvm
如果沒有相關的輸出,那麼需要在消息中查找關於您之前指定的模塊的完整輸出(本示例中的模塊是iwlwifi
),然後查找對應的錯誤信息:
# dmesg | grep iwlwifi
[ 12.342694] iwlwifi 0000:02:00.0: irq 44 for MSI/MSI-X [ 12.353466] iwlwifi 0000:02:00.0: loaded firmware version 39.31.5.1 build 35138 op_mode iwldvm [ 12.430317] iwlwifi 0000:02:00.0: CONFIG_IWLWIFI_DEBUG disabled ... [ 12.430341] iwlwifi 0000:02:00.0: Detected Intel(R) Corporation WiFi Link 5100 AGN, REV=0x6B
如果需要的內核模塊已經加載且網絡接口已經上線,您可以跳過下一節的內容。
安裝 driver/firmware
根據獲得的信息,在下面網址查找硬體支持:
- 參閱表格 Linux 支持的無線驅動並轉到特定驅動程序頁面,其中包含受支持設備的列表。
- Ubuntu Wiki 維護了一個設備被內核和用戶空間驅動支持狀況的列表。
- Linux 無線支持頁面 和硬體兼容性列表(HCL)也維護了一個內核友好的設備列表。
注意有些廠商的產品名稱相同,實際使用的晶片組卻不同。usb-id (USB設備) 或 pci-id (PCI設備)才是唯一識別名稱。
如果您在上述列表裡找到了您的無線網卡,請按照 驅動與固件排錯 中的指示操作,這一節中包含有關安裝某些特定無線網卡所需的驅動程序和固件的信息。完成後,再次檢查驅動程序狀態。
如果您的上述列表裡沒有找到您的無線網卡,那麼大概率您的網卡僅在windows作業系統下受支持。對於這些設備,您可以嘗試使用 #ndiswrapper。
工具
同其他網絡設備一樣,無線網絡接口可以通過 iproute2包 包提供的 ip 命令來管理。
管理一個無線網絡連接需要一套基本的工具。可以使用一個 網絡管理器 或直接使用以下表格中的一個:
軟體 | 軟體包 | WEXT | nl80211 | WEP | WPA/WPA2/WPA3 | Archiso [1] |
---|---|---|---|---|---|---|
wireless_tools1 | wireless_tools包 | 是 | 否 | 是 | 否 | 是 |
iw | iw包 | 否 | 是 | 是 | 否 | 是 |
wpa_supplicant | wpa_supplicant包 | 是 | 是 | 否 | 是 | 是 |
iwd | iwd包 | 否 | 是 | 否 | 是 | 是 |
- 過時,不推薦使用.
iw 與 wireless_tools 的對比
下面表格給出了 iw
和 wireless_tools
命令的對比(更多示例參閱 這裡)。
iw 命令 | wireless_tools 命令 | 描述 |
---|---|---|
iw dev wlan0 link | iwconfig wlan0 | 獲取連接狀態。 |
iw dev wlan0 scan | iwlist wlan0 scan | 掃描可用接入點。 |
iw dev wlan0 set type ibss | iwconfig wlan0 mode ad-hoc | 設置操作模式為 ad-hoc。 |
iw dev wlan0 connect your_essid | iwconfig wlan0 essid your_essid | 連接到開放網絡。 |
iw dev wlan0 connect your_essid 2432 | iwconfig wlan0 essid your_essid freq 2432M | 連接到開放網絡的特定頻道。 |
iw dev wlan0 connect your_essid key 0:your_key | iwconfig wlan0 essid your_essid key your_key | 用16進位密匙連接到 WEP 加密網絡。 |
iw dev wlan0 connect your_essid key 0:your_key | iwconfig wlan0 essid your_essid key s:your_key | 用 ASCII 密匙連接到 WEP 加密網絡。 |
iw dev wlan0 set power_save on | iwconfig wlan0 power on | 啟用省電功能。 |
iw
本章節的示例會假定您的無線接口設備名稱是 interface
, 您想要連接到的WiFi接入點名稱是 your_essid
。請將這兩個欄位作相應替換。
獲取接口名
獲取您無線網卡的名稱,運行:
$ iw dev
接口的名稱會在 "Interface" 單詞後顯示。比如,常見的無線網卡設備名是 wlan0
。
檢查連接狀態
用下面的命令檢查連接狀態:
$ iw dev interface link
獲取統計數據
獲取一些統計數據,比如上傳下載的數據量,信號強度等:
$ iw dev interface station dump
激活接口
一些無線網卡在使用 iw
或 wireless_tools
前需要先激活內核接口:
# ip link set interface up
RTNETLINK answers: Operation not possible due to RF-kill
, 請確保硬體開關已經打開。參閱 #Rfkill 說明。如果出現錯誤 RTNETLINK answers: Operation not possible due to RF-kill
, 請確保硬體開關已經打開。參閱 #Rfkill 說明。
要驗證接口確實打開:
$ ip link show interface
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state DOWN mode DORMANT group default qlen 1000 link/ether 12:34:56:78:9a:bc brd ff:ff:ff:ff:ff:ff
<BROADCAST,MULTICAST,UP,LOWER_UP>
中的UP
顯示接口已經打開,不要和後面的 state DOWN
混淆。
掃描接入點
查看可用的接入點:
# iw dev interface scan | less
iwlist
也會產生這個問題。無線網絡也可能被軟鎖定,請運行 rfkill list all
進行檢查。
需要關注的信息:
- SSID: 網絡的名稱.
- Signal: 用 dbm (-100 to 0) 報告的無線信號強度。數值越接近零,信號越好。觀察高質量連接和低質量連接的數值差異可以了解設備的信號範圍。
-
Security: 沒有直接報告, 檢查
capability
開頭的行,如果有Privacy
信息,例如capability: ESS Privacy ShortSlotTime (0x0411)
, 表示網絡具有某種程度的保護,- 如果有
RSN
信息,網絡被 Robust Security Network(WPA2) 協議保護。 - 如果有
WPA
信息,網絡被 Wi-Fi Protected Access 協議保護。 - 在
RSN
和WPA
信息塊中,可能看到如下信息: - 如果沒有看到
RSN
或WPA
,但是看到了Privacy
, 表示使用的是 WEP.
- 如果有
運行模式
設置無線網卡的操作模式,如果連接到漫遊網絡,需要設置操作模式為 ibss
# iw dev interface set type ibss
ip link set interface down
)才能修改模式。連接到接入點
根據加密方式不同,需要使用密碼將無線設備關聯到接入點。
假設要使用的接入點 ESSID 為 MyEssid
:
無加密
# iw dev interface connect "your_essid"
WEP
使用十六進位或 ASCII 密碼(格式是自動識別出來的,因為 WEP 密碼長度是固定的):
# iw dev interface connect "your_essid" key 0:your_key
使用十六進位或 ASCII 密碼,第三個是默認 (從0計數,共四個):
# iw dev interface connect "your_essid" key d:2:your_key
其它
- iw 只能處理 WEP。要使用其他加密方案登錄, 請查看下文中的 #認證 章節。
無論您使用什麼認證方法,都可以使用以下命令來確認連接是否成功:
# iw dev interface link
認證
WPA2 個人模式
WPA2 個人(模式), 又名 WPA2-PSK, 是一種 受保護Wi-Fi訪問(Wi-Fi存取保護)的模式。
您可以通過 wpa_supplicant 或 iwd 來連接, 或者直接使用 網絡管理器. 如果您只進行了認證,那麼要獲取功能齊全的連接,您仍然需要進行手動連接 或使用 DHCP 客戶端。
WPA2 企業模式
WPA2 企業模式 也是一種 受保護Wi-Fi訪問(Wi-Fi存取保護)的模式,提供了比 WPA2 個人版更好的安全性和密鑰管理,並支持其他的企業型功能,例如 VLAN 和 NAP。然而,與個人模式不同,此種加密需要額外的 RADIUS 認證伺服器來處理用戶的認證。個人模式不需要除無線路由器/接入點以外的設備,對所有用戶也只要求一個密碼或密碼短語。
企業模式允許用戶使用用戶名和密碼或者數字證書來登錄 Wi-Fi。因為每個用戶都擁有一個動態唯一的加密密碼,因此企業模式可以防止通過無限網絡的用戶探聽,並提高加密強度。
本章節描述如何使用 網絡管理器 來連接到使用 WPA2 企業模式的無線接入點。
查看 軟體接入點#RADIUS 來獲取關於設置接入點自身的相關信息。
協議間的對照可以參照此 表格。
MS-CHAPv2
有時,除了原配的 ppp包 (Point-to-Point Protocol) 之外,要求 MSCHAPv2 type-2 with PEAP 的 WPA2 企業級接入點有時會需求 pptpclient包。netctl包 似乎能在缺少 ppp-mppe 的情況下開箱即用。雖然其他認證實現方式通常都並不可用,由於其高度脆弱的特性,用戶在任何情況下都不被鼓勵使用 MSCHAPv2。
eduroam
eduroam 是一項面向科研,高等教育與繼續教育領域人員的國際漫遊服務。
- 存儲未加密的連接配置文件時,建議用 root 用戶運行以下命令以限制 root 帳戶對此文件的的讀取訪問權限:
chmod 600 配置文件
手動/自動配置
-
wpa_supplicant 可以直接通過其配置文件或使用其 CLI/GUI 前端進行配置,並與 DHCP 客戶端結合使用。 請參閱
/usr/share/doc/wpa_supplicant/wpa_supplicant.conf
中的示例來結合您的詳細連接信息。 - iwd#WPA Enterprise
- NetworkManager 可以使用 nmcli 或 graphical front ends 來創建 WPA2 企業級配置文件。nmtui 不支持此功能 (NetworkManager issue 376), 但可以使用現有配置。
- ConnMan 需要在 連接至網絡 之前配置一個單獨的配置文件。詳情請參閱 connman-service.config(5) 和 ConnMan#連接到 eduroam (802.1X)。
-
netctl 可以通過填寫配置中的
WPAConfigSection=
欄位來支持 wpa_supplicant 配置文件。詳情請參閱 netctl.profile(5)。
- 注意: 特殊引用規則適用: 參考 netctl.profile(5) § SPECIAL QUOTING RULES.
- 提示:自定義證書可通過在
WPAConfigSection
中添加欄位'ca_cert="/path/to/special/certificate.cer"'
來配置。
WPA3 個人
WPA3 Personal, 又名 WPA3-SAE, 是一種 受保護Wi-Fi訪問(Wi-Fi存取保護)的模式。
wpa_supplicant 及 iwd 都支持 WPA3 個人認證模式。
WPA3 企業模式
WPA3 企業模式 是一種 受保護Wi-Fi訪問(Wi-Fi存取保護)的模式。
wpa_supplicant (自版本起 2:2.10-8) 支持 WPA3 企業模式。 參見 FS#65314。
提示和技巧
遵循監管區域要求
監管區域用於配置無線驅動,確保對無線硬體的使用符合由 FCC、ETSI 及其他組織制定的當地法規。監管區域使用ISO 3166-1二位字母國家代碼。例如,美國的監管區域代碼是「US」,中國則是「CN」,等等。
監管區域影響無線信道的可用性。在2.4GHz波段,美國允許使用1-11信道,日本是1-14,世界上多數其它地區則是1-13。在5GHz波段,允許使用信道的規則要複雜得多。這兩種情況的更詳細信息見這一WLAN信道列表。
監管區域也影響對來自無線設備的等效各向同性輻射功率(EIRP)所作的限制。這衍生自發射功率(tx power)並以dBm/mBm(1dBm=100mBm)或mW(對數尺度)衡量。在2.4GHz波段,美國和加拿大最大限制30dBm,歐洲大部分是20dBm,世界上其他地區則是20dB-30dBm。在5GHz波段,最大值通常更低。更詳細的信息請參考 wireless-regdb(EIRP dBm 值在每行第二對括號裡)。
錯誤設置監管區域可能會有用——例如,在其他信道擁擠時可以使用未用信道,或者提升發射功率以擴大傳輸範圍。然而不推薦這種做法,因為可能會違反當地法規以及造成與其他無線電設備的干擾。
要配置監管區域,安裝 crda包[損壞的連結:replaced by wireless-regdb包] 並重啟(以重新加載 cfg80211
模塊及所有相關驅動)。檢查啟動日誌以確認 cfg80211
正在調用CRDA:
# dmesg | grep cfg80211
以下命令可將當前監管區域設為美國:
# iw reg set US
用以下命令查詢:
$ iw reg get
- 你的設備國家代碼可能為「00」,它是包含了通用設置的「世界監管區域」。如果無法解除此設置,則CRDA可能配置有誤。
- 根據 CRDA 的 README,從內核版本4.15開始就不再需要它,因為內核會自動從固件加載監管資料庫。然而也有說法稱這一加載操作需要特定的內核設置。
然而設置監管區域可能不會改變您的設置。有些設備在固件/EEPROM中設置了一個監管區域,為設備規定了限制,這意味著通過軟體設置監管區域只能增加限制而不能減少。例如,一個 CN(中國)設備可以用軟體設置為 US(美國)監管區域,但由於中國的 EIRP 最大值為20dBm,設備將無法以美國的最大值30dBm進行發射。
例如,查看一個 Atheros 設備的固件中是否設置了監管區域:
# dmesg | grep ath:
對於其他晶片組,搜索「EEPROM」、「regdomain」或設備驅動的名字可能會有用。
要查看監管區域更改是否成功,以及查詢可用信道數和允許發射功率:
$ iw list | grep -A 15 Frequencies:
監管區域的持久設置可以通過編輯 /etc/conf.d/wireless-regdom
並解除相應區域的注釋實現。 wpa_supplicant
也可以在 /etc/wpa_supplicant/wpa_supplicant.conf
中的 country=
行應用監管區域。
也可以通過添加模塊參數(如 options cfg80211 ieee80211_regdom=EU
),配置 cfg80211 內核模塊,從而使用指定的監管區域。然而這是一種老舊的監管實現。
更多信息請閱讀 wireless.kernel.org 監管文檔。
Rfkill 說明
許多筆記本都有一個硬體按鈕或開關用於關閉無線網卡,然而無線網卡也可以通過內核來屏蔽。這一任務可由 rfkill 處理。顯示當前狀態:
$ rfkill
ID TYPE DEVICE SOFT HARD 0 bluetooth hci0 unblocked unblocked 1 wlan phy0 unblocked unblocked
如果網卡處於硬體屏蔽(hard-blocked)狀態,請使用硬體按鈕或開關來開啟它。 如果無線網卡並沒有被硬體屏蔽但處於軟體屏蔽(soft-blocked),請使用以下命令:
# rfkill unblock wifi
rfkill
內核模塊的一些選項改變這一現象。切換無線網卡的硬體按鈕是廠商專用的內核模塊處理的,經常是 WMI 模塊。特別是非常新的硬體型號,可能還沒有得到最新穩定內核的完全支持。這種情況下,在內核 bug 跟蹤系統搜索信息,並將型號報告給對應廠商內核模塊的維護者(如果還沒有報告的話)經常會有幫助。
參見 https://askubuntu.com/questions/62166/siocsifflags-operation-not-possible-due-to-rf-kill 。u
節能
見 電源管理#網絡接口。
排錯
這個單元包含一般性的錯誤排除提示, 目的並非是排除與設備或固件驅動有關的錯誤。 對於驅動與固件上的問題, 請看 #驅動與固件排錯.
臨時上網
如果您的網絡設備出了問題但需要網絡訪問,例如, 下載一些軟體或向社區尋求幫助, 您可以利用安卓的內置功能來通過USB埠共享網絡。 詳見 Android Tethering#USB tethering。
觀察日誌文件
分析系統日誌文件是排錯的良好切入點。在進行操作(如嘗試連接到無線網絡)的同時,打開第二個終端/控制台窗口並用以下命令監看內核消息:
# dmesg -w
這樣,您就不需要手動一行一行的瀏覽這些消息了。
當您使用網絡管理器時,同樣的,可以用 systemd 提供的日誌命令:
# journalctl -f
通常來說,無線網絡錯誤都伴隨著具有特定理由代碼(reason code)的取消驗證(deauthentication)。例如:
wlan0: deauthenticating from XX:XX:XX:XX:XX:XX by local choice (reason=3)
對照原因代碼 表可能會給出解決問題的第一個提示。
獲取IP位址失敗
- 如果你使用有線接口可以獲得IP位址而無線接口不能, 嘗試禁用無線網卡的 省電 功能(指定
off
而非on
).
- 如果由於等待網絡連接而導致超時錯誤,可能要將特定網卡設備的信道模式改為自動:
auto
# iwconfig wlan0 channel auto
在將wifi信道更改為自動之前,請確保無線接口已關閉。成功地更改後,再次打開無線接口並繼續。
IP位址有效但無法接解析主機名
如果你正在使用公共無線網絡,可能會有 認證門戶, 確保在瀏覽器查詢認證頁面時使用HTTP 而不是HTTPS, 因為有些認證門戶會重定向到HTTP. 如果不是這個導致的問題, 檢查你是否可以解析域名, 可能有必要使用通過DHCP方式得到的DNS伺服器。
Setting RTS and fragmentation thresholds
Wireless hardware disables RTS and fragmentation by default. These are two different methods of increasing throughput at the expense of bandwidth (i.e. reliability at the expense of speed). These are useful in environments with wireless noise or many adjacent access points, which may create interference leading to timeouts or failing connections.
Packet fragmentation improves throughput by splitting up packets with size exceeding the fragmentation threshold. The maximum value (2346) effectively disables fragmentation since no packet can exceed it. The minimum value (256) maximizes throughput, but may carry a significant bandwidth cost.
# iw phy0 set frag 512
RTS improves throughput by performing a handshake with the access point before transmitting packets with size exceeding the RTS threshold. The maximum threshold (2347) effectively disables RTS since no packet can exceed it. The minimum threshold (0) enables RTS for all packets, which is probably excessive for most situations.
# iw phy0 set rts 500
phy0
is the name of the wireless device as listed by iw phy
.Random disconnections
Cause #1
If your journal says wlan0: deauthenticating from MAC by local choice (reason=3)
and you lose your Wi-Fi connection, it is likely that you have a bit too aggressive power-saving on your Wi-Fi card. Try disabling the wireless card's power saving features (specify off
instead of on
).
If your card does not support enabling/disabling power save mode, check the BIOS for power management options. Disabling PCI-Express power management in the BIOS of a Lenovo W520 resolved this issue.
Cause #2
If you are experiencing frequent disconnections and your journal shows messages such as
ieee80211 phy0: wlan0: No probe response from AP xx:xx:xx:xx:xx:xx after 500ms, disconnecting
try changing the channel bandwidth to 20MHz
through your router's settings page.
Cause #3
On some laptop models with hardware rfkill switches (e.g., Thinkpad X200 series), due to wear or bad design, the switch (or its connection to the mainboard) might become loose over time resulting in seemingly random hardblocks/disconnects when you accidentally touch the switch or move the laptop. There is no software solution to this, unless your switch is electrical and the BIOS offers the option to disable the switch. If your switch is mechanical (and most are), there are lots of possible solutions, most of which aim to disable the switch: Soldering the contact point on the mainboard/wifi-card, gluing or blocking the switch, using a screw nut to tighten the switch or removing it altogether.
Cause #4
Another cause for frequent disconnects or a complete failure to connect may also be a sub-standard router, incomplete settings of the router, interference by other wireless devices or low quality signal.
To troubleshoot, first try to connect to the router with no authentication and by getting closer to it.
If that works, enable WPA/WPA2 again but choose fixed and/or limited router settings. For example:
- If the router is considerably older than the wireless device you use for the client, test if it works with setting the router to one wireless mode
- Disable mixed-mode authentication (e.g. only WPA2 with AES, or TKIP if the router is old)
- Try a fixed/free channel rather than "auto" channel (maybe the router next door is old and interfering)
- Disable WPS
- Change the router's 5 GHz channel(s) to a non-DFS (Dynamic Frequency Selection) channel. Connections on such channels may be dropped or suddenly switched due to interference from nearby weather radar.
- Try setting your client to 2.4 GHz only instead of letting it choose what it thinks is best between 5 GHz and 2.4 GHz (the later has a lower throughput but will provide a more stable connection over longer distances)
- Disable
40MHz
channel bandwidth (lower throughput but less likely collisions) withcfg80211.cfg80211_disable_40mhz_24ghz=1
- If the router has quality of service settings, check completeness of settings (e.g. Wi-Fi Multimedia (WMM) is part of optional QoS flow control. An erroneous router firmware may advertise its existence although the setting is not enabled)
Cause #5
On some wireless network adapters (e.g. Qualcomm Atheros AR9485), random disconnects can happen with a DMA error:
# journalctl -xb
ath: phy0: DMA failed to stop in 10 ms AR_CR=0x00000024 AR_DIAG_SW=0x02000020 DMADBG_7=0x0000a400 wlp1s0: authenticate with 56:e7:ee:7b:55:bc wlp1s0: send auth to 56:e7:ee:7b:55:bc (try 1/3) wlp1s0: send auth to 56:e7:ee:7b:55:bc (try 2/3) wlp1s0: send auth to 56:e7:ee:7b:55:bc (try 3/3) wlp1s0: authentication with 56:e7:ee:7b:55:bc timed out
A possible workaround is to disable the Intel IOMMU driver (DMA), adding intel_iommu=off
to the kernel parameters [2].
Cause #6
If you are using a device with iwlwifi
and iwlmvm
for wireless connectivity, and your Wi-Fi card appears to disappear when on battery power (perhaps after a reboot or resuming from suspend), this can be fixed by configuring power saving settings in iwlmvm.
Create the file /etc/modprobe.d/iwlmvm.conf
if it does not exist already, then add the following line to it:
/etc/modprobe.d/iwlmvm.conf
options iwlmvm power_scheme=1
A power_scheme
of 1 sets iwlmvm to "Always Active." Available options are:
Value | Description |
---|---|
1 | Always Active |
2 | Balanced |
3 | Low-power |
This fix was discovered at [3].
Cause #7
If your device undergoes long periods of inactivity (e.g. a file server), the disconnection may be due to power saving, which will block incoming traffic and prevent connections. Try disabling power saving for the interface:
# iw dev interface set power_save off
You can create a udev rule to do this on boot, see Power management#Network interfaces.
Cause #8
If you notice occasional interruptions when connected to a mesh network (e.g., WiFi6) and notice a message such as:
# journalctl -b
kernel: wlan0: disconnect from AP aa:bb:cc:dd:ee:ff for new auth to 11:22:33:44:55:66
You are experiencing roaming issues. Depending on your mean of connection and the issue at hand, one could:
- Lock the BSSID (the
aa:bb:cc:dd:ee:ff
show above) in NetworkManager if roaming is not desired (see NetworkManager#Regular network disconnects, latency and lost packets (WiFi)). - Adjust the
bgscan
setting in Wpa_supplicant#Roaming
Wi-Fi 由於錯誤的信道設置而變得不可見
若電腦 Wi-Fi 信道不符合用戶所處國家之規定,部分Wi-Fi即使處於信號覆蓋範圍內,也可能因信道默認不被允許而不可見。參閱 #Respecting the regulatory domain.
驅動與固件排錯
這一部分包含了關於特定晶片組安裝內核模塊與固件的方法與規範,不同於一般的方法。
參閱 內核模塊 了解通用的模塊操作方法。
Ralink
rt2x00
Ralink 晶片組的統一驅動,代替了 rt2500
, rt61
, rt73
等。Linux 內核從 2.6.24 開始包含此驅動,但是有些設備可能需要額外固件。可以使用標準 wpa_supplicant包 和 iwconfig
工具配置。
有些晶片組需要固件文件,可以安裝軟體包 linux-firmware包。
參見: Using the new rt2x00 beta driver
- Since kernel 3.0, rt2x00 includes also these drivers:
rt2800pci
,rt2800usb
.rt2860sta
被主分支驅動rt2800pci
替代,rt2870sta
被rt2800usb
替代。 - 通過
iwpriv
可以配置很多參數,文檔在 Ralink 原始碼包 中。
rt3090
對於使用 rt3090 晶片組的設備, 應該使用的驅動是rt2800pci
; 然而, 它並沒有非常好的適配這個晶片組 (e.g. 有時候網速甚至不能到 2Mb/s).
rt3290
rt3290 晶片組是由內核模塊rt2800pci
識別的。一些用戶遇到這些 問題,他們選擇恢復到打了補丁的Ralink驅動,這樣效果更好。
rt3573
2012年新出的晶片組,需要 Ralink 的閉源驅動,有不同的廠商使用他們,參閱Belkin N750 示例 。
mt7612u
2014年新發布的晶片組,以新的商用名稱聯發科發布。這是一款AC1200或AC1300級別的晶片組。製造商提供了Linux驅動程序在 支持頁面。從內核 5.5 版本開始, 該晶片組應該已被包含的 mt76
驅動所支持。
Realtek
參見 [4][失效連結 2022-11-10] 查看 Realtek 晶片組和規範列表
rtl8192cu
這個驅動已經被包含在內核裡了, 但很多用戶報告指出即使掃描到了wifi也無法連接。
8192cu-dkmsAUR 包含了很多補丁; 如果內核裡的驅動並沒有很好的起效果可以嘗試這個。
rtl8723ae/rtl8723be
rtl8723ae
和 rtl8723be
模塊已經被包含在 Linux 內核主線
一些用戶使用此網卡時可能會遇到省電方面的問題. 這表現為可能偶爾斷開連接,但高級網絡管理器無法識別 (netctl, NetworkManager). 以root身份執行dmesg -w
可以驗證這個錯誤 ,或以root身份執行 journalctl -f
查找與 powersave 和rtl8723ae
/rtl8723be
模塊相關的輸出. 如果你遇到了這個問題, 使用 fwlps=0
內核選項,這樣可以防止無線網卡自動休眠或停止連接。參閱 Kernel module#Setting module options.
如果你信號很差,可能你只有一個物理天線連接了, 並且天線的自動選擇損壞了. 可以用 ant_sel=1
或ant_sel=2
內核選項強制選擇天線. [5]
rtl88xxau
Realtek晶片組 rtl8811au, rtl8812au, rtl8814au和rtl8821au設計用於各種USB適配器,範圍從AC600到AC1900。有幾個包提供對應的內核驅動,需要DKMS和內核頭文件:
C | P | N |
---|---|---|
rtl8811au, rtl8812au, rtl8821au | rtl88xxau-aircrack-dkms-gitAUR | Aircrack-ng 給 8811au, 8812au ,8821au 提供了監控模式和注入支持。 |
rtl8812au | rtl8812au-dkms-gitAUR | Realtek最新官方驅動版本僅適用於rtl8812au。 |
rtl8811au, rtl8821au | rtl8821au-dkms-gitAUR | 用於 rtl8821au 的新一代驅動版本 |
rtl8814au | rtl8814au-dkms-gitAUR | rtl8813au 可能也適用 |
rtl8811cu/rtl8821cu
rtl8821cu-dkms-gitAUR 提供了一個內核模塊給Realtek 8811cu 和 8821cu 晶片組。
需要 DKMS, 確保安裝了內核頭文件。
如果安裝並加載了 8821cu
模塊,無線接口還是沒有顯示 , 需要手動指定 rtw_RFE_type
選項 [6][7]. 試試 e.g. echo "options 8821cu rtw_RFE_type=0x26" | sudo tee /etc/modprobe.d/8821cu.conf
, 其他值可能也行,比如1或2等等. 詳見 Kernel module#Setting module options
rtl8821ce
rtl8821ce-dkms-gitAUR 為華碩 X543UA 中的 Realtek 8821ce 晶片組提供了一個內核模塊。
它需要 DKMS, 所以應確保已安裝 kernel headers ( 內核頭文件 )。
rtl8821ce
無線模塊是破損的, 會導致連接弱,應該優先使用上面的 AUR 版本。詳見 在github上的討論,使用 lspci -k
檢查是否在用默認的 (rtw88_8821ce
)模塊. 如果是,把它加入黑名單。rtl8822bu
rtl88x2bu-dkms-gitAUR 給 Edimax EW7822ULC USB3, Asus AC53 Nano USB 802.11ac 和 TP-Link Archer T3U adapter 的 Realtek 8822bu 晶片組提供了內核模塊
確保有DKMS和內核頭文件。
rtl8xxxu
可以通過安裝linux-firmware包來獲得rtl8xxxu
的驅動程序。
rtl8xxxu
主線內核模塊的問題可通過編譯特定晶片組的第三方模塊來解決。原始碼可在GitHub 存儲庫中找到。
某些驅動程序可能已存在於在 AUR 中,例如 rtl8723bu-dkms-gitAUR。
RTW88
一份RTW88內核模塊補丁集最近被發到內核郵件列表中,有望被添加進內核主線。
如果正確配置和編譯的話,上游內核以及帶有補丁集的內核將會支持大部分 RTW88 晶片設備。 linux-zen包 和 linux-zen-gitAUR 均包含了這些補丁, 其中已打包的版本已經內置了該模塊。
驅動支持型號有: 882BE, 8822BU, 8822CE, 8822CU, 8723DE, 8723DU, 8821CE, and 8821CU.
Atheros
MadWifi team 开发组维护了三个模块:
-
madwifi
是最老的驅動, Arch kernel 從 2.6.39.1 開始已經不再包含。 -
ath5k
將逐步替代ath_pci
,有些晶片組使用效果很好,但有些還不能很好工作(後面有介紹) -
ath9k
是新的官方驅動,適用於新 Atheros 硬體。
還有一些驅動適用於其他的 Atheros 設備. 詳見 Linux Wireless documentation 。
ath5k
參考:
若網頁有時加載緩慢或設備無法獲取ip地址,嘗試從硬體加密切換為軟體加密,使用 nohwcrypt=1
內核選項加載 ath5k
模塊。詳見 Kernel modules#Setting module options
有些筆記本的 LED 指示燈有問題,可以:
echo none > "/sys/class/leds/ath5k-phy0::tx/trigger" echo none > "/sys/class/leds/ath5k-phy0::rx/trigger"
ath9k
外部文檔資源:
截至 Linux 3.15.1,,一些用戶可能會遇到網絡帶寬下降的問題,這種情況可以為 ath9k
模塊設置 nohwcrypt=1
的內核選項。 詳見 Kernel module#Setting module options.
lsmod
to see what modules are in use and change ath9k
if it is named differently (e.g. ath9k_htc
).節能/省電模式
雖然Linux 無線工具表明對於比 AR9280 更新的 Atheros ath9k 單晶片設備已經啟用了動態電源節能功能,雖然 Linux Wireless 指出 比 AR9280 更新的Atheros ath9k 單晶片設備已啟用動態節能功能 , 但一些設備仍 (e.g. AR9285) powertop包 被指出省電被禁用,這種情況需手動開啟。
一些設備 (e.g. AR9285), 啟用省電功能可能會有如下報錯:
# iw dev wlan0 set power_save on
command failed: Operation not supported (-95)
解決方法:為 ath9k
模塊設置 ps_enable=1
內核選項,詳見 Kernel module#Setting module options.
Intel
iwlegacy
iwlegacy 是 Intel's 3945 和 4965 網卡的無線驅動。 linux-firmware包 已經包含此驅動。
udev 會自動加載驅動, 否則要手動加載 iwl3945
或iwl4965
。詳見 內核模塊 。
如果連不上網或者連接很弱, 嘗試啟用 802.11n:
/etc/modprobe.d/iwl4965.conf
options iwl4965 11n_disable=1
若啟動過程中一直失敗,且你正在使用 Nouveau 驅動, 嘗試 啟用早期KMS 避免衝突 [9].
iwlwifi
iwlwifi 是適用於 Intel 當前網卡的無線驅動, 例如 5100AGN, 5300AGN, 和 5350AGN. 查看所有受支持的文件列表。該固件已包含在 linux-firmware包 裡。 linux-firmware-iwlwifi-gitAUR 可能包含更新的驅動。
若聯網存在問題或連接很弱,嘗試啟用 802.11n, 也可能需要啟用軟體加密:
/etc/modprobe.d/iwlwifi.conf
options iwlwifi 11n_disable=1 swcrypto=1
在 802.11n 模式下網絡上行速度很慢, 比如 20Mbps, 嘗試啟用TX AMPDU:
/etc/modprobe.d/iwlwifi.conf
options iwlwifi 11n_disable=8
Do not be confused with the option name, when the value is set to 8
it does not disable anything but re-enables transmission TX AMPDU[10] [11]
In case this does not work for you, you may try disabling power saving for your wireless adapter.
Some have never gotten this to work. Others found salvation by disabling N in their router settings after trying everything. This is known to have been the only solution on more than one occasion. The second link there mentions a 5ghz option that might be worth exploring.
If you have an 802.11ax (WiFi 6) access point and have problems detecting the beacons or an unreliable connection, review Intel Article 54799.
11n_disable=0
will also prevent 802.11ac and only allow connection with slower protocols (802.11a in the 5GHz band or 802.11b/g in the 2.4 GHz band).Bluetooth coexistence
If you have difficulty connecting a bluetooth headset and maintaining good downlink speed, try disabling bluetooth coexistence [12]:
/etc/modprobe.d/iwlwifi.conf
options iwlwifi bt_coex_active=0
bt_coex_active
and sw_crypto
module options have been disabled for the hardware handled by the iwlmvm
kernel module. For older hardware handled by the iwldvm
module, the options are still enabled.Firmware issues
You may have some issue where the driver outputs stack traces & errors, which can cause some stuttering.
# dmesg
Microcode SW error detected. Restarting 0x2000000.
Alternatively, you may simply experience miscellaneous issues (e.g. connection issues on 5GHz, random disconnections, no connection on resume).
To confirm it is the cause of the issues, downgrade the package linux-firmware包.
If confirmed, move the buggy firmware files so that an older version is loaded (to be able to have an up to date linux-firmware包 since it is not only providing firmware updates for your Intel WiFi card):
# for i in {64..73} ; do mv /usr/lib/firmware/iwlwifi-ty-a0-gf-a0-$i.ucode.xz /usr/lib/firmware/iwlwifi-ty-a0-gf-a0-$i.ucode.xz.bak ; done
To avoid having to repeat these steps manually after each update, use the NoExtract
array in pacman.conf
with a wildcard to block their installation. See pacman#Skip files from being installed to system.
Adapter not detected after booting from Windows
If the WiFi adapter is not getting detected after finishing a session in Windows, this might be due to Windows' Fast Startup feature which is enabled by default. Try disabling Fast Startup. The iwlwifi kernel driver wiki has an entry for this.
禁用 LED 閃爍
iwlegacy
和 iwlwifi
驅動默認設置中 LED 閃爍是開著的,有些人不喜歡,可以systemd-tmpfiles[損壞的連結:無效的章節]禁止閃爍:
/etc/tmpfiles.d/phy0-led.conf
w /sys/class/leds/phy0-led/trigger - - - - phy0radio
運行 systemd-tmpfiles --create phy0-led.conf
使更改生效,或重啟
查看此LED所有可選的觸發值:
# cat /sys/class/leds/phy0-led/trigger
# cat /sys/class/leds/phy0-led/trigger
Broadcom
其他 驅動/設備
Tenda w322u
該型號 Tenda 卡 可被視為 rt2870sta
設備。參閱 #rt2x00.
orinoco
這應當是內核的一部分,是已經被安裝的。
部分 Orinoco 晶片組屬於 Hermes 二代系列。應使用 wlags49_h2_cs
驅動而非 orinoco_cs
以獲得WPA 支持。 使用此驅動前需先 blacklist orinoco_cs
prism54
p54
已經包含在內核中, 不過必須從 此網站 下載適合你網卡的驅動並且把它安裝進/usr/lib/firmware
目錄。
過時的 prism54
和新內核模塊 p54pci
或 p54usb
同時裝入造成衝突,使用 lsmod | grep prism54
查看是否裝入了過時模塊,如果是,那麼就 屏蔽 prism54
並根據上面方法修改固件名稱。
zd1211rw
zd1211rw 是ZyDAS ZD1211 802.11b/g USB WLAN晶片的驅動,最近的版本的內核已經包括了。[13]有被支持的設備列表。 需要安裝固件zd1211-firmwareAUR。
hostap_cs
Host AP 是一個 Linux 驅動程序,對於基於 Intersil 的 Prism2/2.5/3 晶片組的無線區域網卡。該驅動程序包含在 Linux 內核中。
orinico_cs
driver
ACX100/111
軟體包: tiacx
tiacx-firmware
(已被官方倉庫 和 AUR 移除)
詳見 official wiki 。
ndiswrapper
Ndiswrapper並不是一個真正的驅動,但是如果你無法找到適合你的無線網卡驅動, 它就派上用場了.有的時候, 它是非常有用的.為了使用Ndiswrapper, 你需要Windows驅動中的*.inf文件(*.sys文件應該和*.info在同一個目錄中)。如果你需要從 *.exe
文件解壓縮,你可以使用 cabextract包.
下面是安裝ndiswrapper的幾個步驟:
1. 安裝 ndiswrapper-dkms包
2. 安裝驅動到 /etc/ndiswrapper/*
ndiswrapper -i filename.inf
3. 列出所有的安裝的驅動
ndiswrapper -l
4. 配置文件寫到 /etc/modprobe.d/ndiswrapper.conf
ndiswrapper -m depmod -a
然後依照 這裡設置啟動時加載這個模塊。
modprobe ndiswrapper iwconfig
如果正常的話, 你應該可以看到wlan0接口了. 如果有問題的話, 你可以閱讀: Ndiswrapper installation wiki[失效連結 2020-08-04 ⓘ]. ndiswrapper howto 和 ndiswrapper FAQ.
參見
- The Linux Wireless project
- Aircrack-ng guide on installing drivers
- Wireless Device Database Wiki (This fork is hosted by wi-cat.ru since the original wiki has shut down. There are two less complete versions available: TechInfoDepot, deviwiki)