如何在Java中进行反向dns查找 [英] how to make reverse dns lookup in Java

查看:191
本文介绍了如何在Java中进行反向dns查找的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一份IP列表。我需要尊重DNS,即我想要网站名称。

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

我尝试了以下内容:

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

但是,我的示例中的IP是针对yahoo.com的,当我运行代码时,我得到了:ir1.fp.vip.ne1.yahoo.com

But, the IP in my example is for yahoo.com, when I run the code, I get: ir1.fp.vip.ne1.yahoo.com

我需要一种方法,这样我就可以通过输入IP来获取域名。

I need a way so I can get the domain name by entering the IP.

推荐答案

您提供的代码中的IP地址解析为yahoo,因为它由雅虎持有。

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

您使用的IP地址仅指定给一个主机。你可以想象雅虎可能拥有数千台服务器。他们被分配了一个ipaddresses的分配,然后他们重新使用,因为他们认为适合内部分配。 yahoo域下的不同服务器具有不同的名称,因此当您从特定服务器引用IP地址时,您将获得该特定服务器的名称。对于yahoo.com的一般ipaddress可能是隐藏的,除非你想要nslookup并查询整个范围的ipaddress以找到yahoo.com分配并从那里推广。

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.

这篇关于如何在Java中进行反向dns查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