Route caches and multiple default routes

Discussion in 'Linux Networking' started by David Brown, Feb 14, 2014.

  1. David Brown

    David Brown Guest

    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
     
    David Brown, Feb 14, 2014
    #1
    1. Advertisements

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

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

    - Andrew
     
    Andrew Gideon, Feb 26, 2014
    #2
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.