Scheduled Maintenance: We are aware of an issue with Google, AOL, and Yahoo services as email providers which are blocking new registrations. We are trying to fix the issue and we have several internal and external support tickets in process to resolve the issue. Please see: viewtopic.php?t=158230

 

 

 

auto switch interface

Linux Kernel, Network, and Services configuration.
Post Reply
Message
Author
Bouwser
Posts: 13
Joined: 2014-09-04 14:12

auto switch interface

#1 Post by Bouwser »

Hello,
I have an Single Board computer (SBC) running Debian Stretch with 2 ethernet ports and a cellular connection. The first Ethernet port is configured to connect to a network as DHCP. The second Ethernet is configured to act as a DHCP server to allow a technician to come up and plug into it in the field if necessary. This second Ethernet port is not made accessible to the customer and is rarely used. I will be ignoring this Ethernet port in my scenarios below. This SBC is a product that could end up in a variety of situations. I would like it to do the following...

1. If just the Ethernet is connected, and the USB cell modem is not plugged in, then use the Ethernet port to route messages to the internet.
2. If just the USB cell modem is plugged in and the Ethernet is not, use the cell modem to route messages to the internet.
3. If both the Ethernet and cell modem are plugged in, use Ethernet to route messages to the internet.
4. If both the Ethernet and cell modem are plugged in, but then the ethernet is unplugged switch to using the cellular modem to route messages to the internet.
5. If just the cell modem is plugged in and then the Ethernet is plugged in, switch to using the Ethernet to route messages to the internet.

I currently am able to do 1 - 3, but not 4 & 5. Is there a way to detect if an interfaces appearing and going away and then re-route messages to the preferred interface?

Here is my current interfaces file...
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

#source /etc/network/interfaces.d/*

#The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto enp2s0
allow-hotplug enp2s0
iface enp2s0 inet dhcp
gateway 192.168.150.1 #Gateway for Ethernet must be defined if you want to default to this interface vs cellular.

#Cellular Interface
auto enp0s20u1
allow-hotplug enp0s20u1
iface enp0s20u1 inet dhcp

# The secondary network interface
auto enp3s0
allow-hotplug enp3s0
iface enp3s0 inet static
address 192.168.175.1
netmask 255.255.255.0
broadcast 192.168.175.255
network 192.168.175.0


dns-nameservers 8.8.8.8 8.8.4.4
post-up iptables-restore < /etc/iptables.up.rules
#post-up route del default dev $IFACE #this is required if no gateway is specified for enp2s0

thanks in advance,
Brent

Post Reply