写于:2016-02-22		最近一次更新:2017-10-19

Trouble:

使用NetworkManager(nm-applet)管理网络 有线网络设备正常,无线用不了,nm-applet一直提示 无线网络设备未就绪(Wi-Fi Networks device not ready)

Oneway:

如果确定无线网卡驱动没有问题,那么就 重装 wpa_supplicant 和 dbus ,先用有线网络连上外网, 然后用root权限重装wpa_supplicant和dbus,并重启NetworkManager root@slack:~# slackpkg reinstall wpa_supplicant root@slack:~# slackpkg reinstall dbus #dbus-glib也选中重装一下 root@slack:~# /etc/rc.d/rc.networkmanager restart

Details:

提示 Wi-Fi Networks device not ready ,通常有两种情况 一是网卡驱动异常, 二是 wpa_supplicant 配置不正确或未能成功执行 下面是具体排查步骤,请使用root权限执行以下操作 首先,找出无线网卡的设备编号 # lspci -nn | grep -i 'wireless \| network' 03:00.0 Network controller [0280]: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) [168c:002b] (rev 01) 通过lspci命令可以看到我的无线网卡是Atheros牌子的,型号是AR9285 厂家代码:设备代码是 168c:002b ,这个是唯一值,唯一代表一个设备 接着查看 168c:002b 这个设备使用的是哪个驱动模块 # lspci -d 168c:002b -k 03:00.0 Network controller: Atheros Communications Inc. AR9285 Wireless Network Adapter (PCI-Express) (rev 01) Subsystem: Atheros Communications Inc. Device 30a1 Kernel driver in use: ath9k Kernel modules: ath9k 紧接着查看内核驱动模块 ath9k 是否成功加载 # lsmod | grep ath9k ath9k 87291 0 ath9k_common 1951 1 ath9k ath9k_hw 369458 2 ath9k_common,ath9k ath 15545 3 ath9k_common,ath9k,ath9k_hw mac80211 429423 1 ath9k cfg80211 380228 3 ath,ath9k,mac80211 若成功加载再看加载ath9k驱动模块时是否有其他告警或错误信息 # dmesg | grep ath9k 未发现异常信息 确认接口状态是否正常 # ifconfig wlan0: flags=4099 mtu 1500 ether 6c:fd:b9:3b:62:f1 txqueuelen 1000 (Ethernet) RX packets 0 bytes 0 (0.0 B) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 0 bytes 0 (0.0 B) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 # iwconfig wlan0 IEEE 802.11bgn ESSID:off/any Mode:Managed Access Point: Not-Associated Tx-Power=20 dBm Retry long limit:7 RTS thr:off Fragment thr:off Encryption key:off Power Management:off 可以看到ifconfig和iwconfig的执行结果正常, (且Power Management是off状态的,即节能省电功能处于关闭状态, 部分网卡开启省电功能后会工作异常) (关掉无线网卡省电功能的命令是:# iwconfig wlan0 power off) 确认网卡国家代码是否正确 # iw reg get country CN: (2402 - 2482 @ 40), (N/A, 20) (5735 - 5835 @ 40), (N/A, 30) 若不正确,请设置为当前所在的国家代码 # iw reg set CN 确认是否能搜索到无线信号 # iw dev wlan0 scan | grep -i 'ssid' SSID: AT-liuanban SSID: mao SSID: 12LOU SSID: zhang 可以看到无线网卡是能够搜索到附近的无线路由器信号的 既然能搜到无线路由器的信号,可以肯定无线网卡是没有问题的,驱动是正常的 那么,接下来检查以下日志信息 # cat /var/log/messages | grep wlan0 NetworkManager[840]: (wlan0): supplicant interface state: starting -> down NetworkManager[840]: (wlan0): supplicant interface state: starting -> down NetworkManager[840]: (wlan0): supplicant interface state: starting -> down 可以看到大量的supplicant接口状态从starting直接到down的信息,说明supplicant接口起不来 # cat /var/log/syslog | grep wlan0 NetworkManager[840]: [1455862868.217027] [nm-supplicant-interface.c:997] interface_add_cb(): (wlan0): error adding interface: Launch helper exited with unknown return code 255 同样可以看到大量的关于NetworkManager添加接口wlan0失败的错误信息, 错误出在nm-supplicant-interface.c的代码里,还是跟supplicant有关 那么我们就检查supplicant的日志信息 # cat /var/log/wpa_supplicant.log dbus: Could not request service name: org.freedesktop.DBus.Error.AccessDenied Connection ":1.2389" is not allowed to own the service "fi.w1.wpa_supplicant1" due to security policies in the configuration file 这个意思就是说出于安全策略原因 dbus 无法请求 fi.w1.wpa_supplicant1 服务 与 dbus 相关的配置文件一般在这两个地方 /etc/dbus-1/system.d/ /usr/share/dbus-1/system-services/ 然后在这两个地方找到了与wpa_supplicant有关的文件 /etc/dbus-1/system.d/dbus-wpa_supplicant.conf /usr/share/dbus-1/system-services/fi.w1.wpa_supplicant1.service 发现 dbus-wpa_supplicant.conf 文件异常,没有内容, fi.w1.wpa_supplicant1.service 文件正常 然后就去其他装有Slackware的机器上拷了一份dbus-wpa_supplicant.conf过来 接着执行命令# /etc/rc.d/rc.networkmanager restart 重启NetworkManager后 无线网络恢复正常 建议直接重装wpa_supplicant,避免wpa_supplicant其他文件异常带来的麻烦 如果重装wpa_supplicant后, 问题“无线网络设备未就绪(Wi-Fi Networks device not ready)” 依然存在,请检查/var/log/messages中是否存在类似以下信息 Oct 19 16:44:52 mnxnm NetworkManager[790]: WiFi now enabled by radio killswitch Oct 19 16:44:52 mnxnm NetworkManager[790]: (wlan0): bringing up device. Oct 19 16:44:52 mnxnm kernel: [ 158.890720] IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready Oct 19 16:44:52 mnxnm dbus[715]: [system] Activating service name='fi.w1.wpa_supplicant1' (using servicehelper) Oct 19 16:44:52 mnxnm dbus[715]: [system] Activated service 'fi.w1.wpa_supplicant1' failed: Failed to execute program /usr/libexec/dbus-daemon-launch-helper: Success Oct 19 16:44:52 mnxnm NetworkManager[790]: (wlan0): supplicant interface state: starting -> init 或者 Oct 19 17:04:53 mnxnm NetworkManager[781]: (wlan0): supplicant interface state: starting -> down Oct 19 17:04:53 mnxnm dbus[706]: [system] Activating service name='fi.w1.wpa_supplicant1' (using servicehelper) Oct 19 17:04:53 mnxnm dbus[706]: [system] Activated service 'fi.w1.wpa_supplicant1' failed: The permission of the setuid helper is not correct 如果存在类似上述信息,建议把 dbus及其组件 重装一下 当dbus有问题时,可能会影响到xfce桌面环境的正常使用, 比如 Log Out 时无响应或者需要很久才响应, 这时可以尝试重装 dbus及其组件 后重启电脑。 最后,附上 /etc/dbus-1/system.d/dbus-wpa_supplicant.conf 文件的原始内容: <!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd"> <busconfig> <policy user="root"> <allow own="fi.epitest.hostap.WPASupplicant"/> <allow send_destination="fi.epitest.hostap.WPASupplicant"/> <allow send_interface="fi.epitest.hostap.WPASupplicant"/> <allow own="fi.w1.wpa_supplicant1"/> <allow send_destination="fi.w1.wpa_supplicant1"/> <allow send_interface="fi.w1.wpa_supplicant1"/> <allow receive_sender="fi.w1.wpa_supplicant1" receive_type="signal"/> </policy> <policy context="default"> <deny own="fi.epitest.hostap.WPASupplicant"/> <deny send_destination="fi.epitest.hostap.WPASupplicant"/> <deny send_interface="fi.epitest.hostap.WPASupplicant"/> <deny own="fi.w1.wpa_supplicant1"/> <deny send_destination="fi.w1.wpa_supplicant1"/> <deny send_interface="fi.w1.wpa_supplicant1"/> <deny receive_sender="fi.w1.wpa_supplicant1" receive_type="signal"/> </policy> </busconfig>