Skip to content
This repository has been archived by the owner on Jun 11, 2021. It is now read-only.

netifaces.gateways()['default'] picks the interface with the highest metric #53

Open
maxadamo opened this issue Mar 27, 2020 · 1 comment

Comments

@maxadamo
Copy link

IP route is showing that tun0 (my VPN) has the lowest metric:

$  ip route list | grep default
default via 10.100.24.1 dev tun0 proto static metric 50 
default via 192.168.1.1 dev wlp3s0 proto dhcp metric 600 

but netifaces is saying that my WiFi is the default interface:

netifaces.gateways()['default']
{2: ('192.168.1.1', 'wlp3s0')}
@maxadamo maxadamo changed the title netifaces.gateways()['default'] picking the interface with higher metric netifaces.gateways()['default'] picks the interface with higher metric Mar 27, 2020
@maxadamo maxadamo changed the title netifaces.gateways()['default'] picks the interface with higher metric netifaces.gateways()['default'] picks the interface with the highest metric Mar 27, 2020
@yuri-sevatz
Copy link
Contributor

So there's a few things going on here...

  1. Some routes are created with no destination, that is non-null, but still all 0's (e.g. openvpn in some cases!)

--> I have a PR that addresses this here: #71

  1. Some routes are created with no metric, that is inferred to be 0 (e.g. no metric data from PF_NETLINK)

--> I've just added support for this in the same branch from the above PR.

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

No branches or pull requests

2 participants