获取 Java 中 DNS 查找的名称服务器信息
如果我按如下方式从 DNS 名称查找 IP 地址:
InetAddress inetAddress = InetAddress.getByName(name);
String address = inetAddress.getHostAddress();
我可以找出哪个名称服务器向我提供了该信息吗?
If I look up a IP address from a DNS name as follows:
InetAddress inetAddress = InetAddress.getByName(name);
String address = inetAddress.getHostAddress();
Can I find out which nameserver gave me the information?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我不确定这是否是您想要的,但是有一个 DNSJava 库,它在 Java 中提供 DNS 功能。也许您可以使用它来更好地理解您的问题,或者实施特定的解决方案?就像我说的,这不是你的完美匹配,但也许有帮助。
I'm not sure if this is what you want, but there's a DNSJava library which provides DNS functionality in Java. Perhaps you can use this to either get a better understanding of your issues, or to implement a particular solution ? Like I say, not a perfect match for you, but perhaps helpful.
对于给定的 InetAddress,请尝试以下操作:
调整它以获取您要查找的内容。
For a given InetAddress, try the following:
Adapt it to pick up what you're looking for.
你需要一个命名上下文。您可以选择指定 DNS 服务器。
即使这样,您也需要选择您正在寻找的内容。这是一个例子。
you need an Naming Context. Optional you can Specify the DNS Server.
And even then you need to select that you are looking for. Here is an example.