Simple DNS Plus
menubar Skip Navigation Links
Home
Product Details
Download
Purchase
Support
Company
Search
menubar

DNS Client Library for .NET

This library (JH Software's DNS Client Library for .NET) is a freeware component that can be used to perform simple as well as advanced DNS lookups from any .NET code (.NET v. 2.0 or later) against any standard based DNS server.

The .NET framework system.Net.Dns class does provide methods to do basic forward and reverse DNS lookups (host name to IP address / IP address to host name), but it cannot lookup other record types (such as MX-records to locate e-mail servers), it does not allow you to specify which DNS servers to use or specify any options for how the lookup is performed, and it does not give you access to any of the DNS response flags and additional data.
This library fixes all that and more.

Features

  • Lookup any DNS record type (A, AAAA, MX, SPF, SOA, SRV, etc.).
  • Optionally specify which DNS servers to query (default = DNS servers from local system config).
  • Optionally use EDNS0 / specify payload size (more efficient lookups with UDP packets larger than 512 bytes).
  • Optionally use DNS-0x20 (protect against Kaminsky bug / DNS spoofing).
  • Specify whether to request recursion or not (RD flag).
  • Specify request timeout and retry count.
  • Specify which port number to send queries to (default = 53).
  • Access to response details including responding server IP address, AA-flag (authoritative answer), RA-flag (recursion available), EDNS0, as well as individual DNS records (name, type, TTL, data) in answer, authority, and additional sections.
  • Synchronous and asynchronous (Begin.../End...) lookup methods.
  • Works with both IPv4 and IPv6 DNS servers.
  • Automatically switches from UDP to TCP when receiving truncated responses (TC flag).
  • Always uses random query ID and UDP origin port number (protect against Kaminsky bug / DNS spoofing).
  • Fully documented including intellisense in Visual Studio.
  • Convenient simplified methods for host (A/AAAA), reverse (PTR), and MX lookups.
  • Functions to encode/decode IDNs (Internationalized Domain Names).
  • Built on program code from Simple DNS Plus - tested by thousands of users for +10 years.
  • Freeware (see license terms below).

Programming Overview

The primary functions in this library are Lookup, LookupHost, LookupReverse, and LookupMX - all static methods of JHSoftware.DnsClient. Each of these functions have several of overloads, and each has an asynchronous version (Begin... / End...). The LookupHost, LookupReverse, LookupMX functions are used to lookup specific types of DNS records and only return basic data. The Lookup function can lookup any DNS record type and returns a detailed Response object.
For more details, see the help file - also included as a .chm file in the download.

Code Samples

Lookup e-mail servers (MX) for simpledns.com: VB.NET  C#
Dim MXs = JHSoftware.DnsClient.LookupMX("simpledns.com")
For Each MX In MXs
   Console.WriteLine(MX.Preference & " " & MX.HostName)
   If MX.IPAddresses IsNot Nothing Then
      For Each IP In MX.IPAddresses
         Console.WriteLine(">>> " & IP.ToString())
      Next
   End If
Next
Lookup IPv4 addresses for www.simpledns.com using specific DNS servers: VB.NET  C#
Dim 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")}
Dim IPs = JHSoftware.DnsClient.LookupHost("www.simpledns.com", _
                                          JHSoftware.DnsClient.IPVersion.IPv4, _
                                          Options)
For Each IP In IPs
   Console.WriteLine(IP.ToString)
Next
Lookup SPF-records for simpledns.com (and check if DNS server offers recursion): VB.NET  C#
Dim Response = JHSoftware.DnsClient.Lookup("simpledns.com", _
                                           JHSoftware.DnsClient.RecordType.SPF)
Console.WriteLine("Recursion available: " & Response.RecursionAvailable)
For Each Record In Response.AnswerRecords
   Console.WriteLine(Record.Name & " " & _
                     Record.Type.ToString & " " & _
                     Record.TTL & " " & _
                     Record.Data)
Next
Do asynchronous lookup for www.simpledns.com: VB.NET  C#
Sub Main()
   JHSoftware.DnsClient.BeginLookupHost("www.simpledns.com", _
                                        JHSoftware.DnsClient.IPVersion.IPv4, _
                                        Nothing, _
                                        AddressOf MyCallback, _
                                        Nothing)
   REM do other stuff while waiting for lookup to complete...
   Console.ReadKey()
End Sub

Sub MyCallback(ByVal ar As IAsyncResult)
   Dim IPs = JHSoftware.DnsClient.EndLookupHost(ar)
   For Each IP In IPs
      Console.WriteLine(IP.ToString)
   Next
End Sub

License Terms

This software is provided to you free of charge (freeware). You may not reverse engineer it or pass it on as your own as your own creation, but otherwise you are free to use it, include it with other products and services, and distribute it through any media in any way you like. We would of course appreciate a link back to this page page, and/or to be mentioned in the credits of whatever you use it for, but neither is required.

Download

Download JH Software's DNS Client Library for .NET v. 1.0 build 1 (October 29th 2009):

Download JHSoftware.DnsClient.zip (269 KB)

Release Notes

Version 1.0 build 1 - October 29th 2009
- First release.




Comments: RSS

03 Sep 2010 00:38 GMT - by petersonwilliams:
thanks for the release of idea to aid it's required personnesl like me . kudos ..................................

23 Sep 2010 14:12 GMT - by Marc:
Any chance of a 64-bit compiled version for .net 4.0 (or source...)?

07 Oct 2010 16:54 GMT - by mike g:
64 bit .net 4.0 would be amazing... something I'd pay for .. any chance?

18 Mar 2011 14:47 GMT - by Marc:
So, I'm guessing this is abandonware? Does anyone monitor these?

18 Mar 2011 18:15 GMT - by Jesper - JH Software:
Above library is compiled for "AnyCPU" and should work fine with both 32 and 64 bit applications, web-sites, etc.
And while not compiled specifically for .NET 4.0, you should still be able to use it with .NET 4.0 as long as .NET 2.0 is also available.
I expect we will release a .NET 4.0 version at some point, but we don't have a build environment in place for that at this time.

17 May 2011 08:20 GMT - by KickStart64:
Any luck with a .net 4.0 compile ? Btw, why don't you guys release the code ? You are giving away the DLL why not the code as well ??



Copyright © 1999-2012 JH Software ApS. All Rights Reserved.
E-mail questions to
Site Map | Terms of Use | Privacy Statement | Return Policy | About Us
help index