Setup: rasbian raspberry pi 4.4.14-v7+ with systemd for network related stuff.

Using the internal broadcom wifi

Access Point: Another RPi3 with Hostapd 1:2.3-1+deb8u3 and 4.4.14-v7+

I will refer to "client" as the RPI which is trying to connect to the Hostapd Access Point (WPA2)

The Hostapd uses an isc-dhcp-server on the wifi interface which works fine (sends leases, renews them, DHCPACK etc..)


I am unable to accept the fallback mode via /etc/network/interfaces or similiar setups via f.e. ifplugd, which rely on that file.

Currently we use dhclient instead of the default dhcpcd.

Out of the questions are other network managers as well as any graphical tools.


The client needs a full reboot to have wifi working again if the Access Point is not reachable for a short time (reboot, power loss, something like that)

i am not connected to the AP via wpa_supplicant at that point. (hostapd_cli all_sta does not show my Wifi MAC of the client)

iwconfig wlan0 wlan0 IEEE 802.11bgn ESSID:off/any
Mode:Managed Access Point: Not-Associated Tx-Power=31 dBm
Retry short limit:7 RTS thr:off Fragment thr:off Encryption key:off Power Management:off

The "old" version of solving this is either via ifplugd scripts (ifup/ifdown actions) and/or having set wpa-roam in /etc/network/interfaces and using the compatibility layer "networking.service - LSB: Raise network interfaces."

Another option would be to use a cronjob to detect the failing connection and restart $SOMETHING.

Sadly i was unable to figure out what that $SOMETHING is.

As i only want to use the systemd-network way i did not load the "networking" unit.

It seems to me that wpa_supplicant does try to scan for the AP again, but somehow rejects the matching AP SSID.

Here are the settings.

loaded services:

systemctl -t service

UNIT                               LOAD   ACTIVE SUB     DESCRIPTION
bluetooth.service                  loaded active running Bluetooth service
console-setup.service              loaded active exited  LSB: Set console font and keymap
cron.service                       loaded active running Regular background program processing daemon
dbus.service                       loaded active running D-Bus System Message Bus
dphys-swapfile.service             loaded active exited  LSB: Autogenerate and use a swap file
fake-hwclock.service               loaded active exited  Restore / save the current clock
getty@tty1.service                 loaded active running Getty on tty1
hciuart.service                    loaded active running Configure Bluetooth Modems connected by UART
hdparm.service                     loaded active exited  LSB: Tune IDE hard disks
kbd.service                        loaded active exited  LSB: Prepare console
keyboard-setup.service             loaded active exited  LSB: Set preliminary keymap
kmod-static-nodes.service          loaded active exited  Create list of required static device nodes for the current kernel
network-wireless@wlan0.service     loaded active exited  Wireless network connectivity (wlan0)
ntp.service                        loaded active running LSB: Start NTP daemon
openvpn.service                    loaded active exited  OpenVPN service
postfix.service                    loaded active running LSB: Postfix Mail Transport Agent
raspi-config.service               loaded active exited  LSB: Switch to ondemand cpu governor (unless shift key is pressed)
rc-local.service                   loaded active running /etc/rc.local Compatibility
rsyslog.service                    loaded active running System Logging Service
ssh.service                        loaded active running OpenBSD Secure Shell server
systemd-fsck-root.service          loaded active exited  File System Check on Root Device
systemd-fsck@dev-mmcblk0p1.service loaded active exited  File System Check on /dev/mmcblk0p1
systemd-journald.service           loaded active running Journal Service
systemd-logind.service             loaded active running Login Service
systemd-modules-load.service       loaded active exited  Load Kernel Modules
systemd-networkd.service           loaded active running Network Service
systemd-random-seed.service        loaded active exited  Load/Save Random Seed
systemd-remount-fs.service         loaded active exited  Remount Root and Kernel File Systems
systemd-rfkill@rfkill0.service     loaded active exited  Load/Save RF Kill Switch Status of rfkill0
systemd-rfkill@rfkill1.service     loaded active exited  Load/Save RF Kill Switch Status of rfkill1
systemd-setup-dgram-qlen.service   loaded active exited  Increase datagram queue length
systemd-sysctl.service             loaded active exited  Apply Kernel Variables
systemd-tmpfiles-setup-dev.service loaded active exited  Create Static Device Nodes in /dev
systemd-tmpfiles-setup.service     loaded active exited  Create Volatile Files and Directories
systemd-udev-trigger.service       loaded active exited  udev Coldplug all Devices
systemd-udevd.service              loaded active running udev Kernel Device Manager
systemd-update-utmp.service        loaded active exited  Update UTMP about System Boot/Shutdown
systemd-user-sessions.service      loaded active exited  Permit User Sessions
triggerhappy.service               loaded active running LSB: triggerhappy hotkey daemon
udev-finish.service                loaded active exited  Copy rules generated while the root was ro
user@0.service                     loaded active running User Manager for UID 0

