{"id":18030850,"url":"https://github.com/atc0005/dnsc","last_synced_at":"2025-09-18T00:32:47.562Z","repository":{"id":38206296,"uuid":"245489274","full_name":"atc0005/dnsc","owner":"atc0005","description":"Run a DNS query concurrently against all servers in a list and provide results summary","archived":false,"fork":false,"pushed_at":"2024-12-19T08:54:58.000Z","size":6217,"stargazers_count":8,"open_issues_count":25,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T18:55:26.197Z","etag":null,"topics":["dns","dns-query","go","golang","query","troubleshooting"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atc0005.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-06T18:20:38.000Z","updated_at":"2024-12-05T14:50:15.000Z","dependencies_parsed_at":"2022-09-05T09:41:22.454Z","dependency_job_id":"cabc290b-3a9b-4796-bdca-45bf87397ef4","html_url":"https://github.com/atc0005/dnsc","commit_stats":null,"previous_names":[],"tags_count":69,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fdnsc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fdnsc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fdnsc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fdnsc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atc0005","download_url":"https://codeload.github.com/atc0005/dnsc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233433690,"owners_count":18675603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dns","dns-query","go","golang","query","troubleshooting"],"created_at":"2024-10-30T09:15:20.834Z","updated_at":"2025-09-18T00:32:41.732Z","avatar_url":"https://github.com/atc0005.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- omit in toc --\u003e\n# dnsc\n\nSubmit query against a list of DNS servers and display summary of results\n\n[![Latest Release](https://img.shields.io/github/release/atc0005/dnsc.svg?style=flat-square)](https://github.com/atc0005/dnsc/releases/latest)\n[![Go Reference](https://pkg.go.dev/badge/github.com/atc0005/dnsc.svg)](https://pkg.go.dev/github.com/atc0005/dnsc)\n[![go.mod Go version](https://img.shields.io/github/go-mod/go-version/atc0005/dnsc)](https://github.com/atc0005/dnsc)\n[![Lint and Build](https://github.com/atc0005/dnsc/actions/workflows/lint-and-build.yml/badge.svg)](https://github.com/atc0005/dnsc/actions/workflows/lint-and-build.yml)\n[![Project Analysis](https://github.com/atc0005/dnsc/actions/workflows/project-analysis.yml/badge.svg)](https://github.com/atc0005/dnsc/actions/workflows/project-analysis.yml)\n\n\u003c!-- omit in toc --\u003e\n## Table of Contents\n\n- [Project home](#project-home)\n- [Overview](#overview)\n- [Features](#features)\n  - [Current](#current)\n  - [Planned](#planned)\n- [Changelog](#changelog)\n- [Requirements](#requirements)\n  - [Building source code](#building-source-code)\n  - [Running](#running)\n- [Installation](#installation)\n  - [From source](#from-source)\n  - [Using release binaries](#using-release-binaries)\n- [Configuration](#configuration)\n  - [Precedence](#precedence)\n  - [Query types supported](#query-types-supported)\n  - [Service Location (SRV) Protocol \"shortcuts\"](#service-location-srv-protocol-shortcuts)\n  - [Command-line arguments](#command-line-arguments)\n  - [Configuration file](#configuration-file)\n- [Examples](#examples)\n  - [Our config file](#our-config-file)\n  - [Flags only, no config file](#flags-only-no-config-file)\n  - [Use config file for DNS servers list and query types](#use-config-file-for-dns-servers-list-and-query-types)\n  - [Specify DNS servers list via flags](#specify-dns-servers-list-via-flags)\n  - [Query nameserver record (NS)](#query-nameserver-record-ns)\n  - [Query pointer record (PTR) using IP Address](#query-pointer-record-ptr-using-ip-address)\n  - [Query server record (SRV)](#query-server-record-srv)\n  - [Query server record (SRV) using SRV protocol keyword (aka, \"shortcut\")](#query-server-record-srv-using-srv-protocol-keyword-aka-shortcut)\n  - [Force exit on first DNS error](#force-exit-on-first-dns-error)\n  - [Use single-line summary output format](#use-single-line-summary-output-format)\n- [Inspiration](#inspiration)\n- [References](#references)\n\n## Project home\n\nSee [our GitHub repo][repo-url] for the latest code, to file an issue or\nsubmit improvements for review and potential inclusion into the project.\n\n## Overview\n\nRun a DNS query concurrently against all servers in a list and provide summary\nof results. This is most useful after moving servers between subnets when an\nIP Address change is expected, but where the change may not have propagated\nbetween all DNS servers. The summary output is useful for spotting systems\nlagging behind the others.\n\nCommand-line flags are supported for all options, though for some settings\n(e.g., DNS servers), specifying values via configuration file is easier for\nrepeat use.\n\n## Features\n\n### Current\n\n- A mix of command-line flags and configuration file options may be used for\n  all options\n- Query just one server or as many as are provided\n  - Note: A configuration file is recommended for providing multiple DNS\n    servers\n- Multiple [query types supported](#query-types-supported)\n\n- Multiple [Service Location (SRV) Protocol \"shortcuts\" supported](#service-location-srv-protocol-shortcuts)\n\n- User configurable logging levels\n\n- User configurable logging format\n\n- User configurable results summary output format\n\n- User configurable query timeout\n\n### Planned\n\nSee [our GitHub repo][repo-url] for planned future work.\n\n## Changelog\n\nSee the [`CHANGELOG.md`](CHANGELOG.md) file for the changes associated with\neach release of this application. Changes that have been merged to `master`,\nbut not yet an official release may also be noted in the file under the\n`Unreleased` section. A helpful link to the Git commit history since the last\nofficial release is also provided for further review.\n\n## Requirements\n\nThe following is a loose guideline. Other combinations of Go and operating\nsystems for building and running tools from this repo may work, but have not\nbeen tested.\n\n### Building source code\n\n- Go\n  - see this project's `go.mod` file for *preferred* version\n  - this project tests against [officially supported Go\n    releases][go-supported-releases]\n    - the most recent stable release (aka, \"stable\")\n    - the prior, but still supported release (aka, \"oldstable\")\n- GCC\n  - if building with custom options (as the provided `Makefile` does)\n- `make`\n  - if using the provided `Makefile`\n\n### Running\n\n- Windows 10\n- Ubuntu Linux 18.04+\n- Red Hat Enterprise Linux 7+\n\n## Installation\n\n### From source\n\n1. [Download][go-docs-download] Go\n1. [Install][go-docs-install] Go\n1. Clone the repo\n   1. `cd /tmp`\n   1. `git clone https://github.com/atc0005/dnsc`\n   1. `cd dnsc`\n1. Install dependencies (optional)\n   - for Ubuntu Linux\n     - `sudo apt-get install make gcc`\n   - for CentOS Linux\n     1. `sudo yum install make gcc`\n1. Build\n   - for current operating system\n     - `go build -mod=vendor ./cmd/dnsc/`\n       - *forces build to use bundled dependencies in top-level `vendor`\n         folder*\n   - for all supported platforms (where `make` is installed)\n      - `make all`\n   - for Windows\n      - `make windows`\n   - for Linux\n     - `make linux`\n1. Copy the applicable binary to whatever systems needs to run it\n   - if using `Makefile`: look in `/tmp/dnsc/release_assets/dnsc/`\n   - if using `go build`: look in `/tmp/dnsc/`\n\n**NOTE**: Depending on which `Makefile` recipe you use the generated binary\nmay be compressed and have an `xz` extension. If so, you should decompress the\nbinary first before deploying it (e.g., `xz -d dnsc-linux-amd64.xz`).\n\n### Using release binaries\n\n1. Download the [latest\n   release](https://github.com/atc0005/dnsc/releases/latest) binaries\n1. Decompress binaries\n   - e.g., `xz -d dnsc-linux-amd64.xz`\n1. Deploy\n   - Place `dnsc` in a location of your choice\n     - e.g., `/usr/local/bin/`\n\n**NOTE**:\n\nDEB and RPM packages are provided as an alternative to manually deploying\nbinaries.\n\n## Configuration\n\n### Precedence\n\nThe priority order is:\n\n1. Command line flags (highest priority)\n1. Configuration file\n1. Default settings (lowest priority)\n\nThe intent of this behavior is to provide a *feathered* layering of\nconfiguration settings; if a configuration file provides nearly all settings\nthat you want, specify just the settings that you wish to override via\ncommand-line flags and use the configuration file for the other settings.\n\n### Query types supported\n\nThese are the record types currently supported:\n\n- `CNAME`\n- `A`\n- `AAAA`\n- `MX`\n- `NS`\n- `PTR`\n- `SRV`\n\nOther types will be added as I encounter a need for them, or as requested.\n\n### Service Location (SRV) Protocol \"shortcuts\"\n\nThese are the keywords currently supported along with an example of the query\nstring used for a user-provided query string of `example.com`. Others will be\nadded as I encounter a need for them, or as requested.\n\nThese \"shortcuts\" are entirely optional. For example, you may still specify\nthe `srv` query type and provide the `_ldap._tcp.dc._msdcs.example.com` query\nstring manually to get the same effect.\n\n| User-specified query string | Keyword      | Query string submitted to servers  |\n| --------------------------- | ------------ | ---------------------------------- |\n| `example.com`               | `msdcs`      | `_ldap._tcp.dc._msdcs.example.com` |\n| `example.com`               | `kerberos`   | `_kerberos._tcp.example.com`       |\n| `example.com`               | `xmppsrv`    | `_xmpp-server._tcp.example.com`    |\n| `example.com`               | `xmppclient` | `_xmpp-client._tcp.example.com`    |\n| `example.com`               | `sip`        | `_sip._tcp.example.com`            |\n\n### Command-line arguments\n\n- Flags marked as **`required`** must be set via CLI flag *or* within a\n  TOML-formatted configuration file.\n- Flags *not* marked as required are for settings where a useful default is\n  already defined.\n\n| Flag                      | Required | Default        | Repeat  | Possible                                                       | Description                                                                                                                                                                                                                                                                                                                                                    |\n| ------------------------- | -------- | -------------- | ------- | -------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `h`, `help`               | No       | `false`        | No      | `h`, `help`                                                    | Show Help text along with the list of supported flags.                                                                                                                                                                                                                                                                                                         |\n| `ds`, `dns-server`        | **Yes**  | *empty string* | **Yes** | *one valid IP Address per flag invocation*                     | DNS server to submit query against. This flag may be repeated for each additional DNS server to query.                                                                                                                                                                                                                                                         |\n| `cf`, `config-file`       | **Yes**  | *empty string* | No      | *valid file name characters*                                   | Full path to TOML-formatted configuration file. See [`config.example.toml`](config.example.toml) for a starter template.                                                                                                                                                                                                                                       |\n| `v`, `version`            | No       | `false`        | No      | `v`, `version`                                                 | Whether to display application version and then immediately exit application.                                                                                                                                                                                                                                                                                  |\n| `def`, `dns-errors-fatal` | No       | `false`        | No      | `def`, `dns-errors-fatal`                                      | Whether DNS-related errors should force this application to immediately exit.                                                                                                                                                                                                                                                                                  |\n| `ot`, `omit-timestamp`    | No       | `false`        | No      | `ot`, `omit-timestamp`                                         | Whether the date \u0026 time for when the output is generated is omitted from the results output.                                                                                                                                                                                                                                                                   |\n| `q`, `query`              | **Yes**  | *empty string* | No      | *any valid FQDN string*                                        | Fully-qualified system to lookup from all provided DNS servers.                                                                                                                                                                                                                                                                                                |\n| `sp`, `srv-protocol`      | No       | *empty list*   | **Yes** | [supported keywords](#service-location-srv-protocol-shortcuts) | Service Location (SRV) protocols associated with a given domain name as the query string. For example, `msdcs` can be specified as the SRV record protocol along with `example.com` as the query string to search DNS for `_ldap._tcp.dc._msdcs.example.com`. This flag may be repeated for each additional SRV protocol that you wish to request records for. |\n| `ll`, `log-level`         | No       | `info`         | No      | `fatal`, `error`, `warn`, `info`, `debug`                      | Log message priority filter. Log messages with a lower level are ignored.                                                                                                                                                                                                                                                                                      |\n| `lf`, `log-format`        | No       | `text`         | No      | `cli`, `json`, `logfmt`, `text`, `discard`                     | Use the specified `apex/log` package \"handler\" to output log messages in that handler's format.                                                                                                                                                                                                                                                                |\n| `ro`, `results-output`    | No       | `multi-line`   | No      | `multi-line`, `single-line`                                    | Specifies whether the results summary output is composed of a single comma-separated line of records for a query, or whether the records are returned one per line.                                                                                                                                                                                            |\n| `t`, `type`               | No       | `A`            | **Yes** | [supported types](#query-types-supported)                      | DNS query type to use when submitting a DNS query to each provided server. This flag may be repeated for each additional DNS record type you wish to request.                                                                                                                                                                                                  |\n| `to`, `timeout`           | No       | `10`           | No      | *any positive whole number*                                    | Maximum number of seconds allowed for a DNS query to take before timing out.                                                                                                                                                                                                                                                                                   |\n\n### Configuration file\n\nConfiguration file settings have the lowest priority and are overridden by\nsettings specified in other configuration sources, except for default values.\nSee the [Command-line Arguments](#command-line-arguments) table for more\ninformation, including the available values for the listed configuration\nsettings.\n\n| Flag Name          | Config file Setting Name | Notes                                                                              |\n| ------------------ | ------------------------ | ---------------------------------------------------------------------------------- |\n| `dns-server`       | `dns_servers`            | [Multi-line array](https://github.com/toml-lang/toml#user-content-array)           |\n| `query`            | `query`                  | While supported, having a fixed query in the config file is not a normal use case. |\n| `dns-errors-fatal` | `dns_errors_fatal`       | Opt-in setting. Useful to leave as-is for most use cases.                          |\n| `log-level`        | `log_level`              |                                                                                    |\n| `log-format`       | `log_format`             |                                                                                    |\n| `results-output`   | `results_output`         |                                                                                    |\n| `omit-timestamp`   | `omit_timestamp`         |                                                                                    |\n| `type`             | `dns_request_types`      | [Multi-line array](https://github.com/toml-lang/toml#user-content-array)           |\n| `srv-protocol`     | `dns_srv_protocols`      | [Multi-line array](https://github.com/toml-lang/toml#user-content-array)           |\n| `timeout`          | `timeout`                |                                                                                    |\n\nThe [`config.example.toml`](config.example.toml) file is intended as a\nstarting point for your own `config.toml` configuration file and attempts to\nillustrate working values for the available command-line flags.\n\nOnce reviewed and potentially adjusted, your copy of the `config.toml` file\ncan be placed in one of the following locations to be automatically detected\nand used by this application:\n\n- alongside the `dnsc` (or `dnsc.exe`) binary (as `config.toml`)\n- at `$HOME/.config/dnsc/config.toml` on a UNIX-like system (e.g., Linux\n  distro, Mac)\n- at `C:\\Users\\YOUR_USERNAME\\AppData\\dnsc\\config.toml` on a Windows system\n\nFeel free to place the file wherever you like and refer to it using the `-cf`\n(short flag name) or `-config-file` (full-length flag name). See the\n[Examples](#examples) and [Command-line arguments](#command-line-arguments)\nsections for usage details.\n\n## Examples\n\n### Our config file\n\nThese examples assume that the referenced `config.example.toml` file has the\nfollowing contents:\n\n```toml\n\ndns_servers = [\n\n    # https://developers.google.com/speed/public-dns\n    \"8.8.8.8\",\n    \"8.8.4.4\",\n\n    # https://www.opendns.com/setupguide/\n    \"208.67.222.222\",\n    \"208.67.220.220\",\n\n    # https://blog.cloudflare.com/announcing-1111/\n    \"1.1.1.1\",\n]\n\ndns_query_types = [\n    \"A\",\n    \"AAAA\",\n    \"MX\",\n    \"NS\",\n    \"CNAME\",\n]\n\nresults_output = \"multi-line\"\n```\n\nSee the [Configuration file](#configuration-file) section for additional\ninformation, including supported locations for this file.\n\n### Flags only, no config file\n\nHere the `dnsc` application attempted to load a config file using the\nlocations mentioned in the [Configuration file](#configuration-file) section,\nbut one was not found:\n\n```ShellSession\n$ dnsc -ds 8.8.8.8 -ds 8.8.4.4 -ds 208.67.220.220 -ds 208.67.222.222 -q www.yahoo.com\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer            RTT     Query            Query Type    Answer                          Answer Type    TTL\n---               ---     ---              ---           ---                             ---            ---\n208.67.220.220    20ms    www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          21\n208.67.220.220    20ms    www.yahoo.com    A             74.6.143.25                     A              33\n208.67.220.220    20ms    www.yahoo.com    A             74.6.143.26                     A              33\n208.67.220.220    20ms    www.yahoo.com    A             74.6.231.20                     A              33\n208.67.220.220    20ms    www.yahoo.com    A             74.6.231.21                     A              33\n208.67.222.222    20ms    www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          54\n208.67.222.222    20ms    www.yahoo.com    A             74.6.143.25                     A              29\n208.67.222.222    20ms    www.yahoo.com    A             74.6.143.26                     A              29\n208.67.222.222    20ms    www.yahoo.com    A             74.6.231.20                     A              29\n208.67.222.222    20ms    www.yahoo.com    A             74.6.231.21                     A              29\n8.8.4.4           7ms     www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          36\n8.8.4.4           7ms     www.yahoo.com    A             74.6.143.25                     A              45\n8.8.4.4           7ms     www.yahoo.com    A             74.6.143.26                     A              45\n8.8.4.4           7ms     www.yahoo.com    A             74.6.231.20                     A              45\n8.8.4.4           7ms     www.yahoo.com    A             74.6.231.21                     A              45\n8.8.8.8           8ms     www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          25\n8.8.8.8           8ms     www.yahoo.com    A             74.6.143.25                     A              22\n8.8.8.8           8ms     www.yahoo.com    A             74.6.143.26                     A              22\n8.8.8.8           8ms     www.yahoo.com    A             74.6.231.20                     A              22\n8.8.8.8           8ms     www.yahoo.com    A             74.6.231.21                     A              22\n```\n\nSince we did not specify a record query type, only `A` records were requested\nin the query to each DNS server. Since we have recursion enabled and the\n`dnsc` application does not exclude them, the initial `CNAME` record found by\neach query is also listed in the `Answers` section above for each DNS server\nthat had it.\n\n### Use config file for DNS servers list and query types\n\nAs can be seen below, this example produces quite a bit of output.\n\n```ShellSession\n$ dnsc --config-file ./config.example.toml -q www.yahoo.com\n  INFO[0000] User-specified config file provided, will attempt to load it\n  INFO[0000] Trying to load config file \"./config.example.toml\"\n  INFO[0000] Config file successfully loaded config_file=./config.example.toml\n\n\nServer            RTT     Query            Type     Answers                         TTL\n---               ---     ---              ---      ---                             ---\n1.1.1.1           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    8\n1.1.1.1           7ms     www.yahoo.com    A        74.6.143.25                     8\n1.1.1.1           7ms     www.yahoo.com    A        74.6.143.26                     8\n1.1.1.1           7ms     www.yahoo.com    A        74.6.231.20                     8\n1.1.1.1           7ms     www.yahoo.com    A        74.6.231.21                     8\n1.1.1.1           51ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    60\n1.1.1.1           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    12\n1.1.1.1           7ms     www.yahoo.com    AAAA     2001:4998:124:1507::f000        12\n1.1.1.1           7ms     www.yahoo.com    AAAA     2001:4998:124:1507::f001        12\n1.1.1.1           7ms     www.yahoo.com    AAAA     2001:4998:44:3507::8000         12\n1.1.1.1           7ms     www.yahoo.com    AAAA     2001:4998:44:3507::8001         12\n1.1.1.1           73ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    60\n208.67.220.220    21ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    19\n208.67.220.220    21ms    www.yahoo.com    AAAA     2001:4998:44:3507::8001         16\n208.67.220.220    21ms    www.yahoo.com    AAAA     2001:4998:124:1507::f000        16\n208.67.220.220    21ms    www.yahoo.com    AAAA     2001:4998:124:1507::f001        16\n208.67.220.220    21ms    www.yahoo.com    AAAA     2001:4998:44:3507::8000         16\n208.67.220.220    23ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    42\n208.67.220.220    22ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    20\n208.67.220.220    22ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    19\n208.67.220.220    22ms    www.yahoo.com    A        74.6.143.25                     58\n208.67.220.220    22ms    www.yahoo.com    A        74.6.143.26                     58\n208.67.220.220    22ms    www.yahoo.com    A        74.6.231.20                     58\n208.67.220.220    22ms    www.yahoo.com    A        74.6.231.21                     58\n208.67.222.222    22ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    25\n208.67.222.222    22ms    www.yahoo.com    A        74.6.143.25                     50\n208.67.222.222    22ms    www.yahoo.com    A        74.6.143.26                     50\n208.67.222.222    22ms    www.yahoo.com    A        74.6.231.20                     50\n208.67.222.222    22ms    www.yahoo.com    A        74.6.231.21                     50\n208.67.222.222    21ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    19\n208.67.222.222    21ms    www.yahoo.com    AAAA     2001:4998:44:3507::8001         16\n208.67.222.222    21ms    www.yahoo.com    AAAA     2001:4998:124:1507::f000        16\n208.67.222.222    21ms    www.yahoo.com    AAAA     2001:4998:124:1507::f001        16\n208.67.222.222    21ms    www.yahoo.com    AAAA     2001:4998:44:3507::8000         16\n208.67.222.222    21ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    20\n208.67.222.222    23ms    www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    19\n8.8.4.4           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    34\n8.8.4.4           8ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    52\n8.8.4.4           8ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    34\n8.8.4.4           8ms     www.yahoo.com    AAAA     2001:4998:44:3507::8001         1\n8.8.4.4           8ms     www.yahoo.com    AAAA     2001:4998:124:1507::f000        1\n8.8.4.4           8ms     www.yahoo.com    AAAA     2001:4998:44:3507::8000         1\n8.8.4.4           8ms     www.yahoo.com    AAAA     2001:4998:124:1507::f001        1\n8.8.4.4           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    33\n8.8.4.4           7ms     www.yahoo.com    A        74.6.143.25                     3\n8.8.4.4           7ms     www.yahoo.com    A        74.6.143.26                     3\n8.8.4.4           7ms     www.yahoo.com    A        74.6.231.20                     3\n8.8.4.4           7ms     www.yahoo.com    A        74.6.231.21                     3\n8.8.8.8           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    34\n8.8.8.8           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    27\n8.8.8.8           7ms     www.yahoo.com    AAAA     2001:4998:124:1507::f000        9\n8.8.8.8           7ms     www.yahoo.com    AAAA     2001:4998:124:1507::f001        9\n8.8.8.8           7ms     www.yahoo.com    AAAA     2001:4998:44:3507::8000         9\n8.8.8.8           7ms     www.yahoo.com    AAAA     2001:4998:44:3507::8001         9\n8.8.8.8           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    52\n8.8.8.8           7ms     www.yahoo.com    A        74.6.143.25                     1\n8.8.8.8           7ms     www.yahoo.com    A        74.6.143.26                     1\n8.8.8.8           7ms     www.yahoo.com    A        74.6.231.20                     1\n8.8.8.8           7ms     www.yahoo.com    A        74.6.231.21                     1\n8.8.8.8           7ms     www.yahoo.com    CNAME    new-fp-shed.wg1.b.yahoo.com.    52\n```\n\n### Specify DNS servers list via flags\n\nYou can also specify the DNS servers via CLI flags, though it is a bit more verbose:\n\n```ShellSession\n$ dnsc -ds 8.8.8.8 -ds 8.8.4.4 -ds 208.67.220.220 -ds 208.67.222.222 -q www.yahoo.com\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer            RTT     Query            Query Type    Answer                          Answer Type    TTL\n---               ---     ---              ---           ---                             ---            ---\n208.67.220.220    20ms    www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          43\n208.67.220.220    20ms    www.yahoo.com    A             74.6.143.25                     A              48\n208.67.220.220    20ms    www.yahoo.com    A             74.6.143.26                     A              48\n208.67.220.220    20ms    www.yahoo.com    A             74.6.231.20                     A              48\n208.67.220.220    20ms    www.yahoo.com    A             74.6.231.21                     A              48\n208.67.222.222    20ms    www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          54\n208.67.222.222    20ms    www.yahoo.com    A             74.6.143.24                     A              42\n208.67.222.222    20ms    www.yahoo.com    A             74.6.231.19                     A              42\n8.8.4.4           7ms     www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          44\n8.8.4.4           7ms     www.yahoo.com    A             74.6.143.25                     A              44\n8.8.4.4           7ms     www.yahoo.com    A             74.6.143.26                     A              44\n8.8.4.4           7ms     www.yahoo.com    A             74.6.231.20                     A              44\n8.8.4.4           7ms     www.yahoo.com    A             74.6.231.21                     A              44\n8.8.8.8           7ms     www.yahoo.com    A             new-fp-shed.wg1.b.yahoo.com.    CNAME          44\n8.8.8.8           7ms     www.yahoo.com    A             74.6.143.25                     A              44\n8.8.8.8           7ms     www.yahoo.com    A             74.6.143.26                     A              44\n8.8.8.8           7ms     www.yahoo.com    A             74.6.231.20                     A              44\n8.8.8.8           7ms     www.yahoo.com    A             74.6.231.21                     A              44\n```\n\nNo errors here since `www.yahoo.com` had records for all of the requested\nquery types.\n\n### Query nameserver record (NS)\n\nHere we query the Google Public DNS server 8.8.8.8 for the nameserver (NS)\nrecords for the google.com domain.\n\n```console\n$ dnsc --ds 8.8.8.8 -q google.com -t ns\n\n\nServer     RTT     Query         Type    Answer             Answer Type    TTL\n---        ---     ---           ---     ---                ---            ---\n8.8.8.8    77ms    google.com    NS      ns3.google.com.    NS             21600\n8.8.8.8    77ms    google.com    NS      ns2.google.com.    NS             21600\n8.8.8.8    77ms    google.com    NS      ns4.google.com.    NS             21600\n8.8.8.8    77ms    google.com    NS      ns1.google.com.    NS             21600\n\nQuery Performed: 2022-06-01T06:30:32-05:00\n```\n\n### Query pointer record (PTR) using IP Address\n\nNot shown is the initial query for `www.yahoo.com` which resolved to multiple\n`A` records. I picked one of the IP Addresses from the list and used it in the\nexample below.\n\n```ShellSession\n\n$ dnsc --ds 8.8.8.8 --q 74.6.143.25 -t ptr\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer     RTT    Query          Query Type    Answer                                             Answer Type    TTL\n---        ---    ---            ---           ---                                                ---            ---\n8.8.8.8    7ms    74.6.143.25    PTR           media-router-fp73.prod.media.vip.bf1.yahoo.com.    PTR            186\n```\n\n### Query server record (SRV)\n\nIn this example, we query for available XMPP servers for `conversations.im`.\n\n```ShellSession\n\n$ dnsc --ds 8.8.8.8 --q \"_xmpp-client._tcp.conversations.im\" -t srv\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer     RTT    Query                                 Query Type    Answer                     Answer Type    TTL\n---        ---    ---                                   ---           ---                        ---            ---\n8.8.8.8    7ms    _xmpp-client._tcp.conversations.im    SRV           xmpp.conversations.im.     SRV            2533\n8.8.8.8    7ms    _xmpp-client._tcp.conversations.im    SRV           xmpps.conversations.im.    SRV            2533\n```\n\n### Query server record (SRV) using SRV protocol keyword (aka, \"shortcut\")\n\nIn this example, we query for available XMPP servers for `conversations.im`\nusing a SRV protocol keyword or \"shortcut\". This makes the query a little less\nverbose to type. You may optionally omit `-t srv` from this example and you\nwill receive the same result; if specifying a SRV protocol keyword, this\napplication assumes that you wish to submit a SRV record query.\n\n```ShellSession\n$ dnsc --ds 8.8.8.8 --q \"conversations.im\" -sp \"xmppclient\" -t srv\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer     RTT    Query                                 Query Type    Answer                     Answer Type    TTL\n---        ---    ---                                   ---           ---                        ---            ---\n8.8.8.8    8ms    _xmpp-client._tcp.conversations.im    SRV           xmpps.conversations.im.    SRV            2837\n8.8.8.8    8ms    _xmpp-client._tcp.conversations.im    SRV           xmpp.conversations.im.     SRV            2837\n```\n\nAs with other record/query types, you may also mix several together. Here we\nspecify the SRV protocol as before, but leave out the explicit `-t srv`\n(relying on implicit inclusion) and also specify that we wish to query for\navailable `A` records.\n\n```ShellSession\n$ dnsc --ds 8.8.8.8 --q \"conversations.im\" -sp \"xmppclient\" -t a\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer     RTT      Query                                 Query Type    Answer                     Answer Type    TTL\n---        ---      ---                                   ---           ---                        ---            ---\n8.8.8.8    27ms     _xmpp-client._tcp.conversations.im    SRV           xmpp.conversations.im.     SRV            3599\n8.8.8.8    27ms     _xmpp-client._tcp.conversations.im    SRV           xmpps.conversations.im.    SRV            3599\n8.8.8.8    231ms    conversations.im                      A             78.47.177.120              A              3599\n```\n\n### Force exit on first DNS error\n\nAs of `v0.3.0`, this application ignores query errors by default in order to\nallow the results to be processed from all servers. This can be useful if you\nhave one DNS server from the group unreachable or providing invalid results.\nIf however you wish to restore the previous behavior you can specify either\nthe `dns-errors-fatal` or `def` flags, or set `dns_errors_fatal = true` in the\n`config.toml` config file. The example below assumes that you've set\n`dns_errors_fatal = true` in the `config.toml` config file.\n\nExample:\n\n```ShellSession\n$ dnsc -config-file ./config.example.toml -q www.penzoil.com\n  INFO[0000] User-specified config file provided, will attempt to load it\n  INFO[0000] Trying to load config file \"./config.example.toml\"\n  INFO[0000] Config file successfully loaded config_file=./config.example.toml\n\n\nServer     RTT     Query              Type    Answers                       TTL\n---        ---     ---                ---     ---                           ---\n8.8.4.4    33ms    www.penzoil.com    A       65.52.64.201 (A)              899\n8.8.4.4    8ms     www.penzoil.com    AAAA    no records found for query\n```\n\nHere the process bailed when the first `AAAA` request failed. This is due to\nthe `dns_errors_fatal = true` config file setting noted earlier.\n\n### Use single-line summary output format\n\nThis is the previous default output format. This format reads well when the\nresult set is small, but may be harder to read when many records are returned\nfor a query type (e.g., large pool of front-end web servers).\n\n```ShellSession\n$ dnsc --ds 8.8.8.8 --q \"conversations.im\" -sp \"xmppclient\" -t a --ro single-line\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer     RTT      Query                                 Type    Answers                                                        TTL\n---        ---      ---                                   ---     ---                                                            ---\n8.8.8.8    8ms      _xmpp-client._tcp.conversations.im    SRV     xmpps.conversations.im. (SRV), xmpp.conversations.im. (SRV)    1545, 1545\n8.8.8.8    944ms    conversations.im                      A       78.47.177.120 (A)                                              3599\n```\n\nHere is an example where this format does not read quite as well:\n\n```ShellSession\n$ dnsc --ds 8.8.8.8 -q www.yahoo.com -t a -t aaaa --ro single-line\n  INFO[0000] User-specified config file not provided\n  INFO[0000] Trying to load config file \"/mnt/t/github/dnsc/config.toml\"\n  WARN[0000] Config file \"/mnt/t/github/dnsc/config.toml\" not found or unable to load\n  INFO[0000] Trying to load config file \"/home/ubuntu/.config/dnsc/config.toml\"\n  WARN[0000] Config file \"/home/ubuntu/.config/dnsc/config.toml\" not found or unable to load\n  WARN[0000] Failed to load config files, relying only on provided flag settings\n\n\nServer     RTT    Query            Type    Answers                                                                                                                                                                   TTL\n---        ---    ---              ---     ---                                                                                                                                                                       ---\n8.8.8.8    8ms    www.yahoo.com    AAAA    new-fp-shed.wg1.b.yahoo.com. (CNAME), 2001:4998:44:3507::8000 (AAAA), 2001:4998:44:3507::8001 (AAAA), 2001:4998:124:1507::f001 (AAAA), 2001:4998:124:1507::f000 (AAAA)    5, 5, 5, 5, 5\n8.8.8.8    7ms    www.yahoo.com    A       new-fp-shed.wg1.b.yahoo.com. (CNAME), 74.6.143.25 (A), 74.6.143.26 (A), 74.6.231.20 (A), 74.6.231.21 (A)                                                                  39, 40, 40, 40, 40\n```\n\n## Inspiration\n\nThis project was inspired by a small script that I used for many years to\nquickly spot outliers with DNS servers after moving virtual servers between\nsubnets. The shell script is usable, but crude. It is provided as-is and can\nbe found here:\n\n[dns_query.sh](contrib/dns_query.sh)\n\nThis project also owes its existence to the `miekg/dns` package and the Black\nHat Go authors whose example code got me started. See the\n[References](#references) section for links to both resources. Many thanks to the\nauthors of both!\n\n## References\n\n- Golang basics\n  - \u003chttps://golang.org/pkg/sort/#Slice\u003e\n  - \u003chttps://golang.org/pkg/flag/#example_\u003e\n  - \u003chttps://stackoverflow.com/questions/24886015/how-to-convert-uint32-to-string\u003e\n  - \u003chttps://www.geeksforgeeks.org/nested-structure-in-golang/\u003e\n\n- TOML config file-related\n  - \u003chttps://github.com/toml-lang/toml#user-content-array\u003e\n  - \u003chttps://github.com/pelletier/go-toml\u003e\n\n- DNS library\n  - \u003chttps://github.com/miekg/dns\u003e\n  - \u003chttps://miek.nl/2014/august/16/go-dns-package/\u003e\n  - \u003chttps://nostarch.com/blackhatgo\u003e\n    - \u003chttps://github.com/blackhat-go/bhg/blob/master/ch-5/get_all_a/main.go\u003e\n\n- Free DNS servers for testing purposes\n  - \u003chttps://developers.google.com/speed/public-dns\u003e\n  - \u003chttps://www.opendns.com/setupguide/\u003e\n  - \u003chttps://blog.cloudflare.com/announcing-1111/\u003e\n\n- Definitions\n  - \u003chttps://www.cloudflare.com/learning/cdn/glossary/round-trip-time-rtt/\u003e\n\n\u003c!-- Footnotes here  --\u003e\n\n[repo-url]: \u003chttps://github.com/atc0005/dnsc\u003e  \"This project's GitHub repo\"\n\n[go-docs-download]: \u003chttps://golang.org/dl\u003e  \"Download Go\"\n\n[go-docs-install]: \u003chttps://golang.org/doc/install\u003e  \"Install Go\"\n\n[go-supported-releases]: \u003chttps://go.dev/doc/devel/release#policy\u003e \"Go Release Policy\"\n\n\u003c!-- []: PLACEHOLDER \"DESCRIPTION_HERE\" --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatc0005%2Fdnsc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatc0005%2Fdnsc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatc0005%2Fdnsc/lists"}