指定要使用哪些DNS服务器来解析.NET中的主机名 [英] Specify which DNS servers to use to resolve hostnames in .NET

查看:363
本文介绍了指定要使用哪些DNS服务器来解析.NET中的主机名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有办法强制System.Net.Dns类使用一组自定义DNS服务器来解析主机名,而不是使用与主网络连接相关联的那些主机名。

I'd like to know if there's any way to force the System.Net.Dns class to resolve hostnames using a set of custom DNS servers instead of using the ones that are associated with the main network connection.

我怀疑这只能使用像DnDns这样的自定义库( http:// dndns.codeplex.com ),但我希望这可以从.NET中完成。

I suspect that this is only possible using a custom library like DnDns (http://dndns.codeplex.com), but I was hoping this could be done from within .NET.

推荐答案

否这不能用.Net框架完成。 Dns.Resolve方法依赖于内部的Win32 API,然后又通过与网络连接相关联的DNS服务器。

No this cannot be done with the .Net Framework. The Dns.Resolve method relies on the internal Win32 APIs which in turn go through the DNS servers associated with the network connection.

为了使其正常工作,您必须更改与网络适配器地址相关联的DNS服务器。

In order to get this to work, you'd have to change the DNS servers associated with the network adapter's address.

这篇关于指定要使用哪些DNS服务器来解析.NET中的主机名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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