views:

383

answers:

1

On Linux, how can I find the default gateway for a local ip address/interface using python?

I saw the question "How to get internal IP, external IP and default gateway for UPnP", but the accepted solution only shows how to get the local IP address for a network interface on windows.

Thanks.

+1  A: 

It seems http://pypi.python.org/pypi/pynetinfo/0.1.9 can do this, but I haven't tested it.

Florian Diesch
That library is great!It has a netinfo.get_routes method that returns a tuple of dictionaries containing precisely the data I needed.Thanks!
gnp