10

I am using a Raspberry Pi 2, running Debian Jessie, and I have a problem with my Wi-Fi connection, after setting my /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

and wpa_supplicant.conf:

ctrl_interface=/var/run/wpa_supplicant


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

then running wpa_cli reconfigure. I get the error, Failed to connect to non-global ctrl_ifname: (null) error: No such file or directory so need help. How can I resolve this?

5

This worked for me

sudo nano /etc/network/interfaces
and add the following lines

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

sudo nano /etc/wpa_supplicant/wpa_supplicant.conf
file looks like this

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

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

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

2

I had a similar problem except for in /etc/network/interfaces I had two interfaces and was updating the wrong one! Ensure you're updating the correct interface.

I had the following and was updating wlan1 when I needed to update wlan0:

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

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

I solved my problem by adding the IP of GOOGLE to DNS because it was the problem

  • 4
    Could you please add some detail to your answer and mark it as correct – Darth Vader Dec 25 '17 at 12:32
  • How this could be possible? It's totally unrelated matter. Could you explain why do you think it was the solution? – Alex Yu Jul 28 at 10:31
0

I have a cluster of 12+ RPis that I am initializing headlessly. The same exact image works on some and fails on others with the message:

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

This is how I'm doing the wifi config:

#### 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

Since it was the last line that was giving the error, I replace it with this:

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

I've never had it loop through more than once, but I put the until there just in case it didn't respond the first time. But, that comes with the risk of never escaping. For my need, I don't want the script to continue without an internet connection. You can decide what works for you. A single pass implementation might look like this:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.