Subject: Re: Finding the correct interface for a packet
To: Klaus Klein <>
From: Andrew Brown <>
List: tech-net
Date: 12/03/1998 16:47:35
>> % route get
>> [...]
>>   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" >-----|             * "ah!  i see you have the internet (Andrew Brown)                that goes *ping*!"       * "information is power -- share the wealth."