Subject: Re: Finding the correct interface for a packet
To: Klaus Klein <kleink@ira.uka.de>
From: Andrew Brown <twofsonet@graffiti.com>
List: tech-net
Date: 12/03/1998 16:47:35
>> % route get 198.67.15.13
>>
>> [...]
>> in each case, the "interface" line is what you want. i, at one
>> point, snarfed pieces of code from route.c and cobbled some other bits
>> together for just this purpose.
>>
>> the snag: it uses routing sockets, which means it needs to be root.
>
>That's no longer true; the routing socket interface has been changed
>to not require super-user privileges for RTM_GET.
then this is probably the ideal.
as for the comment that connected udp sockets are "bad" since routing
tables can change (which is true), i don't think that's really an
issue unless the information that was being obtained (ie, the name of
the interface) was expected to stay constant for a considerable length
of time. if you just need to know "right now" for "right now" then
either method is fine.
but, of course, i don't know exactly what the original querier (matt?)
had in mind. :)
--
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org * "ah! i see you have the internet
twofsonet@graffiti.com (Andrew Brown) that goes *ping*!"
andrew@crossbar.com * "information is power -- share the wealth."