how to make reverse dns lookup in Java

前端 未结 2 1777
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-06 10:32

I have a list of IPs. I need to make reveres DNS, i.e, I want the website name.

I tried the following:

InetAddress addr = InetAddress.getByName(\"98.         


        
2条回答
  •  甜味超标
    2021-01-06 11:30

    Using IP address to get the domain name (in the way you are expecting) might not be possible. There will be several servers for Yahoo and they all will map to the domain name yahoo.com. But they will have individual ip address and host name. The addr.getCanonicalHostName() returns the host name and not the domain name!

提交回复
热议问题