def get_local_ip_for(target):
 try:
  target_ipaddr = socket.gethostbyname(target)
 except socket.gaierror:
  return None
 udpprot = DatagramProtocol()
 port = reactor.listenUDP(0, udpprot)
 try:
  udpprot.transport.connect(target_ipaddr, 7)
  localip = udpprot.transport.getHost().host
 except socket.error:
  localip = None
 port.stopListening()
 return localip

def get_local_ip_for ( target ) : try : target_ipaddr = socket . gethostbyname ( target ) except socket . gaierror : return None udpprot = DatagramProtocol ( ) port = reactor . listenUDP ( 0 , udpprot ) try : udpprot . transport . connect ( target_ipaddr , 7 ) localip = udpprot . transport . getHost ( ) . host except socket . error : localip = None port . stopListening ( ) return localip
find out what our ip address is for use by a given target .