I have two network interfaces eth0 and eth1 and I just wanna know how get the "eth1" as default route automatically if the "eth0" goes down?
3 Answers
What you want is called interface bonding
- There are lots of howtos on setting this up, this one is good for bare-bones "type this" information, and this one has a little more information.
The ifcfg-bonding manpage (& references) may also be of help, and is probably more up-to-date than any tutorials you'd find by googling..
-
I hadn't considered bonding as the answer here, maybe simply because of the phrasing of OPs question. This may be the right answer but its hard to tell.– dmouratiJun 3, 2011 at 21:45
-
@dmourati same way I didn't think of it being two NICs on different networks -- it's a bit vague :)– voretaq7Jun 3, 2011 at 21:51
You can use the metric argument to route
. Metrics are counted as additional hops to the destination network or host.
route add default gw eth1defaultroute metric 10 dev eth1
This is the "old school" way of doing things.
You may also be interested to learn about iproute2:
ip route add default via eth1defaultroute metric 10 dev eth1
For more details, see:
-
... If you're talking about two NICs on different subnets this is the way to go.– voretaq7Jun 3, 2011 at 21:50