I have two network interfaces in Linux machine , eth0 and eth1. IP is assigned to both interface from two different VLANs and default gateway to eth0. Now if interface eth0 is down I am unable to route traffic outside as default gateway is also unavailable.

Is there is any way to address this scenarios?


it's not clear from your description, are both interfaces connected to the same network.
let's assume
you have
eth0 -, gw
eth0 -, gw

  1. create new rule
    #ip ru add table 5 prio 20000 from
  2. create new default rule
    `#ip ro add table 5 default via'

so, you can check the settings by:
#ip ru sh - see rules
0: from all lookup local
20000: from lookup 5

#ip ro sh ta 5 - see routing for you table
default via dev eth1

BTW, there is a good reading concerning linux routing Linux Advanced Routing & Traffic Control

| improve this answer | |
  • hi, It is connected to same network but different VLAN. From above solution if eth0 is goes down , then eth1 default gw will work? – user50879 Nov 8 '13 at 9:55
  • this solution will work independently to VLANs, but it has some obvious limitation - if you receive IPs via DHCP/SLAAC - it will be difficult to add such rule/route – vasily-vm Nov 8 '13 at 12:51

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.