code: @Deprecated
    public static String reverseDns(InetAddress hostIp, String ns)
      throws NamingException {
      //
      // Builds the reverse IP lookup form
      // This is formed by reversing the IP numbers and appending in-addr.arpa
      //
      String[] parts = hostIp.getHostAddress().split("\\.");
      String reverseIP = parts[3] + "." + parts[2] + "." + parts[1] + "."
        + parts[0] + ".in-addr.arpa";
  
      DirContext ictx = new InitialDirContext();
      Attributes attribute =
        ictx.getAttributes("dns://"               // Use "dns:///" if the default
                           + ((ns == null) ? "" : ns) + 
                           // nameserver is to be used
                           "/" + reverseIP, new String[] { "PTR" });
      ictx.close();
      
      return attribute.get("PTR").get().toString();
    }
docs: Returns the hostname associated with the specified IP address by the
  provided nameserver.
  
  @param hostIp
  The address to reverse lookup
  @param ns
  The host name of a reachable DNS server
  @return The host name associated with the provided IP
  @throws NamingException
  If a NamingException is encountered
  @deprecated Reliance on DNS is not preferred