1

How do I set up a backup static route on a linux router. For example if I have 2 routers R1 and R2, connected through a switch, through two links:

 R1(eth1)->switch->R2(eth1)
 R1 (eth2)->switch->R2(eth2)

Behind router R2 is a LAN(LAN A) How do I set two routes to LAN A from R1, one that uses a main next hop the eth1 from R2, and one that uses a secundary next hop the address from eth2 from R2. Something like when the main next hop is unavailable, the secondary route should be used. Could someone please help me? Thanks

[EDIT] Should I use different metrics when creating the two routes?

[EDIT2] Topology

2 Answers 2

3

If you add 2 default routes with different metrics, this will switch the route only the case when main link is down and the other is up. The link is up (the interface status of the link) even if the router is not reachable. The link goes down only when the physical connection of the interface is down (e.g. no carrier detected, other out of band signaling).

What you really need is to detect when the remote router is down even if the link is up. This can be accomplished by using a dynamic routing protocol.

Another way would be to use a daemon or crontab script that will change the default route based on the reachability of the neighbor routers.

EDIT: The answer to your question is bellow. But this is not what you should configure to have redundancy.

ip route add default via R1 metric 100
ip route add default via R2 metric 200

If you need to make redundancy for the connection between R1 and R2 you should set LCAP as @growse wrote.

2
  • "If you add 2 default routes with different metrics, this will switch the route only the case when main link is down and the other is up"->that is exactly what I am trying to accomplish. Could you please help me out with what metric should I use and how. Thanks a lot
    – biggdman
    Dec 22, 2011 at 23:24
  • I think the commands you wrote are exactly what i need. I edited and put an image of the topology i was trying to describe. I am trying to configure on R1 two routes to lan l: one that goes though eth1 of R2, and one that goes through eth2 of R2. By gets through i mean set the interface ip addr as the next hop
    – biggdman
    Dec 22, 2011 at 23:45
3

If you're just trying to achieve link resilience between your routers and your switch, then you're aiming at the wrong level in the OSI stack.

It sounds like you just need to bond the two NICs together on each router to make an ethernet trunk, and configure it on the switch. Either LACP or Etherchannel, depending on what the switch supports.

2
  • I do not want a trunk connection, I just want when eth1 from R2 is down, the packet to travel using the second route(through eth2 of R2),and when eth1 of R2 is back up, to take that route
    – biggdman
    Dec 22, 2011 at 23:27
  • 3
    What are you actually trying to protect against the failure of? The NIC? The cable? The switch? In other words, why? Some more details about the specific scenario and the requirements / restrictions you're working under would really be useful here.
    – growse
    Dec 22, 2011 at 23:35

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .