netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* determine outgoing interface (eth0,eth1) for a packet according to the dest IP
@ 2006-04-25  7:31 John Que
  2006-04-25  7:43 ` Andi Kleen
  0 siblings, 1 reply; 9+ messages in thread
From: John Que @ 2006-04-25  7:31 UTC (permalink / raw)
  To: netdev

Hello,
What is the right way to determine on which interface card
(eth0 or eth1) will a packet be sent (according to the dest IP)?

I have a machine with two NICS (eth0 and eth1).
I have 2 different gateways.
I need to know on which interface (eth0 or eth1) will the
packet be send according to the dest IP.
I want to do in in a User Space function.

I think of one way to do this is:
Parse the routing table (/proc/net/route) as is done in
net-tools. (to be more specific rprint_fib() in lib/inet_gr.c
of net-tools.
Than according to the IP address and the netmask check if the
dest IP is for one gatway or the second.
If not - than it is the default gateway.

Is there another way ? Is it the correct way ?
Regards,
John

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-04-30 12:55 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-25  7:31 determine outgoing interface (eth0,eth1) for a packet according to the dest IP John Que
2006-04-25  7:43 ` Andi Kleen
2006-04-25  7:58   ` David S. Miller
2006-04-25 14:44   ` John Que
2006-04-25 14:48     ` Andi Kleen
2006-04-26 10:24       ` John Que
2006-04-26 13:58         ` Herbert Xu
2006-04-30  9:17           ` Lennert Buytenhek
2006-04-30 12:55             ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).