hostapd:无法设置通道(freq = 2417):-16(设备或资源繁忙)

hostapd:无法设置通道(freq = 2417):-16(设备或资源繁忙)

我正在尝试在我的 Raspberry Pi 上设置 WiFi 接入点。我将网络接口设置为静态 IP 并安装hostapd

我正在使用这个配置:

# Interface and Driver
interface=wlan0
#driver=nl80211

# Config
ssid=AP
channel=2
hw_mode=g
ieee80211n=1
ieee80211d=1
country_code=DE
wmm_enabled=1

# Encryption
auth_algs=1
wpa=2
wpa_key_mgmt=WPA-PSK
rsn_pairwise=CCMP
wpa_passphrase=xxxxxxxxxxxxxx

但是,当我像这样运行它时,# hostapd -dd /etc/hostapd/hostapd.conf我得到以下日志:

# hostapd -dd /etc/hostapd/hostapd.conf
random: Trying to read entropy from /dev/random
Configuration file: /etc/hostapd/hostapd.conf
nl80211: interface wlan0 in phy phy0
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
nl80211: Using driver-based off-channel TX
nl80211: Add own interface ifindex 3
nl80211: Set mode ifindex 3 iftype 3 (AP)
nl80211: Failed to set interface 3 to mode 3: -95 (Operation not supported)
nl80211: Interface already in requested mode - ignore error
nl80211: Create interface iftype 6 (MONITOR)
nl80211: New interface mon.wlan0 created: ifindex=7
nl80211: Add own interface ifindex 7
BSS count 1, BSSID mask 00:00:00:00:00:00 (0 bits)
nl80211: Regulatory information - country=DE
nl80211: 2400-2483 @ 40 MHz
nl80211: 5150-5250 @ 80 MHz
nl80211: 5250-5350 @ 80 MHz
nl80211: 5470-5725 @ 160 MHz
nl80211: 5725-5875 @ 80 MHz
nl80211: 57000-66000 @ 2160 MHz
nl80211: Added 802.11b mode based on 802.11g information
Allowed channel: mode=1 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=12 freq=2467 MHz max_tx_power=20 dBm
Allowed channel: mode=1 chan=13 freq=2472 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=1 freq=2412 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=2 freq=2417 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=3 freq=2422 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=4 freq=2427 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=5 freq=2432 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=6 freq=2437 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=7 freq=2442 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=8 freq=2447 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=9 freq=2452 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=10 freq=2457 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=11 freq=2462 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=12 freq=2467 MHz max_tx_power=20 dBm
Allowed channel: mode=0 chan=13 freq=2472 MHz max_tx_power=20 dBm
Completing interface initialization
Mode: IEEE 802.11g  Channel: 2  Frequency: 2417 MHz
nl80211: Set freq 2417 (ht_enabled=1 sec_channel_offset=0)
nl80211: Failed to set channel (freq=2417): -16 (Device or resource busy)
Could not set channel for kernel driver
wlan0: Unable to setup interface.
Flushing old station entries
Could not connect to kernel driver.
Deauthenticate all stations
nl80211: Remove interface ifindex=7
netlink: Operstate: linkmode=0, operstate=6
nl80211: Set mode ifindex 3 iftype 2 (STATION)

我能发现的唯一真正的错误是:nl80211: Failed to set channel (freq=2417): -16 (Device or resource busy)

尽管我不知道如何检查将使用该设备的内容。我可能很久以前就设置过一些东西,但我不记得那是什么了。因此,我非常感谢有人能够为我指明正确的方向,或者更广泛地向我展示如何找出哪个进程正在使用该设备。

提前致谢。

答案1

解决方案一:

你可以尝试

 sudo rfkill unblock wlan

并重复

sudo hostapd /etc/hostapd/hostapd.conf

按照提议这里并在我的树莓派上进行了测试,我收到了与您相同的错误消息。
在我的例子中,hostapd 似乎已经以某种方式运行,sudo killall hostapd接下来的操作sudo hostapd /etc/hostpad/hostapd.conf也达到了目的。

解决方案二:

或者,您可以添加行

DAEMON_CONF="/etc/hostapd/hostapd.conf"

到文件

/etc/default/hostapd

并重新启动你的树莓派,然后hostapd将在启动后启用,如中所述官方文档

相关内容