It isn't really systemd that's being annoying here, it's NetworkManager.
You can tell NetworkManager to ignore wlan0.
There are some good ideas in this thread already.
I thought I'd add what I do to this list.
- @GChuf's method - Force NetworkManager to fail by deleting systemd files. Delete files so NetworkManager is shouting into the void. I'm not sure if this method would survive a package update.
- @Habibie's method - Force NetworkManager to fail by masking wpa_supplicant. This makes NetworkManager try a few times then give up.
- @ChalkTalk's method - Force NetworkManager to fail by turning off the radio. Looks like it runs systemd-rfkill.service.
check the default setup
The default NetworkManager setup is to try to manage whatever it can get its hands on. NetworkManager runs wpa_supplicant to manage the WIFI interface wlan0. Here it is in the process list.
[nick@rpi4 ~]$ ps -fC wpa_supplicant
UID PID PPID C STIME TTY TIME CMD
root 593 1 0 14:36 ? 00:00:00 /usr/sbin/wpa_supplicant -c /etc/wpa_supplicant/wpa_supplicant.conf -u -s
[nick@rpi4 ~]$
Wlan0 doesn't connect, and NetworkManager keeps trying.
Messages like these appear in the journal every few minutes.
[nick@rpi4 ~]$ journalctl -f
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info> [1615822023.9272] device (wlan0): set-hw-addr: set MAC address to AA:9D:10:50:87:5B (scanning)
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info> [1615822023.9359] device (wlan0): supplicant interface state: disconnected -> interface_disabled
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info> [1615822023.9362] device (p2p-dev-wlan0): supplicant management interface state: disconnected -> interface_disabled
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info> [1615822023.9367] device (wlan0): supplicant interface state: interface_disabled -> inactive
Mar 15 15:27:03 rpi4 NetworkManager[1526]: <info> [1615822023.9369] device (p2p-dev-wlan0): supplicant management interface state: interface_disabled -> inactive
The status of wlan0 is disconnected.
[nick@rpi4 ~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
wlan0 wifi disconnected --
Tell NetworkManager that wlan0 is unmanaged
Edit the NetworkManager config and tell NetworkManager to ignore wlan0.
Stop the services.
systemctl stop NetworkManager
systemctl stop wpa_supplicant
Add these lines to the bottom of the config file, /etc/NetworkManager/NetworkManager.conf.
If you want a description of what unmanaged-devices is, run man NetworkManager.conf.
[keyfile]
unmanaged-devices=interface-name:wlan0
Then run systemctl start NetworkManager.
Device state changes from disconnected to unmanaged.
The wpa_supplicant process doesn't start again, even though it's not masked.
[nick@rpi4 ~]$ nmcli device status
DEVICE TYPE STATE CONNECTION
wlan0 wifi unmanaged --
...
[nick@rpi4 ~]$ ps -fC wpa_supplicant
UID PID PPID C STIME TTY TIME CMD
[nick@rpi4 ~]$