cat /etc/systemd/network/00-wireless.network

#General configuration wlan0

i did set some additional debug info in /var/log/wpa_supplicant.log so th ExecStart is a bit longer than usual.

cat /etc/systemd/system/network-wireless@.service

Description=Wireless network connectivity (%i)


ExecStart=/sbin/ip l set %i up
ExecStart=/sbin/wpa_supplicant -t -dd -f /var/log/wpa_supplicant.log -dd -B -i %i -c /etc/wpa_supplicant/wpa_supplicant.conf
ExecStart=/sbin/dhclient %i

ExecStop=/sbin/ip l set %i down


cat /etc/wpa_supplicant/wpa_supplicant.conf

ctrl_interface=/var/run/wpa_supplicant GROUP=netdev

some logs:

booting the client:

systemctl status network-wireless@wlan0.service

● network-wireless@wlan0.service - Wireless network connectivity (wlan0)
Loaded: loaded (/etc/systemd/system/network-wireless@.service; enabled)
Active: active (exited) since Fri 2016-08-05 12:21:17 CEST; 3min 32s ago
Process: 431 ExecStart=/sbin/dhclient %i (code=exited, status=0/SUCCESS)
Process: 425 ExecStart=/sbin/wpa_supplicant -t -dd -f /var/log/wpa_supplicant.log -dd -B -i %i -c /etc/wpa_supplicant/wpa_supplicant.conf (code=exited, status=0/SUCCESS)
Process: 387 ExecStart=/sbin/ip l set %i up (code=exited, status=0/SUCCESS)
Main PID: 431 (code=exited, status=0/SUCCESS)

booting client (everything OK, connection stable and working for hours/days on previous tests)

journalctl -u network-wireless@wlan0.service -b

-- Logs begin at Fri 2016-08-05 12:21:05 CEST, end at Fri 2016-08-05 12:22:53 CEST. --
Aug 05 12:21:08 testclient systemd[1]: Starting Wireless network connectivity (wlan0)...
Aug 05 12:21:09 testclient dhclient[431]: DHCPREQUEST on wlan0 to port 67
Aug 05 12:21:13 testclient dhclient[431]: DHCPREQUEST on wlan0 to port 67
Aug 05 12:21:17 testclient dhclient[431]: DHCPREQUEST on wlan0 to port 67
Aug 05 12:21:17 testclient dhclient[431]: DHCPACK from
Aug 05 12:21:17 testclient dhclient[431]: bound to -- renewal in 60 seconds.
Aug 05 12:21:17 testclient systemd[1]: Started Wireless network connectivity (wlan0).
Aug 05 12:22:17 testclient dhclient[549]: DHCPREQUEST on wlan0 to port 67
Aug 05 12:22:17 testclient dhclient[549]: DHCPACK from
Aug 05 12:22:17 testclient dhclient[549]: bound to -- renewal in 53 seconds.

rebooting the AP:

Aug  5 12:26:55 testclient systemd-networkd[422]: wlan0           : lost carrier
Aug  5 12:26:55 testclient dhclient: DHCPREQUEST on wlan0 to port 67
Aug  5 12:27:00 testclient dhclient: DHCPREQUEST on wlan0 to port 67
Aug  5 12:27:12 testclient dhclient: DHCPREQUEST on wlan0 to port 67
Aug  5 12:27:32 testclient dhclient: DHCPREQUEST on wlan0 to port 67

this leads me to believe that i am missing an option on "lost carrier" in the systemd-network unit to restart the wireless service.

What part did i miss or where can i get more info if my search skills on SE and google did fail me. Thanks.

note: according to the raspberrypi.se help i should not use the rpi se site but UX, which i did. Please move if i misunderstood the part of "Questions directly related to Linux/Unix issues. Please use the Unix & Linux Exchange. "

multiple references i tried, however most of them are either outdate or did not help me in my situation.

https://raspberrypi.stackexchange.com/questions/4120/how-to-automatically-reconnect-wifi https://wiki.archlinux.org/index.php/WPA_supplicant



Auto reconnect to wifi once disconnected?

Trying to understand Auto reconnect WIFI method

Systemd Unit for reconnecting wireless on failure

Your Answer

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

Browse other questions tagged or ask your own question.