0

I had the wifi on my raspi 3B working perfectly for about 2 years. I then saw I had two wpa_supplicant.conf files:

/etc/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf

I briefly checked both files and as far as I remember they were the same (but not sure anymore). So I deleted /etc/wpa_supplicant/wpa_supplicant.conf and then wifi didn't work anymore. So I did

sudo cp /etc/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant.conf

After a reboot, wifi still didn't work. So I double checked whether the ssid and password are correct in those files (they are). I also used sudo iwlist wlan0 scan to check whether the raspi finds/sees my wifi network (it does). After that I've been changing all sorts of things in those wpa_supplicant.conf files and in /etc/network/interfaces. After every change I reboot the pi and disconnect the ethernet cable and check the UI of my router to see if it connects. After about two hours banging my head against the wall it still doesn't work and I'm really out of ideas.

The current situation is as follows:

/etc/network/interfaces:

source-directory /etc/network/interfaces.d

auto lo
iface lo inet loopback

iface eth0 inet dhcp

allow-hotplug wlan0
iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

/etc/wpa_supplicant.conf and /etc/wpa_supplicant/wpa_supplicant.conf:

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

network={
    ssid="my_awesome_network"
    psk="my_password"
}

Does anybody have any idea what could be wrong here? Are there any logs that I can check to debug this further? All tips are welcome!

[EDIT]

Ok, so I found out that I've got a Raspi 3B (not the 3B+) and I'm on Raspbian Stretch. I checked out the post that @milliways linked to and made my files look exactly like they say:

I deleted /etc/network/interfaces and /etc/wpa_supplicant/wpa_supplicant.conf looks like this:

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

network={
    ssid="my_network"
    psk="my_password"
}

After rebooting the raspi it still doesn't connect to the wifi.

Any more ideas?

[EDIT 2]

So as suggested by @goldilocks I logged in and ran

sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -d

which resulted in this output. In there it says it Failed to add interface wlan0. After some searching I found this post which suggested to check whether wpa_supplicant is already running on wlan0. So I did

ps aux | grep supplicant

which showed me it was already running indeed. I then killed that process and then ran this again.

sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -d

AND YES! It's running!!

Okay, no need for the capslock, because after a reboot wifi still isn't set up automatically. So I can now get wifi running by booting with the ethernet cable attached, ssh'ing into the pi, kill the existing wpa_supplicant process and then starting it with the command I pasted above. I can then disconnect the ethernet cable and ssh into the pi over wifi.

Any ideas how can get it running correctly after booting up?

[EDIT 3]

Following the instructions of @Milliways I booted the Pi up from scratch with the ethernet cable attached, ssh'ed into it and then ran systemctl status dhcpcd. The result:

● dhcpcd.service - LSB: IPv4 DHCP client with IPv4LL support
   Loaded: loaded (/etc/init.d/dhcpcd; generated; vendor preset: enabled)
  Drop-In: /etc/systemd/system/dhcpcd.service.d
           └─wait.conf
   Active: active (running) since Sat 2019-05-04 23:17:13 CEST; 9h ago
     Docs: man:systemd-sysv-generator(8)
  Process: 345 ExecStart=/sbin/dhcpcd -q -w (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/dhcpcd.service
           └─789 /sbin/dhcpcd -q -w

May 04 23:17:04 raspberrypi dhcpcd[345]: wlan0: soliciting a DHCP lease
May 04 23:17:04 raspberrypi dhcpcd[345]: wlan0: carrier lost
May 04 23:17:04 raspberrypi dhcpcd[345]: wlan0: deleting address fe80::bbd4:7378:8a28:43b9
May 04 23:17:05 raspberrypi dhcpcd[345]: wlan0: new hardware address: 66:60:38:2a:89:7d
May 04 23:17:08 raspberrypi dhcpcd[345]: eth0: probing address 192.168.0.100/24
May 04 23:17:13 raspberrypi dhcpcd[345]: eth0: leased 192.168.0.100 for 7200 seconds
May 04 23:17:13 raspberrypi dhcpcd[345]: eth0: adding route to 192.168.0.0/24
May 04 23:17:13 raspberrypi dhcpcd[345]: eth0: adding default route via 192.168.0.1
May 04 23:17:13 raspberrypi systemd[1]: Started LSB: IPv4 DHCP client with IPv4LL support.
May 04 23:17:19 raspberrypi dhcpcd[789]: eth0: no IPv6 Routers available
Warning: dhcpcd.service changed on disk. Run 'systemctl daemon-reload' to reload units.

So dhcpcd seems to be running fine. The contents of /etc/dhcpcd.conf are:

# A sample configuration for dhcpcd.
# See dhcpcd.conf(5) for details.

# Allow users of this group to interact with dhcpcd via the control socket.
#controlgroup wheel

# Inform the DHCP server of our hostname for DDNS.
hostname

# Use the hardware address of the interface for the Client ID.
#clientid
# or
# Use the same DUID + IAID as set in DHCPv6 for DHCPv4 ClientID as per RFC4361.
# Some non-RFC compliant DHCP servers do not reply with this set.
# In this case, comment out duid and enable clientid above.
duid

# Persist interface configuration when dhcpcd exits.
persistent

# Rapid commit support.
# Safe to enable by default because it requires the equivalent option set
# on the server to actually work.
option rapid_commit

# A list of options to request from the DHCP server.
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
# Most distributions have NTP support.
option ntp_servers
# Respect the network MTU. This is applied to DHCP routes.
option interface_mtu

# A ServerID is required by RFC2131.
require dhcp_server_identifier

# Generate Stable Private IPv6 Addresses instead of hardware based ones
slaac private

The folder /usr/lib/dhcpcd/dhcpcd-hooks/ doesn't exist (/usr/lib/dhcpcd/ doesn't even exist).

