# dns-bench [![Crates.io version][crates-version-badge]][crates-url] [![Crates.io downloads][crates-downloads-badge]][crates-url] ![Rust version][rust-version] ![License][license-badge] [![Workflow Status][workflow-badge]][actions-url] [crates-version-badge]: https://img.shields.io/crates/v/dns-bench.svg [crates-downloads-badge]: https://img.shields.io/crates/d/dns-bench.svg [crates-url]: https://crates.io/crates/dns-bench [license-badge]: https://img.shields.io/crates/l/dns-bench.svg [workflow-badge]: https://github.com/qwerty541/dns-bench/workflows/check/badge.svg [actions-url]: https://github.com/qwerty541/dns-bench/actions [rust-version]: https://img.shields.io/badge/rust-1.74.1%2B-lightgrey.svg?logo=rust
Table of contents - [Description](#description) - [Example](#example) - [Features](#features) - [List of built-in DNS servers](#list-of-built-in-dns-servers) - [Installation](#installation) - [Which method to choose?](#which-method-to-choose) - [From crates.io](#from-cratesio) - [From git repository](#from-git-repository) - [From Docker Hub](#from-docker-hub) - [Options](#options) - [License](#license) - [Contribution](#contribution)
## Description This repository provides DNS benchmarking command line tool written in Rust. It iterates through built-in list of public DNS servers, measures their response time and print table with sorted results in console. It can be used to find the fastest DNS in your location for better internet browsing experience. An example of console output, list of features and list of built-in DNS servers can be found below. ### Example Example ### Features - Built-in list of public DNS servers. - Requests count configuration. By default, 25 requests are made to each DNS server. - Threads count configuration. By default, 8 threads are used. - Timeout configuration. By default, 3 seconds timeout is used. - Domain configuration. By default, google.com domain is used. - Protocol configuration, either TCP or UDP. By default, UDP is used. - Lookup IP version configuration, either IPv4 or IPv6. By default, IPv4 is used. - Configuration of IP version used to establish connection, either IPv4 or IPv6. By default, IPv4 is used. - Table style configuration. By default, rounded style is used. - Ability to save favorite configurations in a file inside user's home directory (`/home/user/.dns-bench/config.toml`) to avoid typing them every time. - Ability to provide custom servers list instead of built-in list. ### List of built-in DNS servers
- Google Public DNS - Cloudflare - Quad9 - ControlD - OpenDNS - CleanBrowsing - AdGuard DNS - Comodo Secure DNS - Level3 - Verisign - DNS.WATCH - Norton ConnectSafe - SafeDNS - NextDNS
## Installation ### Which method to choose? - If you don't have Rust programming language environment installed on your machine, then [installation from Docker Hub](#from-docker-hub) will be the best option for you. - If you have Rust programming language environment installed on your machine, then you can choose between [installation from crates.io](#from-cratesio) or [installation from git repository](#from-git-repository). - Installation from git repository is suitable only when you want to use the development version instead of the stable one or the crates.io service is unavailable. ### From crates.io Run the following command and wait until the crate is compiled: ```sh $ cargo install dns-bench ``` Now you can run compiled binary: ```sh $ dns-bench [OPTIONS] ``` ### From git repository Run the following command and wait until the crate is compiled: ```sh $ cargo install --git https://github.com/qwerty541/dns-bench.git --tag v0.7.1 dns-bench ``` Also you can remove tag option to install the latest development version. Now you can run compiled binary: ```sh $ dns-bench [OPTIONS] ``` ### From Docker Hub Run the following command to pull the image: ```sh $ docker pull qwerty541/dns-bench:0.7.1 ``` Now you can run this tool inside the container: ```sh $ docker run --rm -it --name dns-bench qwerty541/dns-bench:0.7.1 ``` If you want to pass some options, you can do it like this: ```sh $ docker run --rm -it --name dns-bench qwerty541/dns-bench:0.7.1 /bin/bash -c "dns-bench --requests 20 --domain microsoft.com --style re-structured-text" ``` ## Options Below is a list of currently supported options.
Option Description Default value Possible values
--domain Domain to resolve. google.com Any domain
--threads Number of threads to use. 8 Any positive integer
--requests Number of requests to each DNS server. 25 Any positive integer
--timeout Timeout in seconds. 3 Any positive integer
--protocol Protocol to use. udp tcp, udp
--name-servers-ip IP version to use for establishing connection. v4 v4, v6
--lookup-ip IP version to use for lookup. v4 v4, v6
--style Table style to use. rounded empty, blank, ascii, psql, markdown, modern, sharp, rounded, modern-rounded, extended, dots, re-structured-text, ascii-rounded
--save-config Save the configurations to a file in users home directory.
--custom-servers-file Provide a path to a file with custom servers list to use instead of built-in list. An example of file format can be found here for IPv4 and here for IPv6.
## License Licensed under either of - Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or https://www.apache.org/licenses/LICENSE-2.0) - MIT license ([LICENSE-MIT](LICENSE-MIT) or https://opensource.org/licenses/MIT) at your option. ## Contribution Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.