Caio13Vinni/dns-race
Über uns
A fast, lightweight, and cross-platform DNS benchmarking CLI written in Rust. Race multiple DNS resolvers concurrently, measure query latency, compare DNS responses, and detect answer divergence.
Systeme und InfrastrukturWhat you can do
- Concurrent DNS queries across multiple resolvers over UDP.
- A and AAAA record types.
- Built-in default resolvers (1.1.1.1, 8.8.8.8, 9.9.9.9) and custom resolvers (IP or IP:port, IPv4 and IPv6).
- Configurable per-query timeout.
Gemessener Sternzuwachs
- in 24h
- +1
- in 7 days
- Verlauf wird gesammelt
- in 15 days
- Verlauf wird gesammelt
- in 1 month
- Verlauf wird gesammelt
Nettoänderungen in überlappenden Zeiträumen, keine Tagessummen. Fehlende Messwerte bleiben leer. Sterne zeigen Interesse, nicht Qualität.
README.md
Originaldns-race
A fast, lightweight, and cross-platform DNS benchmarking CLI written in Rust. Race multiple DNS resolvers concurrently, measure query latency, compare DNS responses, and detect answer divergence.
Status: Phase 1 (Linux) in progress. The first working slice is implemented: concurrent A/AAAA queries to multiple resolvers over UDP, per-query latency and timeout, and a terminal report with the fastest resolver. Sections marked planned are subject to change.
Overview
dns-race fires concurrent DNS queries at multiple resolvers, measures the latency of each response, identifies the fastest resolver, and flags divergences or anomalies in the returned records. It is built for system administrators, developers, and network professionals who need a quick, scriptable way to compare resolver behavior.
Features
Implemented:
- Concurrent DNS queries across multiple resolvers over UDP.
- A and AAAA record types.
- Built-in default resolvers (
1.1.1.1,8.8.8.8,9.9.9.9) and custom resolvers (IPorIP:port, IPv4 and IPv6). - Configurable per-query timeout.
- Multiple benchmark rounds (
--rounds) with per-resolver min/avg/max latency summary. - Per-resolver latency measurement, answer and minimum-TTL reporting, fastest-resolver identification.
- NXDOMAIN handled as a valid negative response (dedicated status, latency preserved), not as a protocol error.
- Answer-set normalization and cross-resolver divergence detection, with an informational min-TTL comparison.
- Human-readable terminal output with per-query latency bars, color-coded latency bands, and a live progress spinner on interactive terminals. Colors follow
NO_COLORand are disabled automatically when the output is piped. - Stable, versioned JSON output (
--json) for automation and CI/CD. - Exit codes suitable for scripts and CI/CD (0 = at least one resolver answered and all successful resolvers agree, 1 = all queries failed, 2 = usage error, 3 = divergent answers detected).
Technologies
- Rust — single codebase, memory-safe systems language.
- Tokio — asynchronous concurrency.
- Clap — CLI argument parsing.
- Hickory Proto — DNS packet construction and parsing.
- UDP — DNS transport.
- colored / indicatif — terminal colors and the live progress spinner.
Installation
There are no releases yet. To build the development version from source you need a Rust toolchain:
git clone https://github.com/Caio13Vinni/dns-race.git
cd dns-race
cargo build --release
The binary will be at target/release/dns-race. Developed and validated on Linux (Phase 1).
Usage
dns-race example.com # query default resolvers
dns-race example.com --resolvers 1.1.1.1,8.8.8.8
dns-race example.com --record-type aaaa
dns-race example.com --timeout 500
dns-race example.com --rounds 5
dns-race example.com --json
dns-race github.com -r 127.0.0.1:53,1.1.1.1:53
On an interactive terminal, resolvers are marked with ✓/✗, each answered query shows a latency bar scaled to the slowest response of the round, and latencies are color-coded (green ≤ 30 ms, yellow ≤ 100 ms, red above):
Querying A records for github.com. from 3 resolver(s) (timeout 2000 ms)
✓ 1.1.1.1:53 12.14 ms ██░░░░░░░░░░░░░░░░░░ [4.228.31.150] (min TTL: 2s)
✓ 8.8.8.8:53 144.34 ms ████████████████████ [4.228.31.150] (min TTL: 60s)
✓ 9.9.9.9:53 12.05 ms ██░░░░░░░░░░░░░░░░░░ [4.228.31.150] (min TTL: 34s)
Fastest resolver: 9.9.9.9:53 (12.05 ms)
Divergence: none (all resolvers agree on [4.228.31.150])
TTL: differs across resolvers (min 2s, max 60s)
CLI reference
| Argument | Short | Description | Default |
|---|---|---|---|
<DOMAIN> |
Domain name to query (positional, required). | — | |
--resolvers <LIST> |
-r |
Comma-separated resolvers as IP or IP:port (numeric IPs only). Duplicate entries are removed, keeping the first occurrence. |
1.1.1.1,8.8.8.8,9.9.9.9 |
--record-type <TYPE> |
Record type: a or aaaa. |
a |
|
--timeout <MS> |
Per-query timeout in milliseconds. | 2000 |
|
--rounds <N> |
Number of sequential benchmark rounds; with N > 1, a per-resolver min/avg/max summary is printed. |
1 |
|
--json |
Print the report as a single JSON document (schema version: 1) on stdout instead of the terminal report. |
off |
Run dns-race --help for the authoritative reference.
Divergence detection
After each run, dns-race normalizes the answer sets of all successful queries (sorted, deduplicated) and compares them across resolvers. The most frequent set becomes the reference; any successful response with a different set is reported as an outlier:
Divergence: DETECTED in 1/1 round(s) (answers differ from the reference set; this can be legitimate, e.g. load balancing or CDNs)
9.9.9.9:53 returned [1.2.3.4], reference [93.184.215.14]
TTL: differs across resolvers (min 60s, max 3600s)
Divergence means the resolvers returned different answer sets, not that any answer is wrong: load balancing, CDNs, and geographic distribution legitimately produce different answers. The reference set is a comparison baseline, not an assertion of the correct answer.
The minimum-TTL comparison is informational only: TTLs naturally vary between caches, so they never affect the verdict. When fewer than two queries return answers, the comparison is reported as inconclusive — in JSON, divergence.inconclusive is true and detected: false then means "not enough data", not "resolvers agree". NXDOMAIN responses carry no answer set and are excluded from the comparison. Divergence sets the exit code to 3 and is also available in the JSON report under the divergence key.
NXDOMAIN responses
A NXDOMAIN answer is a valid negative DNS response (RFC 9520), not an error. It gets a dedicated nxdomain status in the JSON report and keeps its measured latency, so it counts toward per-resolver statistics and the fastest-resolver pick:
✓ 1.1.1.1:53 14.66 ms ███████░░░░░░░░░░░░░ NXDOMAIN (name does not exist)
Architecture
Conceptually, the tool is organized in six layers:
- CLI and validation — parses arguments; validates the domain, record types, and resolvers.
- Round coordinator — manages benchmark rounds.
- Query engine — runs independent queries in parallel with per-query timeouts.
- DNS codec — builds DNS packets and parses responses.
- Aggregation and analysis — normalizes responses, compares IP sets and TTLs, computes statistics, and detects divergence.
- Presentation — human-readable terminal output or JSON for automation.
Roadmap
Development is progressive and each phase requires maintainer approval before the next begins:
- Phase 1 — Linux (in progress): core functionality, concurrent queries, latency measurement, divergence detection, tests, and a stable CLI. Linux only.
- Phase 2 — Windows: adaptation and validation on Windows 10/11, without breaking Linux.
- Phase 3 — macOS: adaptation and validation, including Apple Silicon (ARM64).
- Phase 4 — Cross-platform distribution: CI/CD, multi-platform builds, and automated releases.
Future possibilities (not scheduled): CNAME/MX/TXT/NS/SOA records, DoH, DoT, latency percentiles (p50/p95/p99), an interactive dashboard, and continuous resolver monitoring.
Contributing
Contributions are welcome, under the following rules:
- Every change goes on its own branch and is submitted via Pull Request — never commit directly to
main. - Keep PRs small, focused, and easy to review.
- Run
cargo fmt --check,cargo clippy -- -D warnings,cargo test, andcargo buildbefore opening a PR. - Pull Requests are reviewed, approved, and merged exclusively by the project owner.
- See AGENTS.md for the full development guidelines (in Portuguese).
License
This project is licensed under the MIT License.
Ähnliche Projekte entdecken
Wird geladen…