How to purge all network related config?

is what i talked about in the opening post

basically, even without leaving the first setup, i can’t tell you exactly what combination of settings bugs my connectivity but having both ethernet and wifi in autoassigned ip can make both interfaces just not connecting at all or having the ethernet connected but internet not working.
I just ended by having only one ssid configured, with autoassigned in both interfaces, and it just works for now, but i have spent 2 days trying to know what the hell was happening as just using very common settings made the connection just not work, not connect at all or showing as connected but no internet connection happening
i suspect it has to do with the way the dietpi network config is designed, as michaing said in github the network of a raspberry is very usually connected only by ethernet, and that is what is more tested and is more easy to program, and the wifi or even more the wifi+ethernet is not as tested
also, maybe having tried to use a 5g wifi maybe have some bug that is the origin of all my issues, is the one ssid i just gave up to configure and now its only configured to connect to a 2.4ghz ssid, now it just works reliability, but im not gonna touch anything or connect it to ethernet as i dont want to spend more hours fixing those basic network problems
maybe you can reproduce this issues testing ethernet+wifi 5g in a raspi 4
i can also say that during the setup sometimes it worked both eth+wlan connection at the same time without problems but maybe after a reboot or after adding the other ssid or something it just stopped working everything or only wifi stopped working

I was playing around with the ifplugd package. After some config attempts, my system is now able to switch between eth0 and wlan0 depending on eth0 status. As soon as a cable is connected, WiFi get deactivated. Removing the cable will activate WiFi. Working as well on boot. This way, only 1 interface is up same time.

okay i have been playing with ifplugd a little bit, i did this:
installed ifplugd, then using http://www.aoakley.com/articles/2013-07-31-raspberry-pi-networking.php i followed the Turning off WiFi when a wired network cable is plugged in, basically edited /etc/ifplugd/action.d/ifupdown and /etc/network/interfaces and the first file was just copypasted, and the second one i edited it with my ips, except i decided to not experiment using the same static ip in both interfaces for now
then i used wpa_cli to replace and have only 1 ssid (a 5G one, if that matters), and rebooted and now the thing is it looks like wpa_supplicant is not the program which is providing the ssid config to the system, because if i enter dietpi-config to monitor the status of the network connectivity, i can see that ethernet is connecting and disconnecting properly, with the ip i set in the interfaces file, but the wlan is not working as expected, it doesnt connect at all but it happens that if i connect ethernet it then connects to the wlan, at the same time (ignoring the ifplugd setting), also if i enter the wlan menu, the ssid is the old one i set yesterday (2.4g) not the one i just set, so i suppose dietpi is not using wpa supplicant, can you guide me from here? i wanna edit manually or at least monitor the config file where it is configured the ssids, and also fix the ifplugd behaviour

edit: if i boot unplugged, it just doesnt connect, it waits the 60 seconds of the ntp daemom, then it waits i think like 2 minutes of postboot script, and then i can log in, also in the welcome print of the terminal, which tells you the cpu temp and dietpi news and so on, it says LAN IP: and the static ip of my ethernet, which has not been plugged in at all during the whole process
Now after all this time and after the time i have been writing all of this, the wlan still has not connected, i can see it in the dietpi config, also if i plug the ethernet right now, i see ethernet connected but still wlan doesnt connect… i expected that after pluggin ethernet then for some reason the wlan will connect, as happened to me before several times

i dont know, if you can guide me from here i will appreciate it a lot, thanks

by the way, now with ethernet plugged in, the boot time is only about 5 seconds, compared to about 30 seconds it took before this changes (with ethernet plugged in, it always took about 30 seconds), so i dont know if all i changed today has been useful at all but this improvement is very noticeable

well the boot time depends on time sync service mainly. Sometime it takes quite long to complete. I’m facing this on all my systems. Sometimes it takes 5 sec to complete, sometimes up to 40 sec. We did not found a cause until now. Anyway this is not our topic :smiley:

Give me some time regarding ifplugd. I’m out this weekend with limited phys access to my RPi. Will try to write something probably during night. Be patient

okay thanks!

edit: im gonna leave here mi current settings.

/etc/wpa_supplicant/wpa_supplicant.conf

# Grant all members of group "netdev" permissions to configure WiFi, e.g. via wpa_cli or wpa_gui
ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
# Allow wpa_cli/wpa_gui to overwrite this config file
update_config=1
network={
        ssid="Wifi_5G"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="my wifi password"
}

