how to make reverse dns lookup in Java(如何在 Java 中进行反向 dns 查找)
问题描述
我有一个 IP 列表.我需要做reveres 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,因为它由 yahoo 持有.
The IP Address in the code your provided resolves to yahoo because it is held by yahoo.
您使用的 IP 地址仅指定给一台主机.你可以想象雅虎可能有成千上万的服务器.他们被分配了一个 ipaddresses 分配,然后在他们认为适合内部分配的情况下重用这些 ipaddresses.yahoo 域下的不同服务器具有不同的名称,因此当您从特定服务器引用 IP 地址时,您将获得该特定服务器的名称.对于可能隐藏的 yahoo.com 的一般 IP 地址,除非您想要进行 nslookup 并查询整个 IP 地址范围以查找 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 查找的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何在 Java 中进行反向 dns 查找
基础教程推荐
- Java:带有char数组的println给出乱码 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- 降序排序:Java Map 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01