import dns.resolver import ifcfg import json import socket import struct import sys import time interfaces = ifcfg.interfaces() def exit_device(): print("Possible devices:", ", ".join(interfaces.keys())) sys.exit(1) def gateway(device): with open("/proc/net/route") as fh: # skip header next(fh) for line in fh: routes = line.strip().split() if routes[0] == device: destination = socket.inet_ntoa(struct.pack("