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 gate
for Mac:
import subprocess def get_default_gateway(): route_default_result = str(subprocess.check_output(["route", "get", "default"])) start = 'gateway: ' end = '\\n' if 'gateway' in route_default_result: return (route_default_result.split(start))[1].split(end)[0] print(get_default_gateway())