network={
        ssid="Wifi24G"
        scan_ssid=1
        key_mgmt=WPA-PSK
        psk="my wifi password"
}

/etc/network/interfaces

# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Local
auto lo
iface lo inet loopback

# Ethernet
allow-hotplug eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 1.1.1.1 1.0.0.1

# WiFi
auto wlan0
iface wlan0 inet manual
wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet static
address 192.168.1.12
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 1.1.1.1 1.0.0.1
wireless-power off

/etc/ifplugd/action.d/ifupdown

  GNU nano 3.2                                                                             /etc/ifplugd/action.d/ifupdown                                                                                         

#!/bin/sh
set -e

case "$2" in
up)
        /sbin/ifup $1
        if [ "$1" == eth0 ]; then /sbin/ifdown wlan0 ; fi
        ;;
down)
        /sbin/ifdown $1
        if [ "$1" == eth0 ]; then /sbin/ifup wlan0 ; fi
        ;;
esac

Hi,

below my settings.

/etc/network/interfaces

  • basically the standard settings if you configure eth0 as well as wlan0 using dietpi-config
  • both interfaces are set to STATIC
  • on eth0, I manually set a # in front of allow-hotplug eth0 to have the feature disabled
  • quite important setting, otherwise wlan0 will not start correctly during reboot if Ethernet cable is unpluged
  • it will block eth0 to start up automatically during reboot. But not a problem as we will give this task to ifplugd to manage eth0
  • Attention: the following will lead to have wlan0 active only until we finished configuration on ifplugd
# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Local
auto lo
iface lo inet loopback

# Ethernet
#allow-hotplug eth0
iface eth0 inet static
address 192.168.0.12
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 9.9.9.9 149.112.112.112

# WiFi
allow-hotplug wlan0
iface wlan0 inet static
address 192.168.0.70
netmask 255.255.255.0
gateway 192.168.0.1
#dns-nameservers 9.9.9.9
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/ifplugd/ifplugd.action

  • completely different than the default script
  • basically it will deactivate one interface before activating another
#!/bin/sh
set -e
if [ -z "$1" ] || [ -z "$2" ] ; then
       echo "Wrong arguments" > /dev/stderr
       exit 1
fi
if [ "$1" != "eth0" ]; then
       echo "Wrong interface!" > /dev/stderr
       exit 1
fi
if [ "$2" = "up" ] ; then
       echo "bring down WiFi"
       /sbin/ifdown wlan0 --force
       /sbin/ifup eth0 --force
       exit 0
elif [ "$2" = "down" ] ; then
       echo "bring up WiFi"
       /sbin/ifdown eth0 --force
       /sbin/ifup wlan0 --force
       exit 0
fi
exit 1

/etc/default/ifplugd

  • nothing special on this
  • eth0 will be managed
  • switching from eth0 to wlan0 will be delayed by 5 sec
  • switching from wlan0 to eth0 will be done as soon as a cable was plugged in, without any delay
INTERFACES="eth0"
HOTPLUG_INTERFACES="auto"
ARGS="-q -f -u0 -d5 -w -I"
SUSPEND_ACTION="stop"

once done ifplugd service would need to be activated

  • Attention: this will immediately force a switch from wlan0 to eth0 if a cable is plugged in
systemctl enable ifplugd.service
systemctl start ifplugd.service

You can check how it’s working by doing the following

journalctl -u ifplugd.service

hmmm there must be some problem, if i start with the eth unplugged, and then plug it, unplug it and finally plug it, this is the log:

