Table of Contents
Raspberry Pi problem: dhcpcd not starting wpa_supplicant
I got a problem with a Realtek RTL8188EUS UBS WiFi dongle, into a Raspberry Pi Model A+, running Rasbpian 2017-11-29 Stretch Lite (based on Debian 9.1).
The new method used by Raspbian to configure the network interfaces involves dhcpcd, so the /etc/network/interfaces should be almost empty, with just the following:
There are no allow-hotplug or auto sections anymore; everything should be managed by dhcpcd, even the start of wpa_supplicant. Which indeed was failing.
First of all I added some debug to dhcpcd: just adding the option -d to the dhcpcd ExecStart into /etc/systemd/system/dhcpcd.service.d/wait.conf. After executing systemctl daemon-reload and a reboot, this was the log:
daemon.debug dhcpcd: dhcpcd-6.11.5 starting daemon.debug dhcpcd: udev: starting daemon.info dhcpcd: dev: loaded udev daemon.debug dhcpcd: wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' PREINIT daemon.debug dhcpcd: wlan0: executing `/lib/dhcpcd/dhcpcd-run-hooks' NOCARRIER daemon.info dhcpcd: wlan0: waiting for carrier daemon.err dhcpcd: timed out daemon.debug dhcpcd: forking to background
So no wpa_supplicant was fired, the wlan0 interface does not sense the carrier and dhcpcd refuses to configure it. It seems that dhcpcd does not aknowledge that it is a WiFi adapter, so we have to force it. Just add an interface section into /etc/dhcpcd.conf:
interface wlan0 env ifwireless=1 env wpa_supplicant_driver=nl80211,wext
the driver specification is required, otherwise wpa_supplicant will die with the error message
nl80211: Driver does not support authentication/association or connect commands nl80211: deinit ifname=wlan0 disabled_11b_rates=0 wlan0: Failed to initialize driver interface
After a reboot everything worked as expected, which is confirmed by the wpa_supplicant process running:
wpa_supplicant -B -c/etc/wpa_supplicant/wpa_supplicant.conf -iwlan0 -Dnl80211,wext
Notice that the configuration file used is /etc/wpa_supplicant/wpa_supplicant.conf, but if one named wpa_supplicant-wlan0.conf exists, it will be preferred.
Alternative: wpa_supplicant started by systemd
The default is to start wpa_supplicant via dhcpcd, as seen above. But if you want, you can force systemd to start the service independently.
You have to start the interface-specific service against the name wlan0, so make the following:
mv /etc/wpa_supplicant/wpa_supplicant.conf /etc/wpa_supplicant/wpa_supplicant-wlan0.conf systemctl enable email@example.com
After a reboot you should see the wpa_supplicant process running, and dhcpcd will configure wlan0 happily.