how to make reverse dns lookup in Java

前端 未结 2 1765
佛祖请我去吃肉
佛祖请我去吃肉 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:13

    The IP Address in the code your provided resolves to yahoo because it is held by yahoo.

    The Ip address you are using is designated for only one host. As you can imagine yahoo probably has thousands of servers. They get assigned an allocation of ipaddresses which they then reuse as they see fit for internal allocation. The different servers under yahoo domain have different names and hence when you reference an ip address from a specific server you get the name for that specific server. For the general ipaddress for yahoo.com that might be hidden unless you want to to a nslookup and query a whole range of ipaddress to find yahoo.com allocations and generalize from there.

    0 讨论(0)
  • 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!

    0 讨论(0)
提交回复
热议问题