Saved for later

Managed C# DNS Libraries

The .NET framework has build-in DNS functions but it is limited to A and PTR records. To be able to look-up SRV, TXT and MX records among other you need to use a third party library.

TL;DR use ARSoft.Tools.Net

One answer (copy here) is being repeated on Stack Overflow and lists the following items without explanation*.

*The last comment about freeware is from the original post.

We’ll go through these options. Some of them will be cut out rather quickly so if you don’t agree with the reasoning feel free to investigation the option further.


We want a library that can be included in any kind of project, so strict copyleft and non-free licenses will be excluded.

Library source code need to be accessible and easy to compile, if there is any issues with the library we can do a quick fix without waiting for the next release.

Option 0: .NET Framework

Without any extra libraries we can do A and PTR look-up using the .NET Framework.

//Domain look-up (A)
IPHostEntry entries = Dns.GetHostEntry("");
foreach (var ip in entries.AddressList)

//Reverse IP lookup (PTR)
IPHostEntry reverse = Dns.GetHostEntry(entries.AddressList [0]);

Option 1, 2, 6: Cutting Licenses

Whenever something is posted on “Code Project” one should proceed with caution. Especially when looking for a library, “Code Project” is not about hosting projects but rather articles with code attached. More importantly the default license of all content is the CPOL which is a very restrictive license.

Also the “freeware” licenses with custom restrictions are not worth looking into.

Therefore we will not look more into the DNS.NET Resolver, C# .NET DNS query component and JH Software’s DNS Client Library

Option 3: OpenDNS.NET


First impression is an empty website. If you remove all the SourceForge generated data all that is hosted there is a single OpenDNS.NET 1.0b beta from 2005, the public domain license and the description:

C# DNS Client Library (100% managed code). Query domains to get MX records, CNAME and Address resource records from your application. All common DNS query types supported. Supports user-defined servers.


As the upload was from 2005 there is no surprise that the first step of loading the project was to convert from the old 2003 build.

var q = new DnsQuery("", Types.WKS);
if(q.Send() == false)
    throw new Exception("no response");

The code is a low-level interface for the dns protocol with some method comments but knowing what WKS is is not within easy reach.


This project was abandoned when published and now its age shows.

Option 4: DnDns


Latest release was in 2010. During that year both own commits and patches form others have been merged.

The code is managed in subversion, svn.

Licensed under the New BSD License


DnsQueryRequest request = new DnsQueryRequest();
DnsQueryResponse response = request.Resolve("", NsType.A, NsClass.INET, ProtocolType.Udp);
Console.WriteLine(response.Answers [0].Answer);

Similar to other this one is also very low-level. One complain on the above interface was that ProtocolType was a System.Net.Socket.ProtocolType having about 20 options, but only 2 of them, Tcp and Udp was supported which was found out at runtime.

This one is a candidate.

Option 5: ARSoft.Tools.Net

This tool is described as a DNS and SPF/SenderID library, in which DNS is an important component for all functions.


Last release was in 2012, with a few previous ones over the years. Over the year issues have been reported and handled actively.

Licensed under the Apache License 2.0

The source code is only released in a .zip along the releases, no source code control is being published.


DnsMessage r = DnsClient.Default.Resolve("");
ARecord a = (ARecord)r.AnswerRecords [0];

As can be seen in the example code above there is a default instance unless you want to specify the dns servers, also the Resolve parameters can be expanded to resolve other than A records but still with the simple interface for A lookups.

This is the one.

Creative Commons License