def get_net_iface():
 internet_ip = get_local_ip()
 ifname = 'eth0'
 if (os.name == 'nt'):
  pass
 else:
  import fcntl
  import struct
  interfaces = ['eth0', 'eth1', 'eth2', 'wlan0', 'wlan1', 'wifi0', 'ath0', 'ath1', 'ppp0']
  for ifname in interfaces:
   try:
    s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    interface_ip = socket.inet_ntoa(fcntl.ioctl(s.fileno(), 35093, struct.pack('256s', ifname[:15]))[20:24])
   except IOError:
    pass
   else:
    if (internet_ip == interface_ip):
     break
 return ifname

def get_net_iface ( ) : internet_ip = get_local_ip ( ) ifname = 'eth0' if ( os . name == 'nt' ) : pass else : import fcntl import struct interfaces = [ 'eth0' , 'eth1' , 'eth2' , 'wlan0' , 'wlan1' , 'wifi0' , 'ath0' , 'ath1' , 'ppp0' ] for ifname in interfaces : try : s = socket . socket ( socket . AF_INET , socket . SOCK_DGRAM ) interface_ip = socket . inet_ntoa ( fcntl . ioctl ( s . fileno ( ) , 35093 , struct . pack ( '256s' , ifname [ : 15 ] ) ) [ 20 : 24 ] ) except IOError : pass else : if ( internet_ip == interface_ip ) : break return ifname
this function is very os dependant .