How to purge all network related config? Topic is solved

Have some feedback, questions, suggestions, or just fancy a chat? Pop it in here.
User avatar
Joulinar
Posts: 2072
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

in theory you could start the wifi monitor service together with ifup wlan0 and bring it down as soon as the script calls ifdown wlan0
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 29, 2020 3:13 pm in theory you could start the wifi monitor service together with ifup wlan0 and bring it down as soon as the script calls ifdown wlan0
nice, so the autoreconnect option of dietpi config is just a systemctl enable & start a systemd service? if so, then it would be as easy as changing the content of
/etc/ifplugd/ifplugd.action


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
--->   systemctl stop name of the .service
--->   systemctl disable name of the .service
       exit 0
elif [ "$2" = "down" ] ; then
       echo "bring up WiFi"
       /sbin/ifdown eth0 --force
       /sbin/ifup wlan0 --force
--->   systemctl start name of the .service
--->   systemctl enable name of the .service
       exit 0
fi
exit 1
User avatar
Joulinar
Posts: 2072
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

you would need to call systemctl with the full path like

Code: Select all

/bin/systemctl
Otherwise the command will not be interpreted correctly, I guess. Unfortunately I already removed my test installation for other suppot requests. Therefore I'm not able to test. But you can give it a try ;)
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 29, 2020 8:02 pm you would need to call systemctl with the full path like

Code: Select all

/bin/systemctl
Otherwise the command will not be interpreted correctly, I guess. Unfortunately I already removed my test installation for other suppot requests. Therefore I'm not able to test. But you can give it a try ;)
okay, no problem, but can you confirm if the dietpi-config option of autoreconnect is just enabling the service? or i would need to do something more to emulate the same thing?
User avatar
MichaIng
Site Admin
Posts: 2294
Joined: Sat Nov 18, 2017 6:21 pm

Re: How to purge all network related config?

Post by MichaIng »

Use
systemctl disable --now name.service
and
systemctl enable --now name.server
to disable/enable + stop/start the services with one command :).
And yes dietpi-wifi-monitor.service just needs to be started, no other step required.
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

I didn't know about the one line systemctl flag, good to know, thanks!
Okay so i have just added it and it works! it reconnects quickly, very good
Now, for a proper testing i should test if there is any reconnection feature without adding those lines but im lazy right now and as it probably doesnt have any reconnect feature, it will disconnect when i disable the wifi from the router, and it wont reconnect again and i would need to take the raspi to connect it from ethernet or reboot it or whatever... meh, lets just assume there wasnt any reconnection feature going on by default and we just added one and it works reliably, so nice! And it is a simple setup, to be honest, which is cool too
Thanks!
Akrai
Posts: 21
Joined: Fri Jun 19, 2020 9:43 am

Re: How to purge all network related config?

Post by Akrai »

If I boot the raspberry with ethernet plugged in, this happens:

systemctl status ifup@wlan0.service -> status: failed, which then implies that if i do a systemctl, it says status: degraded, because an unit has a failed status

journalctl -u ifup@wlan0.service

Code: Select all

jul 01 20:42:56 DietPi systemd[1]: Started ifup for wlan0.
jul 01 20:42:56 DietPi wpa_supplicant[377]: Successfully initialized wpa_supplicant
jul 01 20:42:59 DietPi wpa_supplicant[469]: wlan0: Trying to associate with SSID 'CasitaAP_5G'
jul 01 20:43:02 DietPi wpa_supplicant[469]: wlan0: Associated with cc:32:e5:53:9e:99
jul 01 20:43:02 DietPi wpa_supplicant[469]: wlan0: CTRL-EVENT-CONNECTED - Connection to cc:32:e5:53:9e:99 completed [id=0 id_str=]
jul 01 20:43:02 DietPi wpa_supplicant[469]: wlan0: CTRL-EVENT-SUBNET-STATUS-UPDATE status=0
jul 01 20:43:19 DietPi systemd[1]: ifup@wlan0.service: Main process exited, code=exited, status=1/FAILURE
jul 01 20:43:19 DietPi wpa_supplicant[469]: nl80211: Failed to open /proc/sys/net/ipv4/conf/p2p-dev-wlan0/drop_unicast_in_l2_multicast: No such file or directory
jul 01 20:43:19 DietPi wpa_supplicant[469]: nl80211: Failed to set IPv4 unicast in multicast filter
jul 01 20:43:19 DietPi wpa_supplicant[469]: nl80211: Failed to open /proc/sys/net/ipv4/conf/p2p-dev-wlan0/drop_unicast_in_l2_multicast: No such file or directory
jul 01 20:43:19 DietPi wpa_supplicant[469]: nl80211: Failed to set IPv4 unicast in multicast filter
jul 01 20:43:19 DietPi wpa_supplicant[469]: nl80211: deinit ifname=p2p-dev-wlan0 disabled_11b_rates=0
jul 01 20:43:19 DietPi wpa_supplicant[469]: p2p-dev-wlan0: CTRL-EVENT-TERMINATING
jul 01 20:43:19 DietPi wpa_supplicant[469]: wlan0: CTRL-EVENT-DISCONNECTED bssid=cc:32:e5:53:9e:99 reason=3 locally_generated=1
jul 01 20:43:19 DietPi wpa_supplicant[469]: nl80211: deinit ifname=wlan0 disabled_11b_rates=0
jul 01 20:43:20 DietPi wpa_supplicant[469]: wlan0: CTRL-EVENT-TERMINATING
jul 01 20:43:20 DietPi systemd[1]: ifup@wlan0.service: Failed with result 'exit-code'.
Why did it tried to connect? wpa_supplicant didn't had to be launched at all at any time since ethernet is plugged in from the beggining
User avatar
Joulinar
Posts: 2072
Joined: Sat Nov 16, 2019 12:49 am

Re: How to purge all network related config?

Post by Joulinar »

Starting WiFi during boot is as expected becasue we set allow-hotplug wlan0 within /etc/network/interfaces. This means WiFi is always being started during boot, but will be switched off as soon as ifplugd is detecting the Ethernet connection. On my test it was needed to set allow-hotplug wlan0, otherwise WiFi was not working correctly if the system was booted with WiFi only.
Pls let us know if a solution is working. This could help others if they hit by similar situation. Your DietPi Team
Post Reply