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

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

问题描述

我想知道是否有任何方法可以强制 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 Framework 完成.Dns.Resolve 方法依赖于内部 Win32 API,这些 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.

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

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