nslookup for C# and C++ to resolve a host using a specific Server
I need to resolve a hostname using a specific DNS server like you would in nslookup
C:\>nslookup hotname 192.100.10.10
Server: UnKnown
Address: 192.100.10.10
Name: hostname.host
Address: 192.100.10.14
But of course in return I don't just want the address I want all the values for Server
, Address
, Name
and Address
I h开发者_Go百科ave looked at the System.Net.Dns
Class but that only gives me the Resolved IP Address and doesn't let me select the DNS Server of my choosing
If any one has done this before and you can help me with this.
Edit:
Found One for C# : http://www.simpledns.com/dns-client-lib.aspx
Here is a snippet of my code just for some entertainment
//Buy him Cookies and Strippers
using JHSoftware;
I still dont have an answer for C++ but here is the one for 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());
}
The above is using JHSoftware.dll and the code is copied from there to help others, the link is as below:
http://www.simpledns.com/dns-client-lib.aspx
精彩评论