How to resolve DNS from java like WIRESHARK does?

Could you explain how Wireshark makes a DNS query in order to resolve the name of an IP address?

My issue is about the mismatch between the domain name resolved by Wireshark and that returned by nslookup. Moreover, nslookup sometimes fails for certain IP addresses where Wireshark succeeds. Further, I would to get the same value from java.

An example to clarify: A case I found (one of thousands) is about the address 54.230.45.185

Wireshark resolves it as: dwjgneh8ogcu1.cloudfront.net (54.230.45.185) (yes, it seems to be a randomly generated domain name)

The other tools resolve it differently, something like: server-54-230-45-185.fra6.r.cloudfront.net

So I'm wondering how or where Wireshark finds that domain name.

Another example is: installer.betterinstaller.com (78.138.127.15).

1

1 Answer

Consider asking Java-related questions on StackOverflow.

E.g.,

InetAddress addr = InetAddress.getByName("98.138.253.109");
String host = addr.getCanonicalHostName();
System.out.println(host);

This is called an IP lookup, or a reverse DNS lookup (the latter is, I believe, a more appropriate naming).

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like