Dns.GetHostEntry错误情况和解决方法 [英] Dns.GetHostEntry error conditions and resolution methods

查看:2898
本文介绍了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条目评论<一个href="http://msdn.microsoft.com/en-us/library/ms143998%28v=VS.85%29.aspx">http://msdn.microsoft.com/en-us/library/ms143998(v=VS.85).aspx indictate,有可能是与主机的反向DNS条目的问题,但我没能重现该问题的测试网络上,即使删除了(还有其他的.NET版本的详细评论,所有让所有的反向查找区域similiar问题)。即使deliberatly addind一个错误的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. 在何种条件下也GetHostEntry抛出此特定错误?
  2. 在哪些解决方法不会使用?如果我没有记错,它使用了非托管Winsock函数则getnameinfo(<一href="http://msdn.microsoft.com/en-us/library/ms738532%28v=vs.85%29.aspx">http://msdn.microsoft.com/en-us/library/ms738532(v=vs.85).aspx),: 名称解析可以通过域名系统(DNS),本地hosts文件,或其他命名机制。
  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

推荐答案

我个人一直使用<一个href="http://msdn.microsoft.com/en-us/library/system.net.dns.gethostaddresses.aspx">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".

据我所知,<一个href="http://msdn.microsoft.com/en-us/library/system.net.dns.gethostaddresses.aspx">Dns.GetHostAddresses刚刚返回的IP地址。

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

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

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