[CentOS] Fwd: How to add a route to a network via 2 gateways.

Fri Dec 29 22:07:53 UTC 2006
Aleksandar Milivojevic <alex at milivojevic.org>

Quoting Indunil Jayasooriya <indunil75 at gmail.com>:

> Hi ,
>
> I have a network to reach which is 192.168.2.0/24. It is a branch of the
> company. I have currently added a route to that network via one gateway (
> 192.168.0.254) in following way.
>
> ip route add 192.168.2.0/24 via 192.168.0.254
>
> Now, We got another gateway which is 192.168.0.250. Now I want to add a
> route to the same network  which is 192.168.2.0/24 via this gateway
> (192.168.0.250)
> as well.
>
> Then I will have 2 paths to the same network. One path should be primary and
> the other path  should be backup. everything should go via primary path.
>
> if the primary  path goes down, the backup path should be active.
>
> That is the purpose of doing this.
>
> Pls let me know whether it is possible or not?
>
> if possible, How can I achieve this goal.

One possible solution is to enable one of the routing protocols on  
your routers, instead of using static routing.  For example BGP or  
OSPF.  The routers will than discover which paths to every of the  
networks you have exist and will dynamically change routing rules  
(instead of using static set of rules) as the network connections go  
up and down.  In the way you requested in your question.  It might be  
an overkill for simple network.  But if your network becomes more  
complex in the future, you'll have infrastructure to handle it.   
Another advantage of using standard routing protocol is that they tend  
to be platform independent.  You want to replace that Cisco router  
with Linux router or Linux router with Cisco router.  Guess what, you  
can use BGP or OSPF on both Linux and Cisco based router and your  
configuration is not specific to single type of router anymore.