python network interface library code example
Example: python3 netifaces get current interface
>>> import netifaces
>>> def_gw_device = netifaces.gateways()['default'][netifaces.AF_INET][1]
>>> import netifaces
>>> def_gw_device = netifaces.gateways()['default'][netifaces.AF_INET][1]