Subject: Re: determine outgoing interface (eth0,eth1) for a packet according to the dest IP

From: Andi Kleen <[email-masked]>
Date: Tue, 25 Apr 2006 09:43:49 +0200

On Tuesday 25 April 2006 09:31, John Que wrote:
> 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)?

You can send a rtnetlink RTM_GETROUTE message to ask the kernel.
Result is the interface index in RTA_OIF, which can be converted
into a name.

-Andi