-   Linux - Newbie (
-   -   2 network cards (

ThomasRonshof 12-01-2011 05:33 AM

2 network cards

I have defined eth0 and eth1 with 2 different IP's.

If eth0 stops working, I would like to be able to use eth1 instead.

What's to do when eth0 breaks down ? I think something about moving default gateway from eth0 til eth1 ?


kvmfix 12-01-2011 06:21 AM


While eth0 is active, do you still need eth1 to be active?

ThomasRonshof 12-01-2011 06:24 AM

Yes, because I use them for virtualization. eth0 is bridged as br0 and eth1 as br1. I have several guests using br0 and br1 at the same time.

kvmfix 12-01-2011 06:31 AM

Are both nic are in same network?

Can you reach eth0 and eth1 from other devices?

ThomasRonshof 12-01-2011 06:39 AM

Jep, eth0 is, eth1 is,


I can ssh in to both IP's from another host.
If I unplug eth1, I can still ssh to eth0.
If I unplug eth0 alone, I can't ssh to eth1 ! I think it's because of the GW and sshd is listening on eth0 ??

aazkan 12-01-2011 07:26 AM


Unless configured to listen on a defined ip , sshd will listen to any/all.


netstat -antpd|grep :22
shows where sshd runs on.

It is possible to have 2 default gateway (sort off). You will need the iproute2 utility to add modify the routing table. Search through the forum, you'll probably find some leads here.

ThomasRonshof 12-01-2011 08:00 AM

Well, I don't need 2 gw's, only 1.

When eth0 dies, I want to change from eth0 to eth1.

Isn't that possible, maybe with the route command ?

aazkan 12-01-2011 08:52 AM

Sorry i misunderstood your question, thought you wanted a dual gateway
Of course, you can change your def gw to eth1.

ThomasRonshof 12-02-2011 03:10 AM

Ok,,, but how ?

enno_onne 12-02-2011 03:35 AM

I'm also still learning unix here, but I hope this may work and help you out. If not, I am sorry and please let me know.

first, you need to see what is the original routing table by giving this command

netstat -rn
it will show you something like this

Routing Table: IPv4
  Destination          Gateway          Flags  Ref    Use    Interface
-------------------- -------------------- ----- ----- ---------- ---------
default            UG        9      3021 e1000g0              UH        2        244 lo0      U        3        495 e1000g0 

Routing Table: IPv6
  Destination/Mask            Gateway                  Flags Ref  Use    If 
--------------------------- --------------------------- ----- --- ------- -----
::1                        ::1                        UH      2      12 lo0 
fe80::/10                  fe80::203:1dff:fe0a:981c    U      3      0 e1000g0
default                    fe80::b8cf:cb3a:d1ee:7554  UG      2      0 e1000g0

remember this IP routing tables.

Then you need to run this code

route add
--------------------- !!!!!! ------------------------
If it doesn't work then you need to do the reversal and when you re run the netstat -rn, it should be the same

route remove
--------------------- !!!!!! ------------------------

Good luck :)

ThomasRonshof 12-02-2011 05:30 AM

Well, tried:

route del default
route add default gw eth1

But can't still ssh to from the outside ?

ThomasRonshof 12-02-2011 06:52 AM

Works now. Must do a ifconfig eth0 down also :-)

All times are GMT -5. The time now is 06:00 AM.