a simple DNS-over-HTTPS client
a simple DNS over HTTPS client.
This is a simple DoH python client (RFC 8484, GET), which supports plain (default) and json output.
pip3 install doh-cli
It's based & tested on Python 3.
If you want to contribute, you can clone the repository and install all dependencies locally:
pip3 install .
doh-cli libredns.gr A
doh-cli --help
doh-cli libredns.gr A
116.202.176.26
in json
doh-cli libredns.gr A --output json
[{"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 --output json | jq .
[
{
"Query": "libredns.gr.",
"TTL": "54",
"RR": "A",
"Answer": "116.202.176.26"
}
]
doh-cli libredns.gr AAAA --output json | jq .
[
{
"Query": "libredns.gr.",
"TTL": "207",
"RR": "AAAA",
"Answer": "2a01:4f8:c2c:52bf::1"
}
]
doh-cli www.libredns.gr CNAME --output json | jq .
[
{
"Query": "www.libredns.gr.",
"TTL": "600",
"RR": "CNAME",
"Answer": "libredns.gr."
}
]
doh-cli libreops.cc MX --output json | jq .
[
{
"Query": "libreops.cc.",
"TTL": "10794",
"RR": "MX",
"Answer": [
"10",
"spool.mail.gandi.net.",
"libreops.cc.",
"10794",
"IN",
"MX",
"50",
"fb.mail.gandi.net."
]
}
]
doh-cli libredns.gr CAA --output json
[{"Query": "libredns.gr.", "TTL": "590", "RR": "CAA", "Answer": ["0", "issue", "\"letsencrypt.org\""]}]
doh-cli libredns.gr A --output plain
116.202.176.26
doh-cli libredns.gr A --verbose
116.202.176.26
Verbose: https://doh.libredns.gr/dns-query?dns=lSIBAAABAAAAAAAACGxpYnJlZG5zAmdyAAABAAE
doh-cli test.libredns.gr A --debug
116.202.176.26
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
doh-cli test.libredns.gr A --time
116.202.176.26
Query time: 531.764
doh-cli test.libredns.gr --time --output json | jq .
[
{
"Query": "test.libredns.gr.",
"TTL": "3600",
"RR": "A",
"Answer": [
"116.202.176.26"
]
},
{
"Query Time": "476.537"
}
]
Disclaimer: This value is related to the client request towards the DoH provider, not the actual dns response.
doh-cli libredns.gr A --dns cloudflare
116.202.176.26
or you can use LibreDNS Block Trackers endpoint:
doh-cli --dns libredns-ads analytics.google.com A
0.0.0.0
or provide your own DoH url:
doh-cli --dns https://doh.libredns.gr/dns-query www.example.com A
93.184.216.34