jun 21 10:17:54 DietPi systemd[1]: Starting LSB: Brings up/down network automatically...
jun 21 10:17:54 DietPi ifplugd(eth0)[438]: ifplugd 0.28 initializing.
jun 21 10:17:55 DietPi ifplugd(eth0)[438]: Using interface eth0/DC:A6:32:A9:4B:8D with driver <bcmgenet> (version: v2.0)
jun 21 10:17:55 DietPi ifplugd(eth0)[438]: Using detection mode: SIOCETHTOOL
jun 21 10:17:55 DietPi ifplugd(eth0)[438]: Initialization complete, link beat not detected.
jun 21 10:17:55 DietPi ifplugd[421]: Network Interface Plugging Daemon...start eth0...done.
jun 21 10:17:55 DietPi systemd[1]: Started LSB: Brings up/down network automatically.
jun 21 10:20:26 DietPi ifplugd(eth0)[438]: Link beat detected.
jun 21 10:20:26 DietPi ifplugd(eth0)[438]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
jun 21 10:20:26 DietPi ifplugd(eth0)[438]: client: bring down WiFi
jun 21 10:20:26 DietPi ifplugd(eth0)[438]: client: RTNETLINK answers: No such process
jun 21 10:20:26 DietPi ifplugd(eth0)[438]: client: RTNETLINK answers: Cannot assign requested address
jun 21 10:20:26 DietPi ifplugd(eth0)[438]: Program executed successfully.
jun 21 10:21:34 DietPi ifplugd(eth0)[438]: Link beat lost.
jun 21 10:21:39 DietPi ifplugd(eth0)[438]: Executing '/etc/ifplugd/ifplugd.action eth0 down'.
jun 21 10:21:39 DietPi ifplugd(eth0)[438]: client: bring up WiFi
jun 21 10:21:39 DietPi ifplugd(eth0)[438]: client: wpa_supplicant: wpa-roam can only be used with the "manual" inet METHOD
jun 21 10:21:39 DietPi ifplugd(eth0)[438]: client: run-parts: /etc/network/if-pre-up.d/wpasupplicant exited with return code 1
jun 21 10:21:39 DietPi ifplugd(eth0)[438]: client: ifup: failed to bring up wlan0
jun 21 10:21:39 DietPi ifplugd(eth0)[438]: Program execution failed, return value is 1.
jun 21 10:22:33 DietPi ifplugd(eth0)[438]: Link beat detected.
jun 21 10:22:33 DietPi ifplugd(eth0)[438]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
jun 21 10:22:33 DietPi ifplugd(eth0)[438]: client: bring down WiFi
jun 21 10:22:33 DietPi ifplugd(eth0)[438]: client: RTNETLINK answers: No such process
jun 21 10:22:33 DietPi ifplugd(eth0)[438]: client: RTNETLINK answers: Cannot assign requested address
jun 21 10:22:33 DietPi ifplugd(eth0)[438]: Program executed successfully.

okay so i change wpa-roam in my /etc/network/interfaces to wpa-conf as you have it, and looks working, but it doesnt connect to the ssids, i dont understand why:

-- Logs begin at Thu 2019-02-14 11:11:58 CET, end at Sun 2020-06-21 10:42:53 CEST. --
jun 21 10:25:03 DietPi systemd[1]: Starting LSB: Brings up/down network automatically...
jun 21 10:25:04 DietPi ifplugd(eth0)[438]: ifplugd 0.28 initializing.
jun 21 10:25:04 DietPi ifplugd(eth0)[438]: Using interface eth0/DC:A6:32:A9:4B:8D with driver <bcmgenet> (version: v2.0)
jun 21 10:25:04 DietPi ifplugd(eth0)[438]: Using detection mode: SIOCETHTOOL
jun 21 10:25:04 DietPi ifplugd(eth0)[438]: Initialization complete, link beat not detected.
jun 21 10:25:04 DietPi ifplugd[417]: Network Interface Plugging Daemon...start eth0...done.
jun 21 10:25:04 DietPi systemd[1]: Started LSB: Brings up/down network automatically.
jun 21 10:25:09 DietPi ifplugd(eth0)[438]: Link beat detected.
jun 21 10:25:09 DietPi ifplugd(eth0)[438]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
jun 21 10:25:09 DietPi ifplugd(eth0)[438]: client: bring down WiFi
jun 21 10:25:09 DietPi ifplugd(eth0)[438]: client: ifdown: waiting for lock on /run/network/ifstate.wlan0
jun 21 10:25:17 DietPi ifplugd(eth0)[438]: Program executed successfully.
jun 21 10:26:42 DietPi ifplugd(eth0)[438]: Link beat lost.
jun 21 10:26:47 DietPi ifplugd(eth0)[438]: Executing '/etc/ifplugd/ifplugd.action eth0 down'.
jun 21 10:26:47 DietPi ifplugd(eth0)[438]: client: bring up WiFi
jun 21 10:26:47 DietPi wpa_supplicant[884]: Successfully initialized wpa_supplicant
jun 21 10:26:50 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:26:52 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:26:55 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:26:58 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:26:59 DietPi ifplugd(eth0)[438]: Program executed successfully.
jun 21 10:27:01 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'Casita'
jun 21 10:27:04 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:06 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'Casita'
jun 21 10:27:09 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:12 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:27:15 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:18 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:27:21 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:21 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CasitaAP" auth_failures=1 duration=10 reason=CONN_FAILED
jun 21 10:27:29 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'Casita'
jun 21 10:27:32 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:35 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="CasitaAP"
jun 21 10:27:35 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'Casita'
jun 21 10:27:38 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:38 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=1 ssid="Casita" auth_failures=1 duration=10 reason=CONN_FAILED
jun 21 10:27:45 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:27:48 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:27:48 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CasitaAP" auth_failures=2 duration=20 reason=CONN_FAILED
jun 21 10:28:01 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-REENABLED id=1 ssid="Casita"
jun 21 10:28:01 DietPi wpa_supplicant[887]: wlan0: Failed to initiate sched scan
jun 21 10:28:08 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="CasitaAP"
jun 21 10:28:08 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:28:11 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:28:11 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CasitaAP" auth_failures=3 duration=30 reason=CONN_FAILED
jun 21 10:28:24 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'Casita'
jun 21 10:28:26 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:28:26 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=1 ssid="Casita" auth_failures=2 duration=20 reason=CONN_FAILED
jun 21 10:28:41 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="CasitaAP"
jun 21 10:28:41 DietPi wpa_supplicant[887]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 10:28:44 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 10:28:44 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CasitaAP" auth_failures=4 duration=60 reason=CONN_FAILED
jun 21 10:28:56 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-REENABLED id=1 ssid="Casita"
jun 21 10:28:56 DietPi wpa_supplicant[887]: wlan0: Failed to initiate sched scan

