ftao / python-ifcfg

Python cross-platform network interface discovery (ifconfig/ipconfig/ip)
BSD 3-Clause "New" or "Revised" License
55 stars 37 forks source link

Support Gateways #59

Closed ghost closed 3 years ago

ghost commented 3 years ago

Is it possible to support getting information about the gateways for the linux parser?

benjaoming commented 3 years ago

Thanks for filling in this issue.

IMHO, this ~is~ isn't within the scope of the project. [edited: sentence was meant the exact opposite way]

If you want gateway information, you can run route (legacy) or ip route list but this project is originally only intended for ifconfig and later ip addr show, none of which have gateway information AFAIK.

Ideally, we would have everything work cross-platform, so implementing this only for Linux-based platforms would also be a bit of a stretch.

I would say that if you can come up with a PR that implements the behavior for both Linux ip route list <interface> and Windows ipconfig, then it could still work.. but adding several commands would break with the current design assumptions.

ghost commented 3 years ago

I would only be able to implement this feature for Linux via ip route show dev <interface>, since I'm not familiar with networking in Windows. Are you nevertheless interested in a PR?

benjaoming commented 3 years ago

I think if you can contribute that PR, you could potentially make the structure necessary for someone to add a Windows solution. But you could potentially write the Windows solution, too? It seems trivial if you write it for the example output here:

https://github.com/ftao/python-ifcfg/blob/master/tests/ipconfig_out.py