Find interface associated with default route?

Steve Holden steve at holdenweb.com
Mon Nov 13 10:54:50 CET 2006


Neal Becker wrote:
[...]
> 
> A quick strace reveals that 'route' just reads /proc/net/route, so:
> 
C:\Steve>type /proc/net/route
The syntax of the command is incorrect.

C:\Steve>type \proc\net\route
The system cannot find the path specified.

Python, but not platform dependent :-)

It would be nice to provide a shim module to provide stuff like this in 
a way that any platofrm could use. But when you look at the trouble it 
took to find a reasonable way for Ka Ping's guid function to locate an 
Ethernet address you'll agree that it would be a lot of work.

So probably reading /proc/net/route is a good bet for a limited range of 
platforms. OpenBSD is another place you won't find /proc/net/route.

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd          http://www.holdenweb.com
Skype: holdenweb       http://holdenweb.blogspot.com
Recent Ramblings     http://del.icio.us/steve.holden




More information about the Python-list mailing list