### Install dns-bench from crates.io using Cargo Source: https://github.com/qwerty541/dns-bench/blob/master/README.md Installs the dns-bench crate from crates.io using the Cargo package manager. This method requires a Rust programming language environment. After installation, the compiled binary can be executed with specified options. ```shell $ cargo install dns-bench $ dns-bench [OPTIONS] ``` -------------------------------- ### Install dns-bench from Git repository using Cargo Source: https://github.com/qwerty541/dns-bench/blob/master/README.md Installs the dns-bench tool directly from its Git repository using Cargo. This is useful for installing development versions or if crates.io is unavailable. It requires a Rust programming language environment. The command allows specifying a tag for a stable release or omitting it for the latest development version. ```shell $ cargo install --git https://github.com/qwerty541/dns-bench.git --tag v0.14.0 dns-bench $ dns-bench [OPTIONS] ``` -------------------------------- ### Run dns-bench with Custom Options Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This example demonstrates running a dns-bench benchmark with specific options: 50 requests (`--requests 50`) to a specific domain (`--domain microsoft.com`) and outputting in a re-structured text format (`--style re-structured-text`). ```sh docker run --rm -it --name dns-bench \ qwerty541/dns-bench:latest \ --requests 50 --domain microsoft.com --style re-structured-text ``` -------------------------------- ### Persist and Reuse dns-bench Configuration Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This example demonstrates saving a configuration and then running the benchmark again using the saved configuration. First, it saves the current flags to the persistent directory. The subsequent run automatically uses the saved configuration. ```sh mkdir -p "$PWD/.dns-bench" # Save current flags docker run --rm -it --name dns-bench \ --volume "$PWD/.dns-bench:/root/.dns-bench" \ qwerty541/dns-bench:latest \ --save-config # Next run uses saved config by default docker run --rm -it --name dns-bench \ --volume "$PWD/.dns-bench:/root/.dns-bench" \ qwerty541/dns-bench:latest ``` -------------------------------- ### CI/CD DNS Performance Monitoring - Bash Script Source: https://context7.com/qwerty541/dns-bench/llms.txt An example bash script for integrating dns-bench into a CI/CD pipeline. It runs a benchmark, outputs results in JSON format, and parses them using 'jq' to check for slow DNS servers. ```bash #!/bin/bash # ci-dns-check.sh - DNS benchmark for CI/CD pipeline # Run benchmark with JSON output and capture results dns-bench \ --format json \ --requests 10 \ --timeout 2 \ --skip-system-servers \ --skip-gateway-detection \ > dns-results.json # Parse results with jq to check if any DNS server is too slow MAX_AVG_MS=50 SLOW_SERVERS=$(jq -r '.[] | select(.avg_duration.succeeded.nanos > '"$((MAX_AVG_MS * 1000000)) ``` -------------------------------- ### Run dns-bench using Docker Hub image Source: https://github.com/qwerty541/dns-bench/blob/master/README.md Pulls and runs the dns-bench tool using its official Docker Hub image. This method does not require a local Rust installation. The tool can be run with default settings or with custom options passed as arguments. It also supports mounting custom server list files. ```shell $ docker pull qwerty541/dns-bench:latest $ docker run --rm -it --name dns-bench qwerty541/dns-bench:latest $ docker run --rm -it --name dns-bench qwerty541/dns-bench:latest --requests 50 --domain microsoft.com --style re-structured-text $ docker run --rm -it --name dns-bench --volume /path/to/ipv4-custom-servers.txt:/servers.txt:ro qwerty541/dns-bench:latest --custom-servers-file /servers.txt ``` -------------------------------- ### Run dns-bench using GHCR image Source: https://github.com/qwerty541/dns-bench/blob/master/README.md Pulls and runs the dns-bench tool using its image from GitHub Container Registry (GHCR). Similar to the Docker Hub method, this avoids the need for a local Rust installation. The commands for running the container are analogous to those used for the Docker Hub image, simply replacing the image reference. ```shell $ docker pull ghcr.io/qwerty541/dns-bench:latest $ docker run --rm -it --name dns-bench ghcr.io/qwerty541/dns-bench:latest ``` -------------------------------- ### Persist dns-bench Configuration Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This example shows how to persist the dns-bench configuration across runs. It creates a directory on the host (`$PWD/.dns-bench`) and mounts it to `/root/.dns-bench` inside the container. The `--save-config` flag saves the current settings to this persistent location. ```sh mkdir -p "$PWD/.dns-bench" docker run --rm -it --name dns-bench \ --volume "$PWD/.dns-bench:/root/.dns-bench" \ qwerty541/dns-bench:latest \ --save-config ``` -------------------------------- ### Reset or Delete Persistent Configuration Source: https://context7.com/qwerty541/dns-bench/llms.txt Provides options to either reset the configuration file to its default values or completely delete the configuration file. This is useful for troubleshooting or starting with a clean slate. ```bash # Reset config to default values dns-bench config reset # Output: Config file reset to default values. # Delete the config file dns-bench config delete # Output: Config file deleted. ``` -------------------------------- ### Run dns-bench executable on Windows Source: https://github.com/qwerty541/dns-bench/blob/master/README.md Executes the pre-compiled Windows binary for dns-bench. This method is suitable for users without a Rust programming language environment. The executable can be downloaded from the releases page and run from the command line with specified options. A warning about the unsigned nature of the executable may appear. ```cmd dns-bench.exe [OPTIONS] ``` -------------------------------- ### Initialize Persistent Configuration Source: https://context7.com/qwerty541/dns-bench/llms.txt Creates a configuration file (typically at ~/.dns-bench/config.toml) to store persistent benchmark settings. This allows users to save their preferred configurations for future runs. ```bash # Create config file with default values # Config is stored at ~/.dns-bench/config.toml dns-bench config init # Output: Config file created with default values. # View current config values dns-bench config list # Output: # domain: google.com # threads: 16 # requests: 50 # timeout: 1 # protocol: udp # name-servers-ip: v4 # lookup-ip: v4 # style: rounded # custom-servers-file: null # format: human-readable # skip-system-servers: false # skip-gateway-detection: false # disable-adaptive-timeout: false ``` -------------------------------- ### Show dns-bench Help Information Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs the dns-bench container and displays its help message, listing all available options and subcommands. This is useful for understanding the full capabilities of the tool. ```sh docker run --rm -it --name dns-bench qwerty541/dns-bench:latest --help ``` -------------------------------- ### Use Custom DNS Server List Source: https://context7.com/qwerty541/dns-bench/llms.txt Enables benchmarking against a user-defined list of DNS servers instead of the default set. This requires creating a text file with server details and specifying it using the --custom-servers-file option. ```bash # Create a custom servers file (IPv4 example) # Format: Name;IP:Port (one per line) cat > my-dns-servers.txt << 'EOF' My ISP DNS;192.168.1.1:53 Corporate DNS;10.0.0.53:53 Google Primary;8.8.8.8:53 Cloudflare Primary;1.1.1.1:53 EOF # Run benchmark with custom server list dns-bench --custom-servers-file my-dns-servers.txt # IPv6 custom servers file example cat > my-ipv6-servers.txt << 'EOF' Google IPv6;[2001:4860:4860::8888]:53 Cloudflare IPv6;[2606:4700:4700::1111]:53 EOF # Benchmark custom IPv6 servers dns-bench --custom-servers-file my-ipv6-servers.txt --name-servers-ip v6 ``` -------------------------------- ### Run dns-bench with Options Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Executes the dns-bench application with specified command-line options. This allows for customized benchmarking scenarios, such as setting name server types, lookup types, and timeouts. ```bash cargo run -- [OPTIONS] ``` -------------------------------- ### Run dns-bench with Threads and Requests Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs a dns-bench benchmark using 16 threads (`--threads 16`) and performing 50 requests (`--requests 50`). This allows for more controlled and potentially faster benchmarking. ```sh docker run --rm -it --name dns-bench \ qwerty541/dns-bench:latest \ --threads 16 --requests 50 ``` -------------------------------- ### Build Project with Cargo Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Builds the dns-bench project using the Cargo build command. This is a fundamental step for local development and testing. ```bash cargo build ``` -------------------------------- ### Test Project with Cargo Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Runs all defined tests for the dns-bench project using the Cargo test command. This is crucial for verifying code correctness and ensuring stability. ```bash cargo test ``` -------------------------------- ### Save CLI Options to Config - dns-bench Source: https://context7.com/qwerty541/dns-bench/llms.txt This command demonstrates how to save the current command-line interface options to a configuration file during a benchmark run. This is useful for reusing specific benchmark settings. ```bash dns-bench --domain github.com --requests 75 --save-config ``` -------------------------------- ### Output dns-bench Results in XML Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs dns-bench and formats the output as XML. This format can be useful for integration with other systems that consume XML data. ```sh docker run --rm -it --name dns-bench \ qwerty541/dns-bench:latest \ --format xml ``` -------------------------------- ### Run dns-bench with Host Networking Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs dns-bench using host networking (`--network host`). This is recommended on Linux for more accurate latency measurements as it bypasses Docker's network translation layers. ```sh docker run --rm -it --name dns-bench --network host qwerty541/dns-bench:latest ``` -------------------------------- ### Output dns-bench Results in JSON Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs dns-bench and formats the output as JSON. This is useful for programmatic processing of the benchmark results. ```sh docker run --rm -it --name dns-bench \ qwerty541/dns-bench:latest \ --format json ``` -------------------------------- ### Output dns-bench Results in CSV and Save to File Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs dns-bench, formats the output as CSV, and redirects the output to a file named `results.csv` on the host machine. This allows for easy saving and analysis of the benchmark data. ```sh docker run --rm --name dns-bench \ qwerty541/dns-bench:latest \ --format csv \ > results.csv ``` -------------------------------- ### Run Interactive dns-bench Benchmark Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs the dns-bench container interactively. It uses default settings, skipping system servers and gateway detection. The `--rm` flag ensures the container is removed after it exits, and `--name` assigns a name for easier management. ```sh docker run --rm -it --name dns-bench qwerty541/dns-bench:latest ``` -------------------------------- ### Mount Custom DNS Server List Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs dns-bench using a custom list of DNS servers provided in a file on the host. The file is mounted read-only (`:ro`) into the container at `/servers.txt` and referenced using `--custom-servers-file`. ```sh docker run --rm -it --name dns-bench \ --volume /path/to/ipv4-custom-servers.txt:/servers.txt:ro \ qwerty541/dns-bench:latest \ --custom-servers-file /servers.txt ``` -------------------------------- ### Run Benchmark with Custom Servers File Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Executes the dns-bench application using a custom list of DNS servers provided in a file. This is useful for testing against specific or private DNS infrastructure. ```bash cargo run -- --custom-servers-file ./examples/ipv4-custom-servers-example.txt ``` -------------------------------- ### Use IPv6 for Lookup and Server Connection Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command configures dns-bench to use IPv6 for both DNS lookups (`--lookup-ip v6`) and for connecting to name servers (`--name-servers-ip v6`). ```sh docker run --rm -it --name dns-bench \ qwerty541/dns-bench:latest \ --lookup-ip v6 --name-servers-ip v6 ``` -------------------------------- ### Lint Code with Cargo Clippy Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Runs the Clippy linter with all features enabled and warnings treated as errors. This helps catch common mistakes and improve code quality. ```bash cargo clippy --all-features -- -D warnings ``` -------------------------------- ### Export Benchmark Results as XML Source: https://context7.com/qwerty541/dns-bench/llms.txt Generates benchmark results in XML format, useful for integration with XML-based workflows and systems. The output can be redirected to a file for storage or further processing. ```bash # Output results as XML dns-bench --format xml # Example XML output: # # # Cloudflare # 1.1.1.1 # 142.250.75.14 # # 50 # 50 # 100 # # 9.48ms # 14.51ms # 11.68ms # # # Save XML to file dns-bench --format xml > dns-results.xml ``` -------------------------------- ### Run dns-bench as Non-Root User Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command runs the dns-bench container as the current user (`--user "$(id -u):$(id -g)"`), which can be useful for permissions management. It also mounts the persistent configuration directory and a custom server list. ```sh docker run --rm -it --name dns-bench \ --user "$(id -u):$(id -g)" \ --volume "$PWD/.dns-bench:/root/.dns-bench" \ --volume /path/to/servers.txt:/servers.txt:ro \ qwerty541/dns-bench:latest \ --custom-servers-file /servers.txt ``` -------------------------------- ### Export Benchmark Results as JSON Source: https://context7.com/qwerty541/dns-bench/llms.txt Outputs benchmark results in JSON format, suitable for programmatic processing. This command can be used to redirect the JSON output to a file for further analysis or integration with other systems. ```bash # Output results as JSON dns-bench --format json # Example JSON output: # [ # { # "name": "Cloudflare", # "ip": "1.1.1.1", # "last_resolved_ip": "142.250.75.14", # "total_requests": 50, # "successful_requests": 50, # "successful_requests_percentage": 100.0, # "min_duration": { "succeeded": { "secs": 0, "nanos": 9695536 } }, # "max_duration": { "succeeded": { "secs": 0, "nanos": 14927918 } }, # "avg_duration": { "succeeded": { "secs": 0, "nanos": 11502243 } } # }, # ... # ] # Save JSON output to file dns-bench --format json > dns-results.json ``` -------------------------------- ### Export Benchmark Results as CSV Source: https://context7.com/qwerty541/dns-bench/llms.txt Exports benchmark results in CSV format, which is easily importable into spreadsheet applications for analysis. The command allows for saving the CSV output directly to a file. ```bash # Output results as CSV dns-bench --format csv # Example CSV output: # name,ip,last_resolved_ip,total_requests,successful_requests,successful_requests_percentage,min_duration_value_ms,min_duration_error,max_duration_value_ms,max_duration_error,avg_duration_value_ms,avg_duration_error # Cloudflare,1.1.1.1,142.250.75.14,50,50,100.0,9.483524,,14.509014,,11.680231, # Google,8.8.8.8,142.250.120.113,50,50,100.0,22.330315,,39.044084,,27.958232, # Save CSV to file for import into spreadsheet software dns-bench --format csv > dns-benchmark-results.csv ``` -------------------------------- ### Run IPv4 Benchmark with Short Timeout Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Performs an IPv4 benchmark with a short timeout duration. This is a common quick run command for testing basic IPv4 DNS resolution performance. ```bash cargo run -- --name-servers-ip v4 --lookup-ip v4 --timeout 1 ``` -------------------------------- ### Format Code with Cargo Source: https://github.com/qwerty541/dns-bench/blob/master/CONTRIBUTING.md Applies standard Rust code formatting to the project using `cargo fmt`. This ensures consistent code style across the codebase. ```bash cargo fmt ``` -------------------------------- ### Pull dns-bench Docker Image Source: https://github.com/qwerty541/dns-bench/blob/master/docker/OVERVIEW.md This command downloads the latest version of the dns-bench Docker image from Docker Hub. This is the first step before you can run any benchmarks. ```sh docker pull qwerty541/dns-bench:latest ``` -------------------------------- ### Customize Human-Readable Table Appearance Source: https://context7.com/qwerty541/dns-bench/llms.txt Allows customization of the visual style for human-readable output tables. Various styles are available, including rounded, markdown, ASCII, and modern, to suit different terminal or documentation needs. ```bash # Default rounded style dns-bench --style rounded # Markdown-compatible output for documentation dns-bench --style markdown # ASCII style for terminal compatibility dns-bench --style ascii # Modern style with box-drawing characters dns-bench --style modern # Other available styles: empty, blank, psql, sharp, modern-rounded, # extended, dots, re-structured-text, ascii-rounded dns-bench --style re-structured-text dns-bench --style psql dns-bench --style dots ``` -------------------------------- ### Update Persistent Configuration Values Source: https://context7.com/qwerty541/dns-bench/llms.txt Modifies specific configuration values stored in the persistent configuration file. This allows users to easily adjust settings like the target domain, number of requests, timeout, protocol, and output style. ```bash # Set specific configuration options dns-bench config set --domain cloudflare.com --requests 100 # Set multiple options at once dns-bench config set --threads 32 --timeout 2 --protocol tcp --style markdown # Set output format dns-bench config set --format json # Enable skip options dns-bench config set --skip-system-servers --skip-gateway-detection # Verify changes dns-bench config list ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.