How to purge all network related config? Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

MichaIng wrote: Mon Jun 22, 2020 1:01 pm 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 ;).
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 :(
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to purge all network related config?

Post by MichaIng »

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 :?.

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
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

MichaIng wrote: Mon Jun 22, 2020 2:12 pm 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 :?.

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:

Code: Select all

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
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

which channels are used on your WiFi AP now?
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

Joulinar wrote: Mon Jun 22, 2020 4:12 pm 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
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

you can use dietpi-wifi-monitor.service to watch the WiFi connection. It should try to reconnect WiFi if connection get lost.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

okay so it seems like this is fixed:

i have clean flashed the distro again, as i have been editing several config files of the system trying to fix the network issues and i dont even remember anymore all the files i modified, and also to discard any other problem i decided to cleanflash and apply my new knowledges in the new install :lol:

okay so, clean flash, and as i know two interfaces active will be problematic i went throught the setup only with ethernet

then i installed ifplugd to have it already installed in case internet connection doesnt work at some point throught the process, then i just set the internet using the dietpi-config for both ethernet, with static ip, and then a reboot, and then the wifi with static and both ssid, the country, the inboard wifi, and then a reboot, and then proceed to edit the config files of wpa_supplicant (it doesnt have to be modified, dietpi-config does it right, but i check it just in case), /etc/network/interface (commenting the hotplugging of eth0, and checking that both interfaces has correct static ips), checking that /etc/default/crda has REGDOMAIN=ES, and finally edit /etc/ifplugd/ifplugd.action to contain:

Code: Select all

#!/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
and /etc/default/ifplugd

Code: Select all

INTERFACES="eth0"
HOTPLUG_INTERFACES="auto"
ARGS="-q -f -u0 -d5 -w -I"
SUSPEND_ACTION="stop"
finally,
systemctl enable ifplugd.service
systemctl start ifplugd.service
reboot
and voilá, it is working

Now, i have set both interfaces to have the same static ip, and it "works", as in it works sometimes but i think hotswitching from one to the other makes the second one to not actually work, but no errors of wifi connection shown, it is connected, it is just that the router doesnt like two macs attatched to the same ip, at least if it happens too recently both of them... but no problem for me, i dont plan to be switching from one to another in a short time

so, conclusions: i suggest the devs to add ifplugd as an option inside the network menu, it is simple to install and configure, and seems to avoid a lot of headaches in common network configurations... Now i would have to try the dietpi-wifi-monitor to see if it makes some trouble if i activate it with my current settings (with ifplugd, i mean), but yeah, im happy with this

thanks to both devs for your time!
User avatar
Joulinar
Posts: 2052
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

ok good that we found a working solution for you.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
User avatar
MichaIng
Site Admin
Posts: 2293
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to purge all network related config?

Post by MichaIng »

@Akrai
Amazing, that is indeed a great setup, would you like to copy he instructions to tutorials? viewforum.php?f=15
I'm still thinking if we should implement it with ifplugd as well or go with an own implementation so that ifplugd is not occupied and can still be used for other purpose. But its great to have a working solution.
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

MichaIng wrote: Mon Jun 29, 2020 12:34 pm @Akrai
Amazing, that is indeed a great setup, would you like to copy he instructions to tutorials? viewforum.php?f=15
I'm still thinking if we should implement it with ifplugd as well or go with an own implementation so that ifplugd is not occupied and can still be used for other purpose. But its great to have a working solution.
Done
viewtopic.php?f=15&t=7835

I don't want to try and enable the wifi monitor for reconnecting yet, is it safe in this setup? does the monitor keeps running when ethernet is connected, for example?
Post Reply