• Route caches and multiple default routes

    From David Brown@110:110/2002 to All on Fri Feb 14 20:19:54 2014
    I am trying to understand a bit about the route caches in a failover networking setup.

    Roughly speaking, I have two network cards eth0 and eth1, on two
    different networks. Each has a default route, but with different metrics.

    So "route -n" gives something like this:

    estination Gateway Genmask Flags Metric Ref Use Iface 192.168.0.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0 192.168.1.0 0.0.0.0 255.255.255.0 U 1 0 0 eth1
    0.0.0.0 192.168.0.1 0.0.0.0 UG 10 0 0 eth0
    0.0.0.0 192.168.2.1 0.0.0.0 UG 20 0 0 eth0


    traceroute 8.8.4.4 shows the routing uses eth0 by default, as the metric
    is lower, and "ip route get 8.8.4.4" confirms it:

    ip route get 8.8.4.4
    8.8.4.4 via 192.168.0.1 dev eth0 src 192.168.0.160
    cache mtu 1500 advmss 1460 hoplimit 64


    If I now unplug eth0, but keep the interface up (alternatively,
    disconnect the router on eth0), then I can no longer access 8.8.4.4.
    "ip route get" and "ip route show cache" confirm that the cached route
    is still via eth0. "ping 8.8.4.4" gives "Destination Host Unreachable".

    If I use "ip route flush cache", and then try "ip route get" again, the highest metric (lowest value) route is tried first, and fails, and then
    the next default route - via eth1 - succeeds. So the route via eth1
    gets put in the cache, and stays there.

    If I bring eth0 online again, the cached route via eth1 is still there -
    I need to flush the cache again to make it try eth0 (with the highest
    priority metric).


    I am trying to figure some way to make this all work automatically. If
    the highest priority default route fails, I would like the cached route
    to be dropped and the next default route tried - without having to
    manually issue a flush. And I would also like cached routes to have a timeout, so that after a while the higher priority default route will be
    tried again.


    Any ideas or hints would be much appreciated.

    David

    --- MBSE BBS v1.0.1 (GNU/Linux-i386)
    * Origin: A noiseless patient Spider (110:110/2002@linuxnet)
  • From Andrew Gideon@110:110/2002 to All on Wed Feb 26 14:24:18 2014
    On Fri, 14 Feb 2014 21:19:54 +0100, David Brown wrote:

    And I would also like cached routes to have a timeout, so that after a
    while the higher priority default route will be tried again.

    If I understand correctly what you're asking: they do. See

    /sbin/sysctl -a | fgrep net.ipv4.route.gc

    - Andrew

    --- MBSE BBS v1.0.1 (GNU/Linux-i386)
    * Origin: UsenetServer - www.usenetserver.com (110:110/2002@linuxnet)