LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

Reply
 
Search this Thread
Old 12-08-2010, 06:05 PM   #1
nabi18
LQ Newbie
 
Registered: Dec 2010
Posts: 11

Rep: Reputation: 0
Two ethernet cards in a single network, how to route packets from both interfaces?


Hi,

I have a server and two clients that i use to measure for example the round trip time. The server is an individual computer with an IP= 192.168.0.4 and the clients are in the same computer, so i have one computer with two ethernet cards :
eth0 192.168.0.2
eth1 192.168.0.3

I am sending packets from .2 to .3 via the server and viceversa. So, each client has a receiver and a sender. Programming the sockets, i bind one of the clients to .2 and the other .3 in both the sender and receiver hoping that this will make the computer two use the rigt ethernet card.

Unfortunately by looking at wireshark i realise that i am sending packets from the same ethernet card , that is, wireshark shows different IPs (as expected from binding the sockets) but the MAC address is alwasy the same.

I have a look to the routing table by netstat -nr and indeed i understand what is happening, the routing table says

Destination | Gateway | Mask | ... Interface
192.168.0.0 0.0.0.0 255.255.255.0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 eth2

So all packets routed to the server are going through eth0. How can i make use of eth2??? any ideas how to program to bind to a MAC address rather than IP address??

Thanks
 
Old 12-08-2010, 06:47 PM   #2
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
I'm not aware of any way that your configuration would work with both cards on the same network, IP routing would always use eth0 for outbound packets. I'd add a network card to the server and configure 2 separate networks

Code:
[client_eth0]------(net1)-----[server_eth0]
[client_eth1]------(net2)-----[server_eth1]
hth
 
Old 12-08-2010, 09:27 PM   #3
jefro
Guru
 
Registered: Mar 2008
Posts: 11,323

Rep: Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386Reputation: 1386
Change the metric.
 
Old 12-09-2010, 03:49 PM   #4
kbp
Senior Member
 
Registered: Aug 2009
Posts: 3,758

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
Wouldn't that just swap the outbound adapter ? .. OP wants the clients to send traffic out the interfaces they're bound to as far as I can tell
 
Old 12-09-2010, 05:05 PM   #5
nabi18
LQ Newbie
 
Registered: Dec 2010
Posts: 11

Original Poster
Rep: Reputation: 0
Hi,

Thanks for the suggestions. I think i ll take kbp's suggestion. I ll be installing a new ethernet card on the server and insert some routing entrance to make sure that each card is actually being used.

Thanks
 
Old 12-11-2010, 02:49 PM   #6
nabi18
LQ Newbie
 
Registered: Dec 2010
Posts: 11

Original Poster
Rep: Reputation: 0
My final solution,

I generated a virtual network on my ethernet card (on the server side), then the clients send the packets to the virtual ip address with an static routing entrace with iproute.

for the record, at the server, add the next lines in /etc/network/interfaces
auto eth0:1
iface eth0:1 inet static
address 192.168.10
netmask 255.255.255.0
gateway 192.168.0.1
hwaddress eher xx:xx:xx:xx:xx

where you have to substitude the x for your mac address

at the client add at the routing table by tiping in a command

route add -host 192.168.0.2 dev eth0
route add -host 192.168.0.10 dev eth1

Thanks for your comments
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] IP Route UDP and TCP packets different interfaces howudodat Linux - Networking 2 09-22-2010 05:14 PM
How to route IP packets between ethernet bridges? GeorgeS069 Linux - Networking 10 06-06-2009 02:48 PM
How to route traffic on a network - cannot get machine to transfer across interfaces captainpotato Linux - Networking 15 10-04-2006 08:04 AM
2 network cards, single network, load balancing? tormentum Linux - Networking 1 02-13-2005 02:37 PM
ethernet cards, network and drivers Xerop Linux - Hardware 1 03-05-2004 10:31 PM


All times are GMT -5. The time now is 01:24 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration