2
Objective
I'm trying to setup some kind of "uninterruptible Internet supply" for a Linux machine. For this reason I'm using two uplinks: a standard wired connection via eth0
, and additionally a 3G connection which is available via eth1
. The wired eth0
connection should be the default connection, while the eth1
connection should only be used in case of a connection problem via eth0
. Both interfaces are configured via DHCP.
Current setup
I'm having two default routes via eth0
and eth1
respectively, and I've assigned a higher metric value to eth1
so that eth0
is preferred by default. Basically, this is working fine: when unplugging the ethernet cable from the eth0
port, the system seamlessly continues to use eth1
for any Internet access, since it detects that the eth0
cable became unplugged, and thus can immediately remove the dead eth0
entries from the routing table (which seems to be the default behavior).
The problem
I'm however facing a problem when the wired connection is not directly interrupted at the eth0
interface itself, but at some later point in the network instead. In this case, the Linux machine of course can't detect that some cable has been unplugged, keeps the eth0
entries within the routing table, and any Internet connection attempt fails with a "target network unreachable" error.
So, is there some way to tell Linux to immediately discard the eth0
route if it can't be used to reach the target network? And if yes, how would I detect when the eth0
connection becomes available again, so that I can switch back from eth1
to eth0
again? Is this possible at all?
Thank you very much for any hints!!
1You need to use a script or program to test the connection periodically and make a nuanced decision of whether you want to consider it available or not. – David Schwartz – 2014-09-22T15:09:39.933