def defaultinterface(): '''The interface the default gateway is on, if there is one.''' try: return netifaces.gateways()['default'][netifaces.AF_INET][1] except: return None