Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add function to get the default route #716

Closed
nzjrs opened this issue Dec 10, 2015 · 6 comments
Closed

add function to get the default route #716

nzjrs opened this issue Dec 10, 2015 · 6 comments

Comments

@nzjrs
Copy link

nzjrs commented Dec 10, 2015

a wrapper around the command ip route

@giampaolo
Copy link
Owner

Are you interested in the default gateway?

@nzjrs
Copy link
Author

nzjrs commented Dec 12, 2015

I'm actually interested in the device from which default traffic will be
routed

default via 192.168.0.1 dev eth1 proto static

On 12 December 2015 at 12:24, giampaolo [email protected] wrote:

Are you interested in the default gateway?


Reply to this email directly or view it on GitHub
#716 (comment).

@giampaolo
Copy link
Owner

Closing as duplicate of #667. In the meantime you might want to take a look at netifaces lib which provides info about the gateways: https://pypi.python.org/pypi/netifaces

@nzjrs
Copy link
Author

nzjrs commented Dec 14, 2015

Is it really a dupe if I want the device and not the IP?

On 14 December 2015 at 19:01, giampaolo [email protected] wrote:

Closing as duplicate of #667
#667. In the meantime you
might want to take a look at netifaces lib which provides info about the
gateways: https://pypi.python.org/pypi/netifaces


Reply to this email directly or view it on GitHub
#716 (comment).

@giampaolo
Copy link
Owner

Please try to describe what you would expect in terms of API.
netifaces do this:

>>> import netifaces
>>> netifaces.gateways()
{2: [('10.0.1.1', 'en0', True), ('10.2.1.1', 'en1', False)], 30: [('fe80::1', 'en0', True)], 'default': { 2: ('10.0.1.1', 'en0'), 30: ('fe80::1', 'en0') }}

...on my machine:

>>> netifaces.gateways()
{'default': {2: ('10.0.0.1', 'wlan0')}, 2: [('10.0.0.1', 'wlan0', True)]}
>>> 

I'm asking this because it is not entirely clear to me how network gateways work.

@ofirule
Copy link

ofirule commented Nov 26, 2023

It's really missing.
Reading all routes which may include static routes, and not only the interface gw is very usefull

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants