a simple DNS-over-HTTPS client
Project description
doh-cli
a simple DNS over HTTPS client
This is a simple DoH python client (RFC 8484, GET), json output by default! In less than 100 lines of code (more or less).
Install
pip3 install doh-cli
Requirements
It's based & tested on Python 3.
If you want to contribute, you can clone the repository and install all dependencies locally:
pip3 install .
Usage
doh-cli libredns.gr A
Help
doh-cli --help
Supported Resource Records
- A
- AAAA
- CNAME
- MX
- NS
- SOA
- SPF
- SRV
- TXT
- CAA
Supported DoH Servers
- https://libredns.gr
- https://dns.google
- https://cloudflare-dns.com
- https://quad9.net
- https://doh.cleanbrowsing.org
- https://www.cira.ca/cybersecurity-services/canadian-shield
- you may also provide your own DoH server URL
DoH Options
- libredns (default)
- libredns-ads (LibreDNS No-Trackers/Ads)
- cloudflare
- quad9
- cleanbrowsing
- cira (CIRA's Canadian Shield)
- cira-protect (Protected adds malware and phishing blocking)
- cira-family (Family blocks malware and phishing plus pornographic content)
Some Examples
IPv4
doh-cli libredns.gr A
[{"Query": "libredns.gr.", "TTL": "366", "RR": "A", "Answer": "116.202.176.26"}]
you can use jq to format, parse output:
doh-cli libredns.gr A | jq .
[
{
"Query": "libredns.gr.",
"TTL": "54",
"RR": "A",
"Answer": "116.202.176.26"
}
]
IPv6
doh-cli libredns.gr AAAA | jq .
[
{
"Query": "libredns.gr.",
"TTL": "207",
"RR": "AAAA",
"Answer": "2a01:4f8:c2c:52bf::1"
}
]
CNAME
doh-cli www.libredns.gr CNAME | jq .
[
{
"Query": "www.libredns.gr.",
"TTL": "600",
"RR": "CNAME",
"Answer": "libredns.gr."
}
]
MX
doh-cli libreops.cc MX | jq .
[
{
"Query": "libreops.cc.",
"TTL": "10794",
"RR": "MX",
"Answer": [
"10",
"spool.mail.gandi.net.",
"libreops.cc.",
"10794",
"IN",
"MX",
"50",
"fb.mail.gandi.net."
]
}
]
CAA
doh-cli libredns.gr CAA
[{"Query": "libredns.gr.", "TTL": "590", "RR": "CAA", "Answer": ["0", "issue", "\"letsencrypt.org\""]}]
Plain Output
doh-cli libredns.gr A --output plain
116.202.176.26
verbose
doh-cli libredns.gr A --output plain --verbose
https://doh.libredns.gr/dns-query?dns=lSIBAAABAAAAAAAACGxpYnJlZG5zAmdyAAABAAE
116.202.176.26
debug
doh-cli test.libredns.gr A --output plain --debug
id 24169
opcode QUERY
rcode NOERROR
flags QR RD RA
;QUESTION
test.libredns.gr. IN A
;ANSWER
test.libredns.gr. 3600 IN A 116.202.176.26
;AUTHORITY
libredns.gr. 1822 IN SOA ns1.gandi.net. hostmaster.gandi.net. 1582812814 10800 3600 604800 10800
;ADDITIONAL
116.202.176.26
Query time
doh-cli test.libredns.gr A --output plain --time
Query time: 531.764
116.202.176.26
doh-cli test.libredns.gr --time
Query time: 540.990
[{"Query": "test.libredns.gr.", "TTL": "3600", "RR": "A", "Answer": ["116.202.176.26"]}]
Disclaimer: This value is relative to python request against DoH service, not the actual dns response.
Choose another DNS server
doh-cli libredns.gr A --output plain --dns cloudflare
116.202.176.26
or you can use LibreDNS Block Trackers endpoint:
doh-cli --output plain --dns libredns-ads analytics.google.com A
0.0.0.0
or provide your own DoH url:
doh-cli --output plain --dns https://doh.libredns.gr/dns-query www.example.com A
93.184.216.34
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file doh-cli-0.2.tar.gz
.
File metadata
- Download URL: doh-cli-0.2.tar.gz
- Upload date:
- Size: 16.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
9e2ca1f2b1e74293ccc78c011b2b65134d2802b911ad3b9bac62e4c970a2a36d
|
|
MD5 |
c19eb6750c7bc5a9107bc3d7bc8cbfdc
|
|
BLAKE2b-256 |
70d67067bf9ac9de013e953fc2a89f10a89d4e5723dd5a5d215cd8f9a7c76fca
|
File details
Details for the file doh_cli-0.2-py3-none-any.whl
.
File metadata
- Download URL: doh_cli-0.2-py3-none-any.whl
- Upload date:
- Size: 16.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
8769e3128fc291698d0f5d5aa163d878d147a32b513e8de55a909175b71e6fea
|
|
MD5 |
40bddb9d526423042e2ad44073501ab2
|
|
BLAKE2b-256 |
a0499470cf7a993877fa77fcbb050b4388398b25578ef02d9e4879b84f816bb8
|