I am trying to debug setting up wifi with networkd-systemd managing wpa_supplicant. The overall objective is to get wifi AP and managed client modes working at the same time. I can get managed client working. I can't get the AP mode working.
To help achieve the objective I want to restart both networkd and wpa_supplicant in debug modes. Research with Google found a number of different answers. It appears that some of those answers are now out of date.
From what I can find, the commands
systemctl stop networking.service
systemctl restart networking.service
do a normal stop/restart but I have also found this command
systemctl restart systemd-networkd
The following is mish/mash from different answers to get debug turned on but I don't know if it is the best or correct way to get into debug mode.
systemctl stop [email protected]
systemctl stop systemd-networkd.service
wpa_supplicant -dd -u -f $LOG -B
echo Running wpa-supplicant in debug mode.
(Edit) The OS is Raspbian Stretch-Lite. I have removed networkmanager from the above code.
-
I am using Raspbiandazz– dazz2018年10月07日 00:20:15 +00:00Commented Oct 7, 2018 at 0:20
-
Stretch Lite. It is a headless system.dazz– dazz2018年10月07日 01:16:49 +00:00Commented Oct 7, 2018 at 1:16
1 Answer 1
First to shine a light on this mish/mash of different commands. On Raspbian there are three concurrent network environments installed: old style debian networking with ifupdown
is configured in etc/network/interfaces
but it is deprecated. The default networking environment of Raspbian is managed by dhcpcd and configured in /etc/dhcpcd.conf
. Old style networking is configured to give dhcpcd precedence but if it is used it partial overwrites settings from dhcpcd.
And there is a third network environment sleeping in the background: systemd-networkd that is managed with files in directory /etc/systemd/network/
. It is there because it is build-in to systemd, the default init system of Raspbian. It is not very good to manage mobile devices but with static devices it is very powerful. To use it you have to completely switch over to systemd-networkd and disable both other networking systems.
And to make it a bit more confusing: all three networking systems using wifi manager wpa_supplicant
as helper, each in an other way.
First of all you have to decide what networking system you want to use. The services of all three systems are managed by systemd, of course. With
rpi ~$ systemctl <command> networking.service
you manage old style networking service. With
rpi ~$ systemctl <command> dhcpcd.service
you manage dhcpcd service, and with
rpi ~$ systemctl <command> systemd-networkd.service
You manage that service. wpa_supplicant is only good managed and integrated in systemd when using systemd-networkd with:
rpi ~$ systemctl <command> [email protected]
I don't know how good it can be managed with networking by using
rpi ~$ systemctl <command> wpa_supplicant.service
but with dhcpcd the wpa_supplicant service is definitely not manageable with systemd. With dhcpcd the command
rpi ~$ systemctl status wpa_supplicant.service
shows you that it is disabled but in real it is active to manage wifi.
Now to come to debugging. If you really want to do that in general you can look at www/Software/systemd/Debugging. For systemd-networkd only you can improve its log level by setting an environment variable for this service.
rpi ~$ sudo systemctl edit systemd-networkd.service
and insert this into the empty editor, save and quit it:
[Service]
Environment=SYSTEMD_LOG_LEVEL=debug
This will improve the log messages from systemd-networkd into the journal. You can get them with:
rpi ~$ journalctl --boot --unit=systemd-networkd
Don't forget to disable improved logging with:
rpi ~$ sudo rm -r /etc/systemd/system/systemd-networkd.service.d/
For debugging wpa_supplicant you do it the best in the forground because you have a lot of output. First look what command is executed by the service with:
rpi ~$ systemctl cat [email protected]
You will find a line something like:
ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I
Replace placeholder %I with wlan0, add the debug option -d
and start it:
rpi ~$ sudo systemctl stop [email protected]
rpi ~$ sudo /sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-wlan0.conf -Dnl80211,wext -iwlan0 -d
-
This is broadly correct, but both Debian networking and dhcpcd will both allocate addresses (if anyone is silly enough to attempt this) - with unpredictable results, although they can be used in parallel on different interfaces. dhcpcd will disable itself if it discovers another system calling dhcp. dhcpcd has its own hook to call wpa_supplicant, but this was omitted in Jessie.Milliways– Milliways2018年10月08日 04:03:17 +00:00Commented Oct 8, 2018 at 4:03
-
1@Milliways Yes I know, but it all doesn't matter with systemd-networkd. I only wanted to give an overview without much details like dhcpcd vs /etc/network/interfaces.Ingo– Ingo2018年10月08日 08:15:43 +00:00Commented Oct 8, 2018 at 8:15
-
For HypriotOS (Raspbian-based), is there something else to consider in the ways network is managed ? cloud-init is now used on HypriotOS.Uriel– Uriel2019年03月10日 15:09:39 +00:00Commented Mar 10, 2019 at 15:09
-
@Uriel Because HypriotOS is a Raspbian derivate it should also have three network environments. But I don't know HypriotOS and what networking system it uses.Ingo– Ingo2019年03月10日 19:13:49 +00:00Commented Mar 10, 2019 at 19:13
-
Without drawing you too far off course, can you explain briefly how
systemd-resolved
fits in with all of this, and why it's not used on RPi? Don't waste much time on this... and if you'd prefer, I can post it as a new question.Seamus– Seamus2020年06月09日 00:12:27 +00:00Commented Jun 9, 2020 at 0:12