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?

Ingo
  • 42,961
  • 20
  • 87
  • 207
kramer65
  • 299
  • 1
  • 3
  • 10

2 Answers2

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.

Milliways
  • 62,573
  • 32
  • 113
  • 225
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.

goldilocks
  • 60,325
  • 17
  • 117
  • 234