How to purge all network related config?

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