Debian Codegraph @

PKG-INFO

raw
1 Metadata-Version: 2.2
2 Name: doh-cli
3 Version: 0.8
4 Summary: a simple DNS-over-HTTPS client
5 Home-page: https://gitlab.com/libreops/doh-cli
6 Author: LibreOps
7 Author-email: [email protected]
8 License: LICENSE
9 Classifier: Development Status :: 5 - Production/Stable
10 Classifier: Environment :: Console
11 Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
12 Classifier: Operating System :: OS Independent
13 Classifier: Programming Language :: Python :: 3 :: Only
14 Classifier: Topic :: Internet :: Name Service (DNS)
15 Description-Content-Type: text/markdown
16 License-File: LICENSE
17 Requires-Dist: dnspython
18 Requires-Dist: requests
19 Dynamic: author
20 Dynamic: author-email
21 Dynamic: classifier
22 Dynamic: description
23 Dynamic: description-content-type
24 Dynamic: home-page
25 Dynamic: license
26 Dynamic: requires-dist
27 Dynamic: summary
28
29 # doh-cli
30
31 A simple **DNS over HTTPS** client for the command line.
32
33 This is a simple DoH python client (RFC 8484, GET), which supports **plain** (default) and **json** output.
34
35 ## Install
36
37 ```bash
38 pip3 install doh-cli
39 ```
40
41 ### Upgrade
42
43 or upgrade to latest version by
44
45 ```bash
46 pip install --upgrade doh-cli
47 ```
48
49 ## Requirements
50
51 It's based & tested on Python 3.
52
53 If you want to contribute, you can clone the repository and install all dependencies locally:
54
55 ```bash
56 pip3 install .
57 ```
58
59 ## Usage
60
61 ```bash
62 doh-cli libredns.gr A
63 ```
64
65 ## Help
66
67 ```bash
68 doh-cli --help
69 ```
70
71 ## Supported Resource Records
72
73 - A
74 - AAAA
75 - CNAME
76 - HTTPS
77 - MX
78 - NS
79 - SOA
80 - SPF
81 - SRV
82 - SVCB
83 - TXT
84 - CAA
85 - DNSKEY
86 - DS
87
88 ## Supported DoH Providers
89
90 - [LibreDNS](https://libredns.gr)
91 - [Google](https://dns.google)
92 - [Cloudflare](https://cloudflare-dns.com)
93 - [Quad9](https://quad9.net)
94 - [CleanBrowsing](https://doh.cleanbrowsing.org)
95 - [CIRA](https://www.cira.ca/cybersecurity-services/canadian-shield)
96 - [SecureDNS](https://securedns.eu/)
97 - you may also provide your own DoH server URL
98
99 ### DoH Options
100
101 - libredns (**default**)
102 - libredns-ads (LibreDNS No-Trackers/Ads)
103 - google
104 - cloudflare
105 - quad9
106 - cleanbrowsing (blocks access to adult, pornographic and explicit sites, also VPNs)
107 - cleanbrowsing-secure (blocks access to phishing, malware and malicious domains)
108 - cleanbrowsing-adult (blocks access to all adult, pornographic and explicit sites)
109 - cira (CIRA's Canadian Shield)
110 - cira-protect (Malware and phishing protection)
111 - cira-family (blocking pornographic content plus protected)
112 - securedns
113 - securedns-ads (blockign ads, malware and phishing)
114
115 ## Some Examples
116
117 ### IPv4
118
119 ```bash
120 doh-cli libredns.gr A
121 ```
122
123 ```bash
124 116.202.176.26
125 ```
126
127 in json
128
129 ```bash
130 doh-cli libredns.gr A --json
131 ```
132
133 ```json
134 [{"Query": "libredns.gr.", "TTL": "366", "RR": "A", "Answer": "116.202.176.26"}]
135 ```
136
137 you can use [jq](https://stedolan.github.io/jq/) to format, parse output:
138
139 ```bash
140 doh-cli libredns.gr A --json | jq .
141 ```
142
143 ```json
144 [
145 {
146 "Query": "libredns.gr.",
147 "TTL": "54",
148 "RR": "A",
149 "Answer": "116.202.176.26"
150 }
151 ]
152 ```
153
154 ### IPv6
155
156 ```bash
157 doh-cli example.org AAAA
158
159 2606:2800:220:1:248:1893:25c8:1946
160 ```
161
162 ```json
163 doh-cli example.org AAAA --json | jq .
164
165 [
166 {
167 "Query": "example.org.",
168 "TTL": "45832",
169 "RR": "AAAA",
170 "Answer": [
171 "2606:2800:220:1:248:1893:25c8:1946"
172 ]
173 }
174 ]
175
176 ```
177
178 ### CNAME
179
180 ```bash
181 doh-cli www.libredns.gr CNAME --json | jq .
182 ```
183
184 ```json
185 [
186 {
187 "Query": "www.libredns.gr.",
188 "TTL": "600",
189 "RR": "CNAME",
190 "Answer": "libredns.gr."
191 }
192 ]
193 ```
194
195 ### MX
196
197 ```bash
198 doh-cli libreops.cc MX --json | jq .
199 ```
200
201 ```json
202 [
203 {
204 "Query": "libreops.cc.",
205 "TTL": "10794",
206 "RR": "MX",
207 "Answer": [
208 "10",
209 "spool.mail.gandi.net.",
210 "libreops.cc.",
211 "10794",
212 "IN",
213 "MX",
214 "50",
215 "fb.mail.gandi.net."
216 ]
217 }
218 ]
219 ```
220
221 ### CAA
222
223 ```bash
224 doh-cli libredns.gr CAA --json
225 ```
226
227 ```json
228 [{"Query": "libredns.gr.", "TTL": "590", "RR": "CAA", "Answer": ["0", "issue", "\"letsencrypt.org\""]}]
229 ```
230
231 ### DNSKEY
232
233 > DNS Key record The key record used in DNSSEC. Uses the same format as the KEY record.
234
235 ```bash
236 doh-cli DNSKEY nasa.gov
237
238 256 3 8 AwEAAd86yGbz2WUp4VqClb1svSW9oyx0 CQqCCGebNIEEqbXsF5PtCz225RKL3cDr mPHIeSETR6iUvfPSDiKquYearoLFmPjU 0q1AJJmrZIzl9rDgMx/c9OPJxBnhp196 ntJEaGySgXSoaXQEdUpm8lZzhkjftTfC X9mwDY2abxa3Vq3t
239 256 3 8 AwEAAa/Jh5zZ/apbhzIG6CEUT8LL+WNK +HuVLbFf/pxk5Q/Qmng08J1+24B5ObWK +lUNGHN/FYC0TVbbofeHHOLVS88CBmK9 Zu5RWqDicYYKFu8vra+MXEcwLc6E0fTf R9I/OAIWF6GScPHnkq8GoK2qau8gSD96 UsAw6mCsWEqdyqof
240 257 3 8 AwEAAbo7ImTCXl2KuV8NK+0zEvLC+OrN M0/6rT/kKZncFc0CqIIQwZUJtdurpvi3 mUFY0J6Pv394E2gu/OLOe+EcIRatjxSv KITBM+PJTJq0OtwsGtBQyu4uU8hS2SNE g1hEJVGHE5q5LWIAy01TBnibyGOyVJE4 N3M50ezp4E7DqEYG6WkhZQxLDjn0T4ex KPDqIkP+QUB6OwF2CWKtWtpPIpI1i9h9 OgIWUfXb3uLEgcnJlAYYAf9Jw35hPPDo FP+Zi9fJ4mQ0olm8gj4668QZoCJ57MDr 3p3Rntfw5Ca+AQVNwnaqcB7iUWHYPZP0 KLk7V02NloWXpwNHOA8O1TsOYtc=
241
242 ```
243
244 ### DS
245
246 >Delegation signer The record used to identify the DNSSEC signing key of a delegated zone
247
248 ```bash
249 doh-cli nasa.gov DS --output=json | jq .
250
251 [
252 {
253 "Query": "nasa.gov.",
254 "TTL": "3588",
255 "RR": "DS",
256 "Answer": [
257 "41452",
258 "8",
259 "2",
260 "7490b7f47af44d4c0bed3a7a2fefeb50cf55e3209e5a82e30a44f9d4aa9ae688"
261 ]
262 }
263 ]
264 [
265 {
266 "Query": "nasa.gov.",
267 "TTL": "3588",
268 "RR": "DS",
269 "Answer": [
270 "41452",
271 "8",
272 "1",
273 "83bb6c5ac559bbe1e8b17a98465145265a3cafc4"
274 ]
275 }
276 ]
277 ```
278
279 ### DNSSEC
280
281 Using `--dnssec` sets the `EDNS DO` flag. The response will then include the DNSSEC signature for the requested record set.
282
283 ```bash
284 doh-cli A nasa.gov --dnssec
285 52.0.14.116
286 23.22.39.120
287 8 2 600 20210325164559 20210223160609 6816 nasa.gov. HqVx19SOdF4Mx2+UZl7rhecv99zJdj07 86R7sAAXP2poG5QDa9zpYz7WXz/y2UtV HpMk+0gfb2SrxQ1p93+VWs0S2UxnwZQI 8qtwuB6/9780LVLa8ZHEDVZzdO1NAAx1 AfaaQ0FjoxErPipPBi4edvMSYjnvVhY+ 0baRH2i1syk=
288 ```
289
290 ### Plain Output
291
292 ```bash
293 doh-cli libredns.gr A
294 ```
295
296 ```bash
297 116.202.176.26
298 ```
299
300 ### verbose
301
302 ```bash
303 doh-cli libredns.gr A --verbose
304 ```
305
306 ```bash
307 116.202.176.26
308 Verbose: https://doh.libredns.gr/dns-query?dns=lSIBAAABAAAAAAAACGxpYnJlZG5zAmdyAAABAAE
309 ```
310
311 ### debug
312
313 ```bash
314 doh-cli test.libredns.gr A --debug
315 ```
316
317 ```bash
318 116.202.176.26
319 Debug: id 24169
320 opcode QUERY
321 rcode NOERROR
322 flags QR RD RA
323 ;QUESTION
324 test.libredns.gr. IN A
325 ;ANSWER
326 test.libredns.gr. 3600 IN A 116.202.176.26
327 ;AUTHORITY
328 libredns.gr. 1822 IN SOA ns1.gandi.net. hostmaster.gandi.net. 1582812814 10800 3600 604800 10800
329 ;ADDITIONAL
330 ```
331
332 ### Query time
333
334 ```bash
335 doh-cli test.libredns.gr A --time
336 ```
337
338 ```bash
339 116.202.176.26
340 Query time: 531.764
341 ```
342
343 ```bash
344 doh-cli test.libredns.gr --time --json | jq .
345 ```
346
347 ```json
348 [
349 {
350 "Query": "test.libredns.gr.",
351 "TTL": "3600",
352 "RR": "A",
353 "Answer": [
354 "116.202.176.26"
355 ]
356 },
357 {
358 "Query Time": "476.537"
359 }
360 ]
361 ```
362
363 **Disclaimer**: This value is related to the client request towards the DoH provider, not the actual dns response.
364
365 ### Choose another DNS server
366
367 ```bash
368 doh-cli libredns.gr A --dns cloudflare
369 ```
370
371 ```bash
372 116.202.176.26
373 ```
374
375 or you can use LibreDNS Block Trackers endpoint:
376
377 ```bash
378 doh-cli --dns libredns-ads analytics.google.com A
379 ```
380
381 ```bash
382 0.0.0.0
383 ```
384
385 or provide your own DoH url:
386
387 ```bash
388 doh-cli --url https://doh.libredns.gr/dns-query www.example.com A
389 ```
390
391 ```bash
392 93.184.216.34
393 ```
394
395 **Notice**: This option (--url) overrides the --dns option.
396
397
398 # Changelog
399
400 This document tracks all notable changes to doh-cli, introduced on each release.
401
402 ## v0.8 - 2025-01-10
403
404 - Added support for RFC9460
405
406 ## v0.7 - 2022-10-29
407
408 - Argument url is overwriting dns argument with it's default value (fix bug)
409
410 ## v0.6 - 2021-03-25
411
412 - Add support to request DNSSEC signatures
413 - Support handling multiple answer sections in a response
414 - Use itertools to append multiple dns answers
415 - Simplify doh-cli plain/json usage
416 - Enhance code readability
417 - Make doh-cli module more independent
418 - Update README accordingly
419
420 ## v0.5 - 2021-03-05
421
422 - Add support for DNSKEY and DS RRs
423 - Update README with new RR examples
424 - Fix output bug on multiple answers
425
426 ## v0.4 - 2021-03-02
427
428 - Update Documentation Notes
429 - Add custom DoH endpoint --url option
430 - Add version option to doh-cli
431 - Add cleanbrowsing & securedns DoH Endpoints
432 - Verbose option returns the rest DoH request
433 - Show multiple DNS answers when exist
434 - Use base64url for dns request message
435 - DNS response should have "application/dns-message" headers
436 - Using RequestException instead of generic Exception
437 - Split module for readability and modularity
438
439 ## v0.3 - 2020-04-12
440
441 - Swapping positional arguments (domain, RR) if needed
442 - Check Response Status in case of a Server Error
443 - Switched default output to plain
444 - Debug, Verbose & Query Time values are now part of plain/json output
445
446 ## v0.2 - 2020-04-08
447
448 - Support custom DoH endpoints
449 - More verbose debug option
450 - Allow user to use any RR type
451 - Add CIRA provider
452 - New time option for query response time
453 - Expand documentation
454 - New verbose option for displaying DNS wire
455
456 ## v0.1 - 2019-12-24
457
458 - Initial release