rfkill 無線設備軟開關

最近在調試無線軟AP軟件 hostapd 時遇到個錯誤,總是無法啓動服務。

調試輸出如下:

[root@server ~]# /usr/sbin/hostapd /etc/hostapd/hostapd.conf -d
……省略……
Could not set interface wlp2s0 flags (UP): Operation not possible due to RF-kill
nl80211: Failed to set interface up after switching mode
……省略……

那 RF-kill 是什麼呢?

這裏是 rfkill 相關介紹:

rfkill - RF kill switch support (翻譯)


好吧,先搜索 rfkill 相關的軟件包。

yum search rfkill
[root@server ~]# yum search rfkill
已加載插件:fastestmirror, remove-with-leaves
Loading mirror speeds from cached hostfile
============================ N/S matched: fkill ============================
rfkill.x86_64 : A tool for enabling and disabling wireless devices

這裏也可以看出 rfkill 是一個啓用/禁用無線設備的工具,也就是一個無線設備軟開關。

接下來安裝 rfkill 軟件包。

yum install rfkill

看看 rfkill 有哪些文件。

rpm -ql rfkill
[root@server ~]# rpm -ql rfkill
/sbin/rfkill
/usr/share/doc/rfkill
/usr/share/doc/rfkill/COPYING
/usr/share/doc/rfkill/README
/usr/share/man/man8/rfkill.8.gz

從輸出來看看來就主要一個可執行文件 rfkill。

man rfkill 看看 rfkill 的用法。

man 8 rfkill
[root@server ~]# man 8 rfkill
……簡要輸出……
       rfkill command
COMMANDS
       help   Show rfkill's built-in help text.
       event  Listen for rfkill events and display them on stdout.
       list [type]                             #查看設備狀態
              List the current state of all available rfkill-using devices, 
              or just all of the given type.
       block index|type                        #關閉開關操作
              Disable  the  device corresponding to the given index.  
              type is one of "all", "wifi", "wlan", "bluetooth", "uwb", 
              "ultrawideband", "wimax", "wwan", "gps", "fm" or "nfc".
       unblock index|type                      #開啓開關操作
              Enable the device corresponding to the given index. 
              If the device is hard-blocked, e.g. via a hardware switch, 
              it will  remain  unavailable though it is now soft-unblocked.

那麼接下來就看看有沒有無線設備被關掉。

rfkill list
[root@server ~]# rfkill list
0: phy0: Wireless LAN
        Soft blocked: yes              #開關開啓,無線網卡無法使用
        Hard blocked: no

解鎖操作

rfkill unblock wlan
[root@server ~]# rfkill unblock wlan

再次查看

rfkill list
[root@server ~]# rfkill list
0: phy0: Wireless LAN
        Soft blocked: no               #此時已關閉,可以使用無線網卡
        Hard blocked: no

再次運行調試模式

/usr/sbin/hostapd /etc/hostapd/hostapd.conf -d

OK一切正常,那麼就可以結束調試以正常模式啓動服務了。


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章