i have country=ES in my wpa_supplicant, maybe is because the static ip, but setting it to another one for sure not used by anyone still doesnt work
by the way, i forgot to enable the ifupd daemon as you did, and edit the default file, thats for sure the main reason it didnt work for me before, so for now everything is fixed except the wlan connection :thinking:

edit: okay, so i must use wpa-conf instead of roam if i have preset ssids: https://raspberrypi.stackexchange.com/questions/9257/whats-the-difference-between-wpa-roam-and-wpa-conf-in-the-etc-network-inte

edit: i have just changed the wlan0 to dhcp and it still doesnt connect, im just trying to connect to 2 2.4ghz ssids and the first one the password is 12345678, to discard weird character input, and so the psk is psk=“12345678”

right now i have:
/etc/wpa_supplicant/wpa_supplicant.conf

# Grant all members of group "netdev" permissions to configure WiFi, e.g. via wpa_cli or wpa_gui
ctrl_interface=DIR=/run/wpa_supplicant GROUP=netdev
# Allow wpa_cli/wpa_gui to overwrite this config file
update_config=1
country=ES
network={
        ssid="CasitaAP"
        psk="12345678"
}

network={
        ssid="Casita"
        psk="12345678"
}

/etc/network/interface

# Location: /etc/network/interfaces
# Please modify network settings via: dietpi-config
# Or create your own drop-ins in: /etc/network/interfaces.d/

