This is a typical failover scenario and this is handled
by bonding. You can find information at Debian -
bonding. Here for example I have made
a tested configuration with Raspbian on a Raspberry Pi 3 that will bond wlan0
and eth0
and switch transparent between this two interfaces.
Who are interested for doing this with systemd-networkd
can look at Howto migrate from networking to systemd-networkd with dynamic failover.
For the old style networking you have to configure
/etc/network/interfaces
but I couldn't get it together with dhcpcd.
It's too complicated with network/interfaces and dhcpcd and wpa-supplicant and resolvconf and bonding. So for this example I
disabled dhcpcd and use an old style networking configuration. First install needed packages:
pi@raspberrypi:~ $ sudo apt install ifenslave
pi@raspberrypi:~ $ sudo apt install resolvconf
Then setup /etc/network/interfaces like this:
pi@raspberrypi:~ $ cat /etc/network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
# bond eth0 together with wlan0
# for status look at: cat /proc/net/bonding/bond0
auto bond0
iface bond0 inet static
bond-slaves wlan0 eth0
bond-primary wlan0
bond-mode active-backup
bond-miimon 100
address 192.168.10.60
netmask 255.255.255.0
gateway 192.168.10.1
dns-nameserver 192.168.10.10
dns-search home.hoeft-online.de
allow-bond0 wlan0
iface wlan0 inet manual
bond-give-a-chance 120
wpa-bridge bond0
wpa-ssid "wlan@hoeft-online.de"
wpa-key-mgmt WPA-PSK
wpa-psk "dontBelieveItsMyPw"
pi@raspberrypi:~ $
You should give this file chmod 600 /etc/network/interfaces
.
Disable dhcpcd:
spi@raspberrypi:~ $ sudo systemctl stop dhcpcd
spi@raspberrypi:~ $ sudo systemctl disable dhcpcd
Reboot
Look with cat /proc/net/bonding/bond0
if it's working.
bonding
for this two interfaces. I suggest to usesystemd-networkd
. I'm not willing to investigate in old technologynetworking with ifupdown
. Please follow this Howto migrate from networking to systemd-networkd with dynamic failover step by step. If something is unclear, ask at that Question/Answer. – Ingo Feb 15 '18 at 17:16