Nager.Dns is a simple and powerful C# DNS client that securely performs DNS queries using DNS over HTTPS (DoH). It supports multiple DNS providers and offers an easy-to-use API.
- Secure DNS queries over HTTPS (DoH)
- Bulk DNS query support
- Multiple DNS providers included (e.g., Google, Cloudflare)
- Lightweight and fast
- Easily integrates with .NET applications
The package is available on nuget
PM> install-package Nager.Dns
Perform DNS queries for multiple domains at once:
var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider();
var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
var dnsQuestions = new DnsQuestion[]
{
new DnsQuestion("google.com", DnsAnswerType.A),
new DnsQuestion("microsoft.com", DnsAnswerType.A)
};
var dnsClient = new DnsClient(httpClientFactory);
var responses = await dnsClient.BulkDnsQueryAsync(dnsQuestions, DnsProvider.Google);
Perform a DNS query for a single domain:
var serviceProvider = new ServiceCollection().AddHttpClient().BuildServiceProvider();
var httpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
var dnsClient = new DnsClient(httpClientFactory);
var responses = await dnsClient.DnsQueryAsync(new DnsQuestion("google.com", DnsAnswerType.A), DnsProvider.Google);
- Google Public DNS
- Cloudflare DNS
We welcome feedback, feature requests, and contributions! Feel free to open an issue or submit a pull request.