Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/picatz/doh
🍩 DNS over HTTPS command-line client
https://github.com/picatz/doh
cli-app cloudflare dns-over-https golang google quad9
Last synced: about 9 hours ago
JSON representation
🍩 DNS over HTTPS command-line client
- Host: GitHub
- URL: https://github.com/picatz/doh
- Owner: picatz
- License: mit
- Created: 2018-11-17T15:20:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-08-30T14:46:26.000Z (2 months ago)
- Last Synced: 2024-10-29T19:16:54.754Z (12 days ago)
- Topics: cli-app, cloudflare, dns-over-https, golang, google, quad9
- Language: Go
- Homepage:
- Size: 168 KB
- Stars: 101
- Watchers: 2
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-list - doh - line client | picatz | 73 | (Go)
README
# doh
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/picatz/doh/blob/master/LICENSE)
[![go report](https://goreportcard.com/badge/github.com/picatz/doh)](https://goreportcard.com/report/github.com/picatz/doh)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/picatz/doh/pulls)> 🍩 DNS over HTTPs command-line client
Using [`cloudflare`](https://developers.cloudflare.com/1.1.1.1/dns-over-https/), [`google`](https://developers.google.com/speed/public-dns/docs/dns-over-https), and [`quad9`](https://quad9.net/doh-quad9-dns-servers/) the `doh` command-line utility can concurrently lookup all three sources for one or more given domain(s). You can even specify your own custom source to use.
> [!NOTE]
> Since `doh` outputs everything as JSON, it pairs really well with tools like [`jq`](https://stedolan.github.io/jq/) to parse relevant parts of the output for your purposes.# Install
To get started, you will need [`go`](https://golang.org/doc/install) installed and properly configured.
```shell
$ go install -v github.com/picatz/doh@latest
```# Help Menus
The `--help` command-line flag can show you the top-level help menu.
```console
$ doh --help
doh is a CLI for querying DNS records from DoH serversUsage:
doh [command]Available Commands:
completion Generate the autocompletion script for the specified shell
help Help about any command
query Query DNS records from DoH serversFlags:
-h, --help help for dohUse "doh [command] --help" for more information about a command.
```To get more information for the `query` command:
```console
$ doh query --help
Query DNS records from DoH servers using the given domains and record type.Users can specify which servers to use for the query, or use the default servers from Google, Cloudflare, and Quad9.
They can also specify a timeout for the query, which defaults to 30 seconds if not specified. Each server is queried
in parallel, and each domain is queried in parallel. Results are streamed to STDOUT as JSON newline delimited objects,
which can be piped to other commands (e.g. jq) or redirected to a file.Usage:
doh query domains... [flags]Flags:
-h, --help help for query
-k, --insecure-skip-verify allow insecure server connections (e.g. self-signed TLS certificates)
--resolver-addr string address of a DNS resolver to use for resolving DoH server names (e.g. 8.8.8.8:53)
--resolver-network string protocol to use for resolving DoH server names (e.g. udp, tcp) (default "udp")
--retry-max int maximum number of retries for each query (default 10)
--servers strings servers to query (default [https://dns.google/dns-query,https://cloudflare-dns.com/dns-query,https://dns.quad9.net:5053/dns-query])
--timeout duration timeout for query, 0s for no timeout (default 30s)
--type string dns record type to query for each domain, such as A, AAAA, MX, etc. (default "A")
```# Example Usage
Let's say we're curious about `google.com`'s IPv4 address. We can use `doh` to query three different sources (Google, Cloudflare, and Quad9) for the DNS `A` record type:
```console
$ doh query google.com
{"server":"https://dns.google.com/resolve","resp":{"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,"Question":[{"name":"google.com.","type":1}],"Answer":[{"name":"google.com.","type":1,"TTL":283,"data":"172.217.2.46"}]}}
{"server":"https://cloudflare-dns.com/dns-query","resp":{"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,"Question":[{"name":"google.com","type":1}],"Answer":[{"name":"google.com","type":1,"TTL":129,"data":"142.251.178.101"},{"name":"google.com","type":1,"TTL":129,"data":"142.251.178.138"},{"name":"google.com","type":1,"TTL":129,"data":"142.251.178.113"},{"name":"google.com","type":1,"TTL":129,"data":"142.251.178.102"},{"name":"google.com","type":1,"TTL":129,"data":"142.251.178.100"},{"name":"google.com","type":1,"TTL":129,"data":"142.251.178.139"}]}}
{"server":"https://dns.quad9.net:5053/dns-query","resp":{"Status":0,"TC":false,"RD":true,"RA":true,"AD":false,"CD":false,"Question":[{"name":"google.com.","type":1}],"Answer":[{"name":"google.com.","type":1,"TTL":34,"data":"142.250.191.142"}]}}
```To get just all of the IPs from all of those sources, we could do the following:
```console
$ doh query google.com | jq -r '.resp.Answer[0].data'
172.217.2.46
142.251.178.113
142.250.191.142
```We can also query multiple domains at once:
```console
$ doh query bing.com google.com | jq -r '(.resp.Answer[0].name|rtrimstr(".")) + "\t" + .resp.Answer[0].data' | sort -n
bing.com 13.107.21.200
bing.com 204.79.197.200
bing.com 204.79.197.200
google.com 142.250.191.142
google.com 142.251.178.102
google.com 172.217.0.174
```To get `IPv6` records, we'll need to specify the `--type` flag, like so:
```console
$ doh query google.com --type AAAA
...
```To get `MX` records:
```console
$ doh query google.com --type MX
...
```To get `ANY` records (which is only implemented by Google at the moment):
```console
$ doh query google.com --type ANY --servers=https://dns.google.com/resolve
...
```> [!TIP]
> To use a custom DNS over HTTPs source, specify the URL with the `--servers` flag.