How to make sure, on the same interface, to properly route traffic to the same subnet, based on availability of a gateway?

e.g.  interface eth0/1  gateway  pref 10 metric 1  interface eth0/1  gateway  pref 20 metric 1

this usually means while accessing, for example, it goes via, but the problem is, when is down (cannot ping), it will not automatically goes to the second route (it does if using 2 interfaces and the first interface physically goes down).


This will require some active component.

Typically this is what a routing protocol is for. The gateways use the protocol to announce what networks they will route and your router will put the appropriate routes into its routing table. If one of the gateways disappears, its routes will be removed from your routing table and traffic will flow through the remaining routes.

Of course, if your setup is simple enough, it is also possible to achieve the same thing using a script which pings the gateways and inserts/removes routes depending on the availability of the gateways. What exactly is possible depends on your platform.

  • no way to do it by playing with pref and metric? – Alex Feb 28 '13 at 9:50
  • No, you need to actively check if one of your gateways is no longer available. Pref and metric won't help you there. These are mainly hints that may be used by the routing protocols. – Oliver Feb 28 '13 at 10:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.