运行wpa_cli重新配置时“无法连接到非全局ctrl_ifname”


18

我正在使用运行Debian Jessie的Raspberry Pi 2,并且在设置我的Wi-Fi连接后遇到问题/etc/network/interfaces

    # interfaces(5) file used by ifup(8) and ifdown(8)
    # Include files from /etc/network/interfaces.d:
    source-directory /etc/network/interfaces.d

    # uncomment the next 4 lines and set the correct wpa-ssid (network ssid) and
    auto lo
    iface lo inet loopback
    iface eth0 inet manual
    allow-hotplug wlan0
    iface wlan0 inet manual
         wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant


network={
    ssid="Abass"
    psk="AMSH19691977"
}

然后运行wpa_cli reconfigure。我收到错误,Failed to connect to non-global ctrl_ifname: (null) error: No such file or directory因此需要帮助。我该如何解决?

Answers:


10

这对我有用

sudo nano / etc / network / interfaces
并添加以下行

auto wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
文件看起来像这样

country=GB
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
ssid="your ssid"
psk="your wifi password"
}

来源https://www.domoticz.com/forum/viewtopic.php?t=10930


2

除了在/ etc / network / interfaces中我有两个接口并更新错误的接口外,我遇到了类似的问题!确保您正在更新正确的界面。

我有以下内容,并且在需要更新wlan0时正在更新wlan1:

iface wlan0 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

iface wlan1 inet static
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

2

我有12个以上的RPis集群,我正在无头初始化。相同的确切图像在某些消息上有效,而在其他消息上则无效:

Failed to connect to non-global ctrl_ifname: wlan0  error: No such file or directory

这是我在做wifi配置的方法:

#### Wifi Setup (WPA Supplicant)
##  Replaces the magic of https://github.com/RPi-Distro/raspberrypi-net-mods/blob/master/debian/raspberrypi-net-mods.service
##  See: https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
cat > /etc/wpa_supplicant/wpa_supplicant.conf << EOF
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US

network={
    ssid="wifi name goes here"
    psk="password goes here"
}
EOF
chmod 600 /etc/wpa_supplicant/wpa_supplicant.conf
wpa_cli -i wlan0 reconfigure

由于这是给出错误的最后一行,因此我将其替换为:

until wpa_cli -i wlan0 reconfigure; do
  echo "Failed to reconfigure wlan0 with wpa_cli."
  echo "Restarting dhcpcd with systemctl."
  systemctl restart dhcpcd
done

我从来没有让它循环过一次以上,但是我把until它放在那儿以防万一它第一次没有响应。但是,这带有永不逃避的风险。对于我的需要,我不希望脚本在没有互联网连接的情况下继续运行。您可以决定什么对您有用。单遍实现可能看起来像这样:

wpa_cli -i wlan0 reconfigure || ( systemctl restart dhcpcd; wpa_cli -i wlan0 reconfigure; )

1
很棒的答案!在循环中,我必须在sleep 5之后插入systemctl restart dhcpcd,因为dhcp.service抱怨启动请求重复的速度太快
mcguffin

-1

我将GOOGLE的IP添加到DNS中解决了我的问题,因为这是问题所在


4
您能否在答案中添加一些细节并将其标记为正确
Darth Vader

1
这怎么可能?这完全无关紧要。您能解释一下为什么您认为这是解决方案吗?
亚历克斯于
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.