0

我需要像在 nslookup 中那样使用特定的 DNS 服务器来解析主机名

C:\>nslookup hotname 192.100.10.10
Server:  UnKnown
Address:  192.100.10.10

Name:    hostname.host
Address:  192.100.10.14

但当然作为回报,我不只是想要地址,我想要所有的值ServerAddressNameAddress

我查看了System.Net.Dns课程,但这只给了我解析的 IP 地址,并没有让我选择我选择的 DNS 服务器

如果有人以前这样做过,你可以帮助我。

编辑:

为 C# 找到一个:http ://www.simpledns.com/dns-client-lib.aspx

这是我的代码片段,仅供娱乐

//Buy him Cookies and Strippers
using JHSoftware;
4

1 回答 1

1

我仍然没有 C++ 的答案,但这是 C# 的答案

var Options = new JHSoftware.DnsClient.RequestOptions();
Options.DnsServers = new System.Net.IPAddress[] { 
           System.Net.IPAddress.Parse("1.1.1.1"), 
           System.Net.IPAddress.Parse("2.2.2.2") };
var IPs = JHSoftware.DnsClient.LookupHost("www.simpledns.com", 
                                          JHSoftware.DnsClient.IPVersion.IPv4, 
                                          Options);
foreach(var IP in IPs)
{
   Console.WriteLine(IP.ToString());
}

以上是使用 JHSoftware.dll 并从那里复制代码以帮助其他人,链接如下:

http://www.simpledns.com/dns-client-lib.aspx

于 2010-04-22T04:24:01.110 回答