LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   2 network cards (https://www.linuxquestions.org/questions/linux-newbie-8/2-network-cards-916517/)

ThomasRonshof 12-01-2011 04:33 AM

2 network cards
 
Hi,

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 ?

Regards

kvmfix 12-01-2011 05:21 AM

Hi...

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

ThomasRonshof 12-01-2011 05: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 05:31 AM

Are both nic are in same network?

Can you reach eth0 and eth1 from other devices?

ThomasRonshof 12-01-2011 05:39 AM

Jep, eth0 is 192.168.10.40, eth1 is 192.168.10.45,

GW: 192.168.10.1

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 06:26 AM

Hi,

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

Code:

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 07:00 AM

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

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

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

aazkan 12-01-2011 07: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 02:10 AM

Ok,,, but how ?

enno_onne 12-02-2011 02: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
Code:

netstat -rn
it will show you something like this
Code:

Routing Table: IPv4
  Destination          Gateway          Flags  Ref    Use    Interface
-------------------- -------------------- ----- ----- ---------- ---------
default              192.168.137.1        UG        9      3021 e1000g0 
127.0.0.1            127.0.0.1            UH        2        244 lo0     
192.168.137.0        192.168.137.41      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
Code:

route add 192.168.10.0 192.168.10.45
--------------------- !!!!!! ------------------------
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
Code:

route remove 192.168.10.0 192.168.10.45
--------------------- !!!!!! ------------------------

Good luck :)

ThomasRonshof 12-02-2011 04:30 AM

Well, tried:

route del default
route add default gw eth1

But can't still ssh to 192.168.10.45 from the outside ?

ThomasRonshof 12-02-2011 05:52 AM

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


All times are GMT -5. The time now is 03:05 AM.