def is_public_ip(ipstr):
 addr = ipstr.split(':')[0]
 addr = int(addr, 16)
 byte1 = (addr & 255)
 byte2 = ((addr >> 8) & 255)
 if (byte1 in (10, 0, 127)):
  return False
 if ((byte1 == 172) and (byte2 > 16)):
  return False
 if ((byte1 == 192) and (byte2 == 168)):
  return False
 return True

def is_public_ip ( ipstr ) : addr = ipstr . split ( ':' ) [ 0 ] addr = int ( addr , 16 ) byte1 = ( addr & 255 ) byte2 = ( ( addr >> 8 ) & 255 ) if ( byte1 in ( 10 , 0 , 127 ) ) : return False if ( ( byte1 == 172 ) and ( byte2 > 16 ) ) : return False if ( ( byte1 == 192 ) and ( byte2 == 168 ) ) : return False return True
take a /proc/net/tcp encoded src or dest string return true if it is coming from public ip space .