Dns.GetHostEntry错误条件和分辨率方法 [英] Dns.GetHostEntry error conditions and resolution methods

查看:416
本文介绍了Dns.GetHostEntry错误条件和分辨率方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个非常具体的问题,关于Dns.GetHostEntry:

I have a very specific problem concerning Dns.GetHostEntry:

服务使用Dns.GetHostEntry来检索主机的所有IP地址,使用主办。这一直很好。
在特定的客户端,Dns.GetHostEntry在查询特定的主机时抛出没有这样的主机已知错误。该问题仅在尝试解析与安装服务的计算机不同的域上的主机时才会发生。该服务已经工作了很长时间,但最近停止工作,抛出没有这样的主机已知的错误(可惜的是,没有堆栈跟踪可用)。 Nslookup工作尽管没有问题。
有问题的服务是用VB.NET编写的,目标是.NET Framwork 2.0。

A service uses Dns.GetHostEntry to retrieve all IP Adresses of a host, using the name of of the host. This has always worked fine. At a specific customer, Dns.GetHostEntry throws the "no such host is known" error when querying specific hosts. The problem only occurs when trying to resolve hosts that are on a different domain than the machine the service is installed on. The service has worked for quite some time, but recently is stopped working, throwing the "no such host is known" error (sadly, no stack trace is available). Nslookup works though, no problems there. The service in question is written in VB.NET, targetting the .NET Framwork 2.0.

.NET 3.0的MSDN条目中的注释( http://msdn.microsoft.com/en-us/ library / ms143998(v = VS.85).aspx 指示主机反向DNS条目可能存在问题,但是我无法在测试网络上重现问题,即使是所有的反向查找区域被删除(对于其他.NET版本,有更多的评论,都有类似的问题)。甚至故意添加错误的PTR记录不会在我的测试机器上发生问题。

The comments in the MSDN entry for .NET 3.0 (http://msdn.microsoft.com/en-us/library/ms143998(v=VS.85).aspx indictate that there may be a problem with the reverse DNS entries for the hosts, but I was not able to reproduce the problem on a test network, even with all reverse lookup zones deleted (there are more comments for other .NET Versions, all having similiar problems). Even deliberatly addind a wrong PTR record does not make the problem occur on my test machine.

导致错误的唯一方法是断开网络适配器,从而使DNS服务器不可用,即使由于缓存而导致正向解析仍然有效。

The only thing that made the error come up was disconnecting the network adapter, and thereby making the DNS Server unavailable, even though the forward resolving still worked due to caching.

所以,我的问题是:


  1. GetHos在哪些条件下tEntry抛出这个具体的错误?

  2. 它使用哪些分辨率方法?如果我没有被误认为使用非托管的WinSock函数getnameinfo( http://msdn.microsoft.com/en-us/library/ms738532(v = vs85).aspx ),名称解析可以是域名系统(DNS),一个本地主机文件,或其他命名机制。

  3. 任何有关其他域中的计算机突然失败的想法(但不适用于同一域的计算机) )?

  1. Under which conditions does GetHostEntry throw this specific error?
  2. Which resolution methods does it use? If I'm not mistaken it uses the unmanaged WinSock function getnameinfo (http://msdn.microsoft.com/en-us/library/ms738532(v=vs.85).aspx),: "Name resolution can be by the Domain Name System (DNS), a local hosts file, or by other naming mechanisms".
  3. Any ideas why this suddenly fails for machines on the other domain (but not for machines on the same domain)?

感谢和最好的问候,
cun83

Thanks and best regards, cun83

推荐答案

我个人总是使用 Dns.GetHostAddresses 。它总是给我一个可靠的结果。

I personally always use Dns.GetHostAddresses. It always gives me a reliable result.

关于为什么 Dns.GetHostEntry 给你指定的错误,我认为这是因为 DnsGetHostEntry 将在返回您的IP地址之前尝试执行反向DNS查找。如果反向DNS查找失败,它会给你没有这样的主机是已知的。

Regarding to why Dns.GetHostEntry gives you the specified error, I think it's due to the fact that DnsGetHostEntry will attempt to do a reverse DNS lookup before returning you the IP address. If reverse DNS lookup fails, it will give you "no such host is known".

据我所知, Dns.GetHostAddresses 只是返回IP地址。

As far as I know, Dns.GetHostAddresses just returns the IP address.

这篇关于Dns.GetHostEntry错误条件和分辨率方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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