So where can I go from here? Do I need to write a hook to get the wifi started?

  • Post the output of systemctl status dhcpcd. DO NOT run wpa_supplicant - it should be invoked by a hook in dhcpcd. (goldilocks does not use the standard Raspbian network manager dhcpcd) include the post in your question - NOT an external link – Milliways May 4 at 23:00
  • @Milliways - I added the result of systemctl status dhcpcd to the question under [EDIT 3]. I aslo included the contents of /etc/dhcpcd.conf. Btw, I'm learning a lot from you here, so next to wanting to solve the problem, this is actually really interesting! – kramer65 May 5 at 7:05
  • You can't have two instances of wpa_supplicant running, so there's not much harm in trying to start one. It is not an ideal way to do things, but if there is some problem that is preventing the system from operating normally, it may help to isolate whatever that is. – goldilocks May 5 at 10:36
  • Regardless of which model you have, make sure you are running Raspian 9 (stretch) and not an older version; cat /etc/issue will tell you this. – goldilocks May 5 at 10:42
2

You can't have been using a "3B+ … for about 2 years" because it was only released just over a year ago.

The /etc/network/interfaces file you are using is obsolete, and would never have worked properly, even in Jessie.

Stretch (which was released in August 2017) uses different networking.

The 3B+ only works with firmware introduced in Stretch.

See How to set up networking/WiFi which shows the correct contents of these files.

NOTE "country" is mandatory for WiFi support on the Pi3B+.


It is difficult to know what to suggest. The output of your systemctl status dhcpcd looks like nothing I have seen; init.d is obsolete, and the process should be started with a normal systemd service - mine is listed below (from Raspberry Pi reference 2017-08-16 - fully updated). Unless you have an old Jessie OS with an unsupported update it is difficult to explain.

● dhcpcd.service - dhcpcd on all interfaces
   Loaded: loaded (/lib/systemd/system/dhcpcd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-05-03 16:07:26 AEST; 2 days ago
  Process: 338 ExecStart=/usr/lib/dhcpcd5/dhcpcd -q -b (code=exited, status=0/SUCCESS)
 Main PID: 368 (dhcpcd)
   CGroup: /system.slice/dhcpcd.service
           ├─368 /sbin/dhcpcd -q -b
           └─437 wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext

The hook is /lib/dhcpcd/dhcpcd-hooks/10-wpa_supplicant which is part of Stretch installation


If you don't have the hook you could use the /etc/network/interfaces used by Jessie (listed in the link above), although, if you are using Stretch, I don't know why it is missing.

  • You were right! Turns out I have a 3B, not a 3B+. I've followed your tips (described in more detail in the edits in my question). I can get it working by killing the wpa_supplicant process and then restarting it. But I need to do that every time after a reboot. Any idea how I can get it running automatically? – kramer65 May 4 at 21:08
1

Are there any logs that I can check to debug this further?

The procedure below may interfere or be interfered with by the system networking daemon, whatever it currently is (I've lost track of this on Raspbian as have my own way of doing things). Anyway:

sudo wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -i wlan0 -d

This will run in the foreground so you can read the debugging output (-d, although there is possibly enough without that, and conversely, you can get more with -dd).

If that seems to work, from another terminal:

sudo dhclient -d -v wlan0

If dhclient isn't installed, sudo apt install isc-dhcp-client. Pretty sure it is by default but it isn't used (dhcpcd plays that role).

If it is installed and it fails (e.g., by timing out without getting a lease), check /var/lib/dhcp and delete anything you find there. These are lease records which I've noticed sometimes screw up the negotiation (although they shouldn't, but I've never investigated who is to blame for this, dhclient or the router).

This may get you online, which doesn't exactly solve your problem, or it may provide some clues about what your problem is.

  • I ran the first command. Here's a paste of the command: pastebin.com/fAWnxv57 . I guess an important line is this one: Failed to add interface wlan0. Could it be a problem that I've got the ethernet cable attached and I'm SSH'ed into the pi to run this command? Maybe it cannot connect twice to the same network (both over Ethernet cable and over wifi)? Would you have any idea what this output tells us? – kramer65 May 4 at 20:27
  • Ok thanks to your ideas I got a bit further. I can kill the existing wpa_supplicant process and then start it again with your command. I then have wifi running. After a reboot wifi doesn't work anymore though. I need to kill and restart the process manually again (I described this in more detail in the second edit of my question). Any ideas how I can get it running after booting up? – kramer65 May 4 at 21:05
  • See lines 117 to 122 on your paste. Notice it refers to a file in /var/run that should only exist while wpa_supplicant is running. Check sudo ps -C wpa_supplicant; this will show whether it is actually running or not. If there are no processes and that file is there, move it temporarily (or just delete it). – goldilocks May 5 at 14:18

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.