@ 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 ( ) ; }
Returns the hostname associated with the specified IP address by the provided nameserver .