Re: Failover route

Erik Auerswald <[email protected]> Sat, 16 Mar 2019 16:22:48 +0000
Newsgroups org.kernel.vger.lartc
Message-ID <[email protected]>
Hi,

On 3/12/19 15:32, Leroy Tennison wrote:
> I have a device with two routes to the Internet configured as
> 
> default nexthop via <IP address 1> dev <NIC 1> weight 1
> default nexthop via <IP address 2> dev <NIC 2> weight 1
> 
> If I'm understanding what I saw correctly, if (when) one interface fails it still tries it every other time.  What I saw was an outbound ping regularly failing then succeeding (a few successes then a few failures then the success/failure pattern repeated).  I then noticed that one interface wasn't fully plugged in and, after rectifying that, received 100% ping response.
> Adjusting weights in this situation only makes things better/worse depending on which interface fails, is there a way to configure failover so that one interface is always tried and the second used only if the first fails?  Bonding isn't an option because these are two distinct point-to-point links.

As a crude method I have used a cron job to ping the gateways and
add or remove (default) routes based on ping results in the past.
You could use iproute2's 'ip link' to check interface status instead
(or first).

You may be able to subscribe to Netlink messages to get informed
about interface state changes. At least for a prototype it might
suffice to use iproute2's 'ip monitor' to receive Netlink messages,
but I have not yet tried this. Routing daemons are supposed to do
that, so using one with static default routes might give you the
intended results.

Thanks,
Erik