Soenneker.DnsClient.Util
11.0.1306
Prefix Reserved
dotnet add package Soenneker.DnsClient.Util --version 11.0.1306
NuGet\Install-Package Soenneker.DnsClient.Util -Version 11.0.1306
<PackageReference Include="Soenneker.DnsClient.Util" Version="11.0.1306" />
<PackageVersion Include="Soenneker.DnsClient.Util" Version="11.0.1306" />
<PackageReference Include="Soenneker.DnsClient.Util" />
paket add Soenneker.DnsClient.Util --version 11.0.1306
#r "nuget: Soenneker.DnsClient.Util, 11.0.1306"
#:package Soenneker.DnsClient.Util@11.0.1306
#addin nuget:?package=Soenneker.DnsClient.Util&version=11.0.1306
#tool nuget:?package=Soenneker.DnsClient.Util&version=11.0.1306
Soenneker.DnsClient.Util
Provides a lazily initialized, cached DnsClient.NET LookupClient through dependency injection.
Installation
dotnet add package Soenneker.DnsClient.Util
Registration
using Soenneker.DnsClient.Util.Registrars;
services.AddDnsClientUtilAsSingleton();
Use AddDnsClientUtilAsScoped() when each dependency-injection scope should own a separate lookup client and cache.
Query a record
using DnsClient;
using DnsClient.Protocol;
using Soenneker.DnsClient.Util.Abstract;
public sealed class AddressResolver(IDnsClientUtil dnsClientUtil)
{
public async Task<IReadOnlyList<string>> Resolve(
string host,
CancellationToken cancellationToken)
{
LookupClient client = await dnsClientUtil.Get(cancellationToken: cancellationToken);
IDnsQueryResponse response = await client.QueryAsync(
host,
QueryType.A,
cancellationToken: cancellationToken);
return response.Answers.ARecords()
.Select(record => record.Address.ToString())
.ToArray();
}
}
Get returns the same LookupClient for the utility’s lifetime. The first successful call controls its options; options supplied to later calls are ignored.
Configure the client on the first call when system DNS defaults are not appropriate:
var options = new LookupClientOptions
{
UseCache = true,
Timeout = TimeSpan.FromSeconds(3),
Retries = 2
};
LookupClient client = await dnsClientUtil.Get(options, cancellationToken);
For singleton registration, initialize it once during startup if multiple callers might otherwise race to provide different settings. DnsClient.NET handles DNS response codes and transport failures; inspect the returned response and allow cancellation or network exceptions to propagate when the caller should decide recovery behavior.
The utility owns the cached client. Do not dispose the returned LookupClient; dispose the utility or its dependency-injection scope instead.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- DnsClient (>= 1.8.0)
- Soenneker.Utils.AsyncSingleton (>= 11.0.893)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.DnsClient.Util:
| Package | Downloads |
|---|---|
|
Soenneker.Validators.Email.Mx
A validation module checking for the existence of domain MX records |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.1306 | 139 | 11/11/2026 |
| 11.0.1305 | 121 | 11/11/2026 |
| 11.0.1304 | 88 | 11/11/2026 |
| 11.0.1303 | 103 | 11/11/2026 |
| 11.0.1302 | 87 | 11/11/2026 |
| 11.0.1301 | 449 | 11/3/2026 |
| 11.0.1300 | 182 | 10/27/2026 |
| 11.0.1299 | 140 | 10/26/2026 |
| 11.0.1297 | 109 | 10/26/2026 |
| 11.0.1296 | 111 | 10/26/2026 |
| 11.0.1295 | 134 | 10/26/2026 |
| 4.0.1294 | 128 | 10/25/2026 |
| 4.0.1293 | 167 | 10/15/2026 |
| 4.0.1292 | 125 | 10/15/2026 |
| 4.0.1291 | 115 | 10/14/2026 |
| 4.0.1290 | 137 | 10/14/2026 |
| 4.0.1289 | 98 | 10/14/2026 |
| 4.0.1288 | 102 | 10/14/2026 |
| 4.0.1287 | 112 | 10/14/2026 |
| 4.0.1286 | 105 | 10/14/2026 |
Updated Soenneker.Utils.AsyncSingleton to 11.0.893