# Drop-in configs
source interfaces.d/*

# Local
auto lo
iface lo inet loopback

# Ethernet
#allow-hotplug eth0
iface eth0 inet static
address 192.168.1.10
netmask 255.255.255.0
gateway 192.168.1.1
dns-nameservers 1.1.1.1 1.0.0.1

# WiFi
allow-hotplug wlan0
iface wlan0 inet dhcp
#address 192.168.1.15
#netmask 255.255.255.0
#gateway 192.168.1.1
#dns-nameservers 1.1.1.1 1.0.0.1
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

journalctl -u ifplugd.service

jun 21 11:09:59 DietPi systemd[1]: Starting LSB: Brings up/down network automatically...
jun 21 11:09:59 DietPi ifplugd(eth0)[439]: ifplugd 0.28 initializing.
jun 21 11:09:59 DietPi ifplugd(eth0)[439]: Using interface eth0/DC:A6:32:A9:4B:8D with driver <bcmgenet> (version: v2.0)
jun 21 11:09:59 DietPi ifplugd(eth0)[439]: Using detection mode: SIOCETHTOOL
jun 21 11:09:59 DietPi ifplugd(eth0)[439]: Initialization complete, link beat not detected.
jun 21 11:09:59 DietPi ifplugd[423]: Network Interface Plugging Daemon...start eth0...done.
jun 21 11:09:59 DietPi systemd[1]: Started LSB: Brings up/down network automatically.
jun 21 11:10:04 DietPi ifplugd(eth0)[439]: Link beat detected.
jun 21 11:10:04 DietPi ifplugd(eth0)[439]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
jun 21 11:10:04 DietPi ifplugd(eth0)[439]: client: bring down WiFi
jun 21 11:10:04 DietPi ifplugd(eth0)[439]: client: ifdown: waiting for lock on /run/network/ifstate.wlan0
jun 21 11:10:13 DietPi dhclient[556]: Killed old client process
jun 21 11:10:13 DietPi ifplugd(eth0)[439]: client: Killed old client process
jun 21 11:10:14 DietPi dhclient[556]: Internet Systems Consortium DHCP Client 4.4.1
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: Internet Systems Consortium DHCP Client 4.4.1
jun 21 11:10:14 DietPi dhclient[556]: Copyright 2004-2018 Internet Systems Consortium.
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: Copyright 2004-2018 Internet Systems Consortium.
jun 21 11:10:14 DietPi dhclient[556]: All rights reserved.
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: All rights reserved.
jun 21 11:10:14 DietPi dhclient[556]: For info, please visit https://www.isc.org/software/dhcp/
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: For info, please visit https://www.isc.org/software/dhcp/
jun 21 11:10:14 DietPi dhclient[556]: 
jun 21 11:10:14 DietPi dhclient[556]: Listening on LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: Listening on LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:10:14 DietPi dhclient[556]: Sending on   LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: Sending on   LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:10:14 DietPi dhclient[556]: Sending on   Socket/fallback
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: Sending on   Socket/fallback
jun 21 11:10:14 DietPi dhclient[556]: DHCPRELEASE of 192.168.1.130 on wlan0 to 192.168.1.1 port 67
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: DHCPRELEASE of 192.168.1.130 on wlan0 to 192.168.1.1 port 67
jun 21 11:10:14 DietPi dhclient[556]: send_packet: Network is unreachable
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: send_packet: Network is unreachable
jun 21 11:10:14 DietPi dhclient[556]: send_packet: please consult README file regarding broadcast address.
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: send_packet: please consult README file regarding broadcast address.
jun 21 11:10:14 DietPi dhclient[556]: dhclient.c:2878: Failed to send 300 byte long packet over fallback interface.
jun 21 11:10:14 DietPi ifplugd(eth0)[439]: client: dhclient.c:2878: Failed to send 300 byte long packet over fallback interface.
jun 21 11:10:15 DietPi ifplugd(eth0)[439]: Program executed successfully.
jun 21 11:12:13 DietPi ifplugd(eth0)[439]: Link beat lost.
jun 21 11:12:18 DietPi ifplugd(eth0)[439]: Executing '/etc/ifplugd/ifplugd.action eth0 down'.
jun 21 11:12:18 DietPi ifplugd(eth0)[439]: client: bring up WiFi
jun 21 11:12:18 DietPi wpa_supplicant[918]: Successfully initialized wpa_supplicant
jun 21 11:12:19 DietPi dhclient[926]: Internet Systems Consortium DHCP Client 4.4.1
jun 21 11:12:19 DietPi dhclient[926]: Copyright 2004-2018 Internet Systems Consortium.
jun 21 11:12:19 DietPi dhclient[926]: All rights reserved.
jun 21 11:12:19 DietPi dhclient[926]: For info, please visit https://www.isc.org/software/dhcp/
jun 21 11:12:19 DietPi dhclient[926]: 
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: Internet Systems Consortium DHCP Client 4.4.1
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: Copyright 2004-2018 Internet Systems Consortium.
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: All rights reserved.
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: For info, please visit https://www.isc.org/software/dhcp/
jun 21 11:12:19 DietPi dhclient[926]: Listening on LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:12:19 DietPi dhclient[926]: Sending on   LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:12:19 DietPi dhclient[926]: Sending on   Socket/fallback
jun 21 11:12:19 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: Listening on LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: Sending on   LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: Sending on   Socket/fallback
jun 21 11:12:19 DietPi ifplugd(eth0)[439]: client: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
jun 21 11:12:21 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 11:12:22 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
jun 21 11:12:22 DietPi ifplugd(eth0)[439]: client: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
jun 21 11:12:24 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:12:26 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
jun 21 11:12:26 DietPi ifplugd(eth0)[439]: client: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
jun 21 11:12:27 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 11:12:30 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:12:30 DietPi dhclient[926]: No DHCPOFFERS received.
jun 21 11:12:30 DietPi dhclient[926]: Trying recorded lease 192.168.1.107
jun 21 11:12:30 DietPi ifplugd(eth0)[439]: client: No DHCPOFFERS received.
jun 21 11:12:30 DietPi ifplugd(eth0)[439]: client: Trying recorded lease 192.168.1.107
jun 21 11:12:33 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'Casita'
jun 21 11:12:33 DietPi ifplugd(eth0)[439]: client: PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
jun 21 11:12:33 DietPi ifplugd(eth0)[439]: client: --- 192.168.1.1 ping statistics ---
jun 21 11:12:33 DietPi ifplugd(eth0)[439]: client: 1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
jun 21 11:12:33 DietPi dhclient[926]: No working leases in persistent database - sleeping.
jun 21 11:12:33 DietPi ifplugd(eth0)[439]: client: No working leases in persistent database - sleeping.
jun 21 11:12:33 DietPi ifplugd(eth0)[439]: Program executed successfully.
jun 21 11:12:35 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 7
jun 21 11:12:35 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:12:38 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'Casita'
jun 21 11:12:41 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:12:42 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 4
jun 21 11:12:44 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 11:12:46 DietPi dhclient[926]: No DHCPOFFERS received.
jun 21 11:12:46 DietPi dhclient[926]: Trying recorded lease 192.168.1.107
jun 21 11:12:47 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:12:49 DietPi dhclient[926]: No working leases in persistent database - sleeping.
jun 21 11:12:50 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 11:12:52 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
jun 21 11:12:53 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:12:53 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CasitaAP" auth_failures=1 duration=10 reason=CONN_FAILED
jun 21 11:12:57 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 5
jun 21 11:13:01 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'Casita'
jun 21 11:13:02 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 1
jun 21 11:13:03 DietPi dhclient[926]: No DHCPOFFERS received.
jun 21 11:13:03 DietPi dhclient[926]: Trying recorded lease 192.168.1.107
jun 21 11:13:03 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:13:07 DietPi dhclient[926]: No working leases in persistent database - sleeping.
jun 21 11:13:07 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid="CasitaAP"
jun 21 11:13:07 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'Casita'
jun 21 11:13:10 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:13:10 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=1 ssid="Casita" auth_failures=1 duration=10 reason=CONN_FAILED
jun 21 11:13:10 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
jun 21 11:13:17 DietPi wpa_supplicant[921]: wlan0: Trying to associate with SSID 'CasitaAP'
jun 21 11:13:18 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
jun 21 11:13:20 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16
jun 21 11:13:20 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid="CasitaAP" auth_failures=2 duration=23 reason=CONN_FAILED
jun 21 11:13:21 DietPi dhclient[926]: No DHCPOFFERS received.
jun 21 11:13:21 DietPi dhclient[926]: Trying recorded lease 192.168.1.107
jun 21 11:13:24 DietPi dhclient[926]: No working leases in persistent database - sleeping.
jun 21 11:13:29 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 8
jun 21 11:13:33 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-SSID-REENABLED id=1 ssid="Casita"
jun 21 11:13:33 DietPi wpa_supplicant[921]: wlan0: Failed to initiate sched scan
jun 21 11:13:37 DietPi dhclient[926]: DHCPDISCOVER on wlan0 to 255.255.255.255 port 67 interval 3
jun 21 11:13:40 DietPi dhclient[926]: No DHCPOFFERS received.
jun 21 11:13:40 DietPi dhclient[926]: Trying recorded lease 192.168.1.107
jun 21 11:13:40 DietPi ifplugd(eth0)[439]: Link beat detected.
jun 21 11:13:40 DietPi ifplugd(eth0)[439]: Executing '/etc/ifplugd/ifplugd.action eth0 up'.
jun 21 11:13:40 DietPi ifplugd(eth0)[439]: client: bring down WiFi
jun 21 11:13:40 DietPi dhclient[1125]: Killed old client process
jun 21 11:13:40 DietPi ifplugd(eth0)[439]: client: Killed old client process
jun 21 11:13:40 DietPi wpa_supplicant[921]: wlan0: Failed to initiate sched scan
jun 21 11:13:41 DietPi dhclient[1125]: Internet Systems Consortium DHCP Client 4.4.1
jun 21 11:13:41 DietPi dhclient[1125]: Copyright 2004-2018 Internet Systems Consortium.
jun 21 11:13:41 DietPi dhclient[1125]: All rights reserved.
jun 21 11:13:41 DietPi dhclient[1125]: For info, please visit https://www.isc.org/software/dhcp/
jun 21 11:13:41 DietPi dhclient[1125]: 
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: Internet Systems Consortium DHCP Client 4.4.1
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: Copyright 2004-2018 Internet Systems Consortium.
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: All rights reserved.
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: For info, please visit https://www.isc.org/software/dhcp/
jun 21 11:13:41 DietPi dhclient[1125]: Listening on LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:13:41 DietPi dhclient[1125]: Sending on   LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:13:41 DietPi dhclient[1125]: Sending on   Socket/fallback
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: Listening on LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: Sending on   LPF/wlan0/dc:a6:32:a9:4b:8e
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: Sending on   Socket/fallback
jun 21 11:13:41 DietPi dhclient[1125]: DHCPRELEASE of 192.168.1.130 on wlan0 to 192.168.1.1 port 67
jun 21 11:13:41 DietPi ifplugd(eth0)[439]: client: DHCPRELEASE of 192.168.1.130 on wlan0 to 192.168.1.1 port 67
jun 21 11:13:42 DietPi wpa_supplicant[921]: nl80211: Failed to open /proc/sys/net/ipv4/conf/p2p-dev-wlan0/drop_unicast_in_l2_multicast: No such file or directory
jun 21 11:13:42 DietPi wpa_supplicant[921]: nl80211: Failed to set IPv4 unicast in multicast filter
jun 21 11:13:42 DietPi wpa_supplicant[921]: nl80211: Failed to open /proc/sys/net/ipv4/conf/p2p-dev-wlan0/drop_unicast_in_l2_multicast: No such file or directory
jun 21 11:13:42 DietPi wpa_supplicant[921]: nl80211: Failed to set IPv4 unicast in multicast filter
jun 21 11:13:42 DietPi wpa_supplicant[921]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
jun 21 11:13:42 DietPi wpa_supplicant[921]: p2p-dev-wlan0: CTRL-EVENT-TERMINATING
jun 21 11:13:42 DietPi wpa_supplicant[921]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
jun 21 11:13:42 DietPi wpa_supplicant[921]: wlan0: CTRL-EVENT-TERMINATING
jun 21 11:13:42 DietPi ifplugd(eth0)[439]: Program executed successfully.

Hi,

looks like you constantly getting this issue

wlan0: CTRL-EVENT-ASSOC-REJECT bssid=00:00:00:00:00:00 status_code=16

Something similar was described in this post
https://www.raspberrypi.org/forums/viewtopic.php?t=198104

can you try using this one single AP (WiFi Network) as well as changing the WiFi Channel on your AP?

its so weird, it didnt connect to any channel from 1 to 5, then 6 connected, and so with channel 6 i reconfigured static ip and still working so its like that post said, something only channel related, i just changed again to channel 1 and still error, so i dont know… im using country=ES in the wpa_supplicant.conf :thinking:

edit: just reinstalled the eeprom firmware just in case, nothing

edit: okay so it all has to do with setting the correct reg domain, i dont know what is going on but i have seen that after a while it randomly appeared at the journalctl -u ifplugd.service two lines:
ctrl-event-regdom-change init=core type=world
CTRL-EVENT-REGDOM-CHANGE init=USER type=COUNTRY alpha2=ES
and so i saw that and tried luck and yeah, it connected in the channel 1, and then i tested a reboot and again bad regdomain

so it seems something is overriding my wpa supplicant’s set country…

in /etc/defaults/crda i have REGDOMAIN=ES

cat /sys/module/cfg80211/parameters/ieee80211_regdom
00

crda:
COUNTRY enviroment variable not set

export COUNTRY=ES; crda
Failed to set regulatory domain: -7

iw reg get:
global
country ES: DFS-ETSI
[…]

can you have a look to dietpi-config and check on network settings which country code is set?

it was in ES, but i have started using dietpi-config again and:
i deleted the old ssids that were set in there, and set the 2.4ghz one that i was using changing the channels from 1 to 6, and it worked, it connected in channel 1. But i tried using the same, only 1 ssid, but the 5ghz one, and it doesnt connect, what could be happening? its the last issue to be fixed

using dietpi-config, it doesnt write country=es in the wpa_supplicant.config, but i tested writing it and it still doesnt connect

edit: what does the auto reconnect option do exactly?

auto reconnect option will try to connect you back to WiFi once the WiFi connection get lost (disconnect from WiFi).

okay but that is the default behaviour of wpa_supplicant right? enabling that option would be the same as the default behaviour?
i have it disabled right now and it tries to connect (failing) continuously

Nope, wpasupplicant has not internal auto-reconnection feature (that I am aware of). The one in dietpi-config starts dietpi-wifi-monitor.service which does that by checking connection state every 10 seconds. However just to be clear it is very simple and does not know about ifplugd or other intentions, hence is not compatible with the ifplugd-based auto-switch on Ethernet connection. It will try to reconnect WiFi until you either stop the service (or dietpi-config option) or physically unplug the adapter :wink:.

But I have it switched off and in the journalctl of ifplugd, as I posted here before, I can see the reconnection attempts, and also after each failed attempt there is an increase in the time after the next attempt
You can see it for example in this line:

jun 21 10:27:21 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-TEMP-DISABLED id=0 ssid=“CasitaAP” auth_failures=1 duration=10 reason=CONN_FAILED

Which has the numer of failed attempts, and the duration until the next attempt, that is the output of wpa supplicant
Also this line shows when that time ends and is ready for the next attempt:

jun 21 10:27:35 DietPi wpa_supplicant[887]: wlan0: CTRL-EVENT-SSID-REENABLED id=0 ssid=“CasitaAP”

But anyway, what I want to fix is the WiFi connection :frowning:

Ah okay, yes that is not dietpi-wifi-monitor.service then but wpasupplicant failing to connect to WiFi on Ethernet unplug invoked by ifplugd. Probably wpasupplicant has an internal retry mechanism when initial connection fails. But I doubt that it reliably reconnects when WiFi connection was established successfully and then lost with DHCP and/or static IP, due to the steps required after the WiFi connection to gain network access. But would be actually nice :thinking:.

About country code, we switched from wpasupplicant-based country code assignment to crda only. When adding it to /etc/defaults/crda, it is applied to the WiFi adapter via udev rule once it is plugged/detected, which seems cleaner than setting it again on every AP connection. This means you should be able to remove country=es from wpasupplicant config.

Calling crda requires the COUNTRY variable to be set yes. However it fails with error code -7.
What does the following show? iw reg set ES
Interesting is that iw reg get does show ES indeed.

I read that some USB WiFi adapters have the country code hardcoded:
Could you check: dmesg | grep cfg80211

Okay, there is a problem, i booted the raspberry to get that info and without modifying anything it does connect to both 5ghz and 2.4ghz wifi… i don’t know if this is gonna be any relevant but i will put here the info. Anyway, i have used those commands before and it is the same output that it is showing now:

root@DietPi:~# iw reg get
global
country ES: DFS-ETSI
        (2400 - 2483 @ 40), (N/A, 20), (N/A)
        (5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
        (5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
        (5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
        (5725 - 5875 @ 80), (N/A, 13), (N/A)
        (57000 - 66000 @ 2160), (N/A, 40), (N/A)

root@DietPi:~# iw reg set ES
root@DietPi:~# iw reg get
global
country ES: DFS-ETSI
        (2400 - 2483 @ 40), (N/A, 20), (N/A)
        (5150 - 5250 @ 80), (N/A, 23), (N/A), NO-OUTDOOR, AUTO-BW
        (5250 - 5350 @ 80), (N/A, 20), (0 ms), NO-OUTDOOR, DFS, AUTO-BW
        (5470 - 5725 @ 160), (N/A, 26), (0 ms), DFS
        (5725 - 5875 @ 80), (N/A, 13), (N/A)
        (57000 - 66000 @ 2160), (N/A, 40), (N/A)

root@DietPi:~# dmesg | grep cfg80211
[    2.146142] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[    2.159436] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[    3.352689] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save disabled
[   23.454176] brcmfmac: brcmf_cfg80211_set_power_mgmt: power save disabled

Also, in /etc/defaults/rdca i have REGDOMAIN=ES set

I don’t know, as it does work for now i suppose i cannot reproduce the issue, so i will keep using it as normally for now and if it stops working again i will come here to try to find the issue, i supose. But i dont think it is hardcoded, as it would mean that i would never be able to connect to it but i have been able to connect some times to those wifis. There must be some conflict of several services imposing regdomains, or some cache giving problems

which channels are used on your WiFi AP now?

the 2.4ghz was at first in channel 1 and now i have changed it to channel 13, both works, and both using 40mhz of bandwidth if that matters, and the 5ghz is in channel 48, 80mhz bandwidth

i just changed the channel of the wifi it was connected and i see that it doesnt reconnect by itself, i had to plug and unplug the ethernet cable so that it triggers the connect command, im gonna search for some script for the ifplugd that reconnects when wifi is dropped while ethernet is unplugged

you can use dietpi-wifi-monitor.service to watch the WiFi connection. It should try to reconnect WiFi if connection get lost.