DnsClientX 0.1.1

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package DnsClientX --version 0.1.1                
NuGet\Install-Package DnsClientX -Version 0.1.1                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="DnsClientX" Version="0.1.1" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DnsClientX --version 0.1.1                
#r "nuget: DnsClientX, 0.1.1"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install DnsClientX as a Cake Addin
#addin nuget:?package=DnsClientX&version=0.1.1

// Install DnsClientX as a Cake Tool
#tool nuget:?package=DnsClientX&version=0.1.1                

DnsClientX - DnsClient for .NET and PowerShell

DnsClientX is an async C# library for DNS over UDP, TCP, HTTPS (DoH), and TLS (DoT). It also has a PowerShell module that can be used to query DNS records. It provides a simple way to query DNS records using multiple DNS providers. It supports multiple DNS record types and parallel queries. It's available for .NET 6, .NET 7, .NET 8, .NET Standard 2.0, and .NET 4.7.2.

It provides querying multiple DNS Providers.

If you want to learn about DNS:

We try to unify the responses as much as possible for common use cases by translating on the fly. This is because different providers do not store it always the same way. If you find disprepencies please open an issue or better pull request.

Supported .NET Versions

This library supports multiple NET versions:

  • .NET 6
    • No dependencies
  • .NET 7
    • No dependencies
  • .NET 8
    • No dependencies
  • .NET Standard 2.0
    • System.Text.Json
  • .NET 4.7.2
    • System.Text.Json

Features

  • Supports multiple built-in DNS Providers (System, Cloudflare, Google, Quad9, OpenDNS, etc.)
  • Supports both JSON and Wireformat
  • Supports DNS over HTTPS (DoH) using GET and POST methods
  • Supports DNS over TLS (DoT)
  • Supports DNS over UDP, and switches to TCP if needed
  • Supports DNS over TCP
  • Supports DNSSEC
  • Supports multiple DNS record types
  • Supports parallel queries
  • No external dependencies on .NET 6, .NET 7 and .NET 8
  • Minimal dependencies on .NET Standard 2.0 and .NET 4.7.2

TO DO

This library is still in development and there are things that need to be done, tested and fixed. If you would like to help, please do so by opening an issue or a pull request. Things may and will change, as I'm not quite sure what I am doing 😃

  • Add more providers
  • Add more tests
  • Go thru all additional parameters and make sure they have proper responses

Usage

There are multiple ways to use DnsClientX.

using DnsClientX;

Below are some examples.

Querying DNS over HTTPS via provided hostname that uses /dns-query endpoint and JSON format

var data = await ClientX.QueryDns("evotec.pl", DnsRecordType.A, "1.1.1.1", DnsRequestFormat.JSON);
data.Answers

Querying DNS over HTTPS via defined endpoint using QueryDns

var data = await ClientX.QueryDns("evotec.pl", DnsRecordType.A, DnsEndpoint.CloudflareWireFormat);
data.Answers

Querying DNS over HTTPS via full Uri using QueryDNS and JSON format

var data = await ClientX.QueryDns("evotec.pl", DnsRecordType.A, new Uri("https://1.1.1.1/dns-query"), DnsRequestFormat.JSON);
data.Answers

Querying DNS over HTTPS via defined endpoint using ResolveAll

var Client = new ClientX(DnsEndpoint.OpenDNS);
var data = await Client.ResolveAll(domainName, type);
data

Querying DNS over HTTPS with single endpoint using ResolveAll

var Client = new ClientX(DnsEndpoint.OpenDNS);
var data = await Client.ResolveAll(domainName, type);
data

Querying DNS over HTTPS with multiple endpoints using Resolve

var dnsEndpoints = new List<DnsEndpoint> {
    DnsEndpoint.Cloudflare,
    DnsEndpoint.CloudflareSecurity,
    DnsEndpoint.CloudflareFamily,
    DnsEndpoint.CloudflareWireFormat,
    DnsEndpoint.Google,
    DnsEndpoint.Quad9,
    DnsEndpoint.Quad9ECS,
    DnsEndpoint.Quad9Unsecure,
    DnsEndpoint.OpenDNS,
    DnsEndpoint.OpenDNSFamily
};

// List of endpoints to exclude
var excludeEndpoints = new List<DnsEndpoint> {

};

var domains = new List<string> {
    "github.com",
    "microsoft.com",
    "evotec.xyz"
};

// List of record types to query
var recordTypes = new List<DnsRecordType> {
    DnsRecordType.A,
    DnsRecordType.TXT,
    DnsRecordType.AAAA,
    DnsRecordType.MX,
    DnsRecordType.NS,
    DnsRecordType.SOA,
    DnsRecordType.DNSKEY,
    DnsRecordType.NSEC
};

foreach (var endpoint in dnsEndpoints) {
    if (excludeEndpoints.Contains(endpoint)) {
        continue; // Skip this iteration if the endpoint is in the exclude list
    }

    // Create a new client for each endpoint
    var client = new ClientX(endpoint) {
        Debug = false
    };

    foreach (var domain in domains) {
        foreach (var recordType in recordTypes) {
            DnsResponse? response = await client.Resolve(domain, recordType);
            response.DisplayToConsole();
        }
    }
}

Please share with the community

Please consider sharing a post about DnsClientX and the value it provides. It really does help!

Share on reddit Share on hacker news Share on twitter Share on facebook Share on linkedin

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETFramework 4.7.2

  • .NETStandard 2.0

  • net6.0

    • No dependencies.
  • net7.0

    • No dependencies.
  • net8.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.3.4 0 11/25/2024
0.3.3 0 11/25/2024
0.3.2 0 11/25/2024
0.3.1 133 10/19/2024
0.3.0 97 9/19/2024
0.2.2 107 7/14/2024
0.2.1 173 4/27/2024
0.2.0 121 4/27/2024
0.1.1 124 4/5/2024