Using ARSoft.Tools.Net to implement a client-side DNS resolution service, this tool allows you to see if the current client resolves a domain name with the correct address.
ARSoft.Tools.Net is a very powerful library of open source DNS controls, including. Net SPF validation, SenderID validation, and DNS Client, DNS server interfaces.
This interface makes it easy to implement DNS client-side and server-side resolution. Project address: http://arsofttoolsnet.codeplex.com/or reference: http://i.isclab.org/?p=327
The main code of the tool:
1 Private voidBtndns_click (Objectsender, EventArgs e)2 {3 intQuery_timeout =10000;4 stringDomain =Txtdomain.text;5 stringDNSADDR =Txtdnsaddr.text;6 txtresult.clear ();7btndns.enabled =false;8Btndns.text ="parsing ...";9 NewThread (() =Ten { One if(string. Isnullorwhitespace (domain)) A { -MessageBox.Show ("the domain name to be resolved cannot be empty"); - return; the } - if(string. Isnullorwhitespace (DNSADDR)) - { -MessageBox.Show ("DNS address is not nullable"); + return; - } + //Initialize dnsclient, the first parameter is the IP of the DNS server, the second parameter is the time-out A //dnsclient dnsclient = new Dnsclient (Ipaddress.parse ("8.8.8.8"), query_timeout); atDnsclient dnsclient =Newdnsclient (Ipaddress.parse (DNSADDR), query_timeout); - //resolves the domain name. Send the domain request to the DNS server resolution, the first parameter is the domain name that needs to be resolved, the second parameter is the resolution type, RECORDTYPE.A is the IPV4 type - //dnsmessage dnsmessage = dnsclient.resolve ("sso.zt-express.com", recordtype.a); -Dnsmessage Dnsmessage =dnsclient.resolve (domain, recordtype.a); - //If the returned result is empty, or if there is an error, the request fails. - if(Dnsmessage = =NULL|| (Dnsmessage.returncode! = Returncode.noerror && Dnsmessage.returncode! =returncode.nxdomain)) in { - //return null; to //Console.WriteLine ("No resolution succeeded"); + This. Invoke (NewAction (() = - { theTxtresult.text ="No resolution succeeded"; *btndns.enabled =true; $Btndns.text ="parsing";Panax Notoginseng - })); the } + Else A { the //loops through the returned results, adding the returned IPV4 records to the result set list. + foreach(Dnsrecordbase Dnsrecordinchdnsmessage.answerrecords) - { $Arecord Arecord = Dnsrecord asArecord; $ if(Arecord! =NULL) - { - //Resultiplist.add (aRecord.Address.ToString ()); the //Console.WriteLine (aRecord.Address.ToString ()); - This. Invoke (NewAction (() =Wuyi { theTxtresult.appendtext (aRecord.Address.ToString () +"\ r \ n"); - })); Wu } - Else About { $ Continue; - } - } - This. Invoke (NewAction (() = A { +btndns.enabled =true; theBtndns.text ="parsing"; - })); $ the } the the }). Start (); the -}
Tool: Http://files.cnblogs.com/files/hnsongbiao/Release.rar
C # Implementing the DNS Resolution service