Note: this setup works reliably to change between one interface and the another, but i haven't tested the autoconnect wifi system of dietpi, and so right now i have been using this setup without autoconnect, and for several days it has been connected without any interruption but theoretically, right now, if for some reason my raspberry got any wifi interruption or whatever, it should stay disconnected to the wlan. This hasn't happened yet, but theoretically this setup doesn't have a WLAN autoreconnection system running.
Okay so steps from a clean flash (modify as you want to apply it to a running system):
Clean flash, and as I know two active interfaces have been problematic to me, I went throught the initial setup only with ethernet
Then I installed ifplugd:
Code: Select all
apt-get install ifplugd
My /etc/network/interfaces file:
Code: Select all
# 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 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
wireless-power off
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
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
Code: Select all
INTERFACES="eth0"
HOTPLUG_INTERFACES="auto"
ARGS="-q -f -u0 -d5 -w -I"
SUSPEND_ACTION="stop"
systemctl enable ifplugd.service
systemctl start ifplugd.service
reboot
and voilá, it is working