开发者

Dns.GetHostEntry error conditions and resolution methods

I have a very specific problem concerning Dns.GetHostEntry:

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 stopp开发者_如何学Pythoned 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.

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). [EDIT:] Even deliberatly addind a wrong PTR record does not make the problem occur on my test machine.

[EDIT2:] 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.

So, my questions are:

  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)?

Thanks and best regards, cun83


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

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".

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