For this InetAddress, try the following:
InitialDirContext idc = new InitialDirContext();
Attributes attributes = idc.getAttributes("dns:/" + inetAddress.getHostName());
NamingEnumeration attributeEnumeration = attributes.getAll();
System.out.println("-- DNS INFORMATION --");
while (attributeEnumeration.hasMore()) {
System.out.println("" + attributeEnumeration.next());
}
attributeEnumeration.close();
Adapt it to choose what you are looking for.
source
share