Domain Detective

DNS Examples

Edit on GitHub

Practical DnsClientX and DomainDetective DNS examples for browser, PowerShell, C#, and CLI workflows.

DNS Lane

Overview

Use this page when you already know you want concrete DNS commands or code.

It sits between the browser DNS Lookup workspace and the broader API guides:

  • start in the browser when you want a quick focused DNS view
  • come here when you want copy-ready local examples
  • move to the full API guides when you need the broader DomainDetective surface

PowerShell Examples

Install the DNS module:

Install-Module DnsClientX -Scope CurrentUser
Import-Module DnsClientX

Query common apex records:

Resolve-Dns -Name 'contoso.com' -Type A, AAAA, MX -DnsProvider Cloudflare | Format-Table

Query a mail-policy hostname:

Resolve-Dns -Name '_dmarc.contoso.com' -Type TXT -DnsProvider Google | Format-Table

Query a DKIM selector:

Resolve-Dns -Name 'default._domainkey.contoso.com' -Type TXT, CNAME -DnsProvider Cloudflare | Format-Table

Benchmark resolvers:

Test-DnsBenchmark -Name 'contoso.com' -DnsProvider Cloudflare, Google, Quad9 -Attempts 3 |
    Sort-Object Rank | Format-Table Target, SuccessPercent, AverageMs, Rank, IsRecommended

C# Examples

Install the package:

dotnet add package DnsClientX

Query one record type:

using DnsClientX;

var response = await ClientX.QueryDns("contoso.com", DnsRecordType.A, DnsEndpoint.Cloudflare);
foreach (var answer in response.Answers) {
    Console.WriteLine($"{answer.Name} -> {answer.Data}");
}

Query multiple focused record types:

using DnsClientX;

var recordTypes = new[] { DnsRecordType.TXT, DnsRecordType.CNAME };
foreach (var recordType in recordTypes) {
    var response = await ClientX.QueryDns("default._domainkey.contoso.com", recordType, DnsEndpoint.Google);
    foreach (var answer in response.Answers) {
        Console.WriteLine($"{recordType}: {answer.Name} -> {answer.Data}");
    }
}

Use the DomainDetective DNS inventory:

using DomainDetective;

var healthCheck = new DomainHealthCheck();
await healthCheck.VerifyDnsInventoryAsync("contoso.com");

foreach (var query in healthCheck.DnsInventoryAnalysis.Queries) {
    Console.WriteLine($"{query.RecordType}: {query.Status} ({query.Records.Count} records)");
}

CLI Example

Use the broader DomainDetective DNS inventory from the CLI:

dotnet tool install -g DomainDetective.CLI
domaindetective check contoso.com --checks DNSINVENTORY

When To Use Which Path

  • Use DNS Lookup for a quick browser-safe answer view
  • Use DnsClientX PowerShell or C# when you need specific hostnames, typed records, or repeatable DNS automation
  • Use the wider DomainDetective API or CLI when you want DNS as part of full domain posture analysis