3

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 wpa_supplicant@wlan0.service
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 Raspbian – dazz Oct 7 '18 at 0:20
  • Stretch Lite. It is a headless system. – dazz Oct 7 '18 at 1:16
5

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> wpa_supplicant@wlan0.service

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 wpa_supplicant@wlan0.service

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 wpa_supplicant@wlan0.service
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 Oct 8 '18 at 4:03
  • @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 Oct 8 '18 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 Mar 10 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 Mar 10 at 19:13

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.