dnskit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dnskit/__init__.py +9 -0
- dnskit/__main__.py +5 -0
- dnskit/cli/__init__.py +1 -0
- dnskit/cli/app.py +955 -0
- dnskit/cli/render.py +1334 -0
- dnskit/core/__init__.py +349 -0
- dnskit/core/adapters.py +521 -0
- dnskit/core/batch.py +211 -0
- dnskit/core/compare.py +168 -0
- dnskit/core/config.py +248 -0
- dnskit/core/connectivity.py +139 -0
- dnskit/core/diagnosis.py +100 -0
- dnskit/core/dnssec.py +767 -0
- dnskit/core/doctor.py +836 -0
- dnskit/core/integrity.py +232 -0
- dnskit/core/local.py +725 -0
- dnskit/core/lookup.py +218 -0
- dnskit/core/mail.py +1346 -0
- dnskit/core/nameservers.py +223 -0
- dnskit/core/outside.py +113 -0
- dnskit/core/propagation.py +277 -0
- dnskit/core/reach.py +255 -0
- dnskit/core/reverse.py +61 -0
- dnskit/core/serialize.py +64 -0
- dnskit/core/trace.py +591 -0
- dnskit/core/watch.py +167 -0
- dnskit/py.typed +0 -0
- dnskit-0.1.0.dist-info/METADATA +362 -0
- dnskit-0.1.0.dist-info/RECORD +32 -0
- dnskit-0.1.0.dist-info/WHEEL +4 -0
- dnskit-0.1.0.dist-info/entry_points.txt +2 -0
- dnskit-0.1.0.dist-info/licenses/LICENSE +21 -0
dnskit/core/watch.py
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"""Look a record up again and again, and notice when the answer changes.
|
|
2
|
+
|
|
3
|
+
`watch()` yields one `WatchSample` per check, sleeping `interval` seconds in between, until
|
|
4
|
+
the caller stops iterating. Only real answers (records, "doesn't exist", "no records") are
|
|
5
|
+
compared: a failed lookup (timeout, SERVFAIL…) is reported but never counts as a change, so
|
|
6
|
+
a flaky network doesn't raise false alarms.
|
|
7
|
+
|
|
8
|
+
Every value of every real answer is remembered. A change whose values were all seen before
|
|
9
|
+
is `rotating`: a CDN or round-robin name handing out addresses from a pool. Only a change
|
|
10
|
+
that brings a value never seen before is `new_change`. `watch_summary` lists everything
|
|
11
|
+
seen.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import time
|
|
15
|
+
from collections.abc import Callable, Iterator, Sequence
|
|
16
|
+
from dataclasses import dataclass
|
|
17
|
+
from datetime import UTC, datetime
|
|
18
|
+
from typing import Any
|
|
19
|
+
|
|
20
|
+
from dnskit.core.compare import answer_key
|
|
21
|
+
from dnskit.core.lookup import LookupResult, LookupStatus, _validate_rtype, lookup
|
|
22
|
+
from dnskit.core.reach import parse_target
|
|
23
|
+
|
|
24
|
+
WATCH_INTERVAL_S = 30.0
|
|
25
|
+
MIN_INTERVAL_S = 1.0
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class WatchSample:
|
|
30
|
+
number: int # 1 for the first check
|
|
31
|
+
at: datetime # when it was checked, UTC
|
|
32
|
+
name: str
|
|
33
|
+
rtype: str
|
|
34
|
+
nameserver: str
|
|
35
|
+
result: LookupResult
|
|
36
|
+
# The last real answer before this one, when this one differs from it.
|
|
37
|
+
previous: LookupResult | None = None
|
|
38
|
+
# On a change: this answer's values that no earlier answer had (lower-case).
|
|
39
|
+
new_values: tuple[str, ...] = ()
|
|
40
|
+
|
|
41
|
+
@property
|
|
42
|
+
def answered(self) -> bool:
|
|
43
|
+
"""A real answer, as opposed to a failed lookup."""
|
|
44
|
+
return answer_key(self.result) is not None
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def changed(self) -> bool:
|
|
48
|
+
"""The answer differs from the last real one, in any way."""
|
|
49
|
+
return self.previous is not None
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def rotating(self) -> bool:
|
|
53
|
+
"""A change between values already seen, as a CDN or round-robin pool does.
|
|
54
|
+
|
|
55
|
+
Only between two answers with records: a name appearing or disappearing is never
|
|
56
|
+
rotation.
|
|
57
|
+
"""
|
|
58
|
+
return (
|
|
59
|
+
self.changed
|
|
60
|
+
and not self.new_values
|
|
61
|
+
and self.result.status is LookupStatus.OK
|
|
62
|
+
and self.previous is not None
|
|
63
|
+
and self.previous.status is LookupStatus.OK
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
@property
|
|
67
|
+
def new_change(self) -> bool:
|
|
68
|
+
"""A change that isn't just rotation: something not seen before."""
|
|
69
|
+
return self.changed and not self.rotating
|
|
70
|
+
|
|
71
|
+
def matches(self, expected: str) -> bool:
|
|
72
|
+
"""Whether one of the answer's records is `expected` (case and final dot ignored)."""
|
|
73
|
+
wanted = expected.strip().rstrip(".").lower()
|
|
74
|
+
return any(r.value.rstrip(".").lower() == wanted for r in self.result.records)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def watch(
|
|
78
|
+
target: str,
|
|
79
|
+
rtype: str = "A",
|
|
80
|
+
nameserver: str | None = None,
|
|
81
|
+
interval: float = WATCH_INTERVAL_S,
|
|
82
|
+
timeout: float = 5.0,
|
|
83
|
+
sleep: Callable[[float], None] = time.sleep,
|
|
84
|
+
now: Callable[[], datetime] = lambda: datetime.now(UTC),
|
|
85
|
+
) -> Iterator[WatchSample]:
|
|
86
|
+
"""Check `target`/`rtype` every `interval` seconds, forever; stop by not iterating.
|
|
87
|
+
|
|
88
|
+
Validates the name, record type and interval before the first lookup (ValueError).
|
|
89
|
+
Each sample's `previous` is set when its answer differs from the last real answer.
|
|
90
|
+
"""
|
|
91
|
+
name = parse_target(target)
|
|
92
|
+
rtype = _validate_rtype(rtype)
|
|
93
|
+
if interval < MIN_INTERVAL_S:
|
|
94
|
+
raise ValueError(f"The interval must be at least {MIN_INTERVAL_S:g} second.")
|
|
95
|
+
return _samples(name, rtype, nameserver, interval, timeout, sleep, now)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def _samples(
|
|
99
|
+
name: str,
|
|
100
|
+
rtype: str,
|
|
101
|
+
nameserver: str | None,
|
|
102
|
+
interval: float,
|
|
103
|
+
timeout: float,
|
|
104
|
+
sleep: Callable[[float], None],
|
|
105
|
+
now: Callable[[], datetime],
|
|
106
|
+
) -> Iterator[WatchSample]:
|
|
107
|
+
last: LookupResult | None = None # the last real answer
|
|
108
|
+
seen: set[str] = set() # every value of every real answer so far
|
|
109
|
+
number = 0
|
|
110
|
+
while True:
|
|
111
|
+
number += 1
|
|
112
|
+
report = lookup(name, [rtype], nameserver=nameserver, timeout=timeout)
|
|
113
|
+
result = report.results[0]
|
|
114
|
+
previous: LookupResult | None = None
|
|
115
|
+
new_values: tuple[str, ...] = ()
|
|
116
|
+
if answer_key(result) is not None:
|
|
117
|
+
values = [_value(r.value) for r in result.records]
|
|
118
|
+
if last is not None and answer_key(result) != answer_key(last):
|
|
119
|
+
previous = last
|
|
120
|
+
new_values = tuple(sorted({v for v in values if v not in seen}))
|
|
121
|
+
seen.update(values)
|
|
122
|
+
last = result
|
|
123
|
+
yield WatchSample(
|
|
124
|
+
number, now(), name, rtype, report.nameserver, result, previous, new_values
|
|
125
|
+
)
|
|
126
|
+
sleep(interval)
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
def _value(value: str) -> str:
|
|
130
|
+
return value.rstrip(".").lower()
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
@dataclass(frozen=True)
|
|
134
|
+
class SeenValue:
|
|
135
|
+
value: str
|
|
136
|
+
times: int # how many checks answered with it
|
|
137
|
+
first: datetime
|
|
138
|
+
last: datetime
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
@dataclass(frozen=True)
|
|
142
|
+
class WatchSummary:
|
|
143
|
+
checks: int
|
|
144
|
+
new_changes: int
|
|
145
|
+
rotations: int
|
|
146
|
+
failures: int # lookups that failed
|
|
147
|
+
values: tuple[SeenValue, ...] # every value seen, in the order first seen
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
def watch_summary(samples: Sequence[WatchSample]) -> WatchSummary:
|
|
151
|
+
"""What a watch saw: counts, and every value with how often and when it was seen."""
|
|
152
|
+
seen: dict[str, list[Any]] = {} # value -> [times, first, last]
|
|
153
|
+
for sample in samples:
|
|
154
|
+
if not sample.answered:
|
|
155
|
+
continue
|
|
156
|
+
# Sorted, so values first seen in the same answer are listed in a stable order.
|
|
157
|
+
for value in sorted({_value(r.value) for r in sample.result.records}):
|
|
158
|
+
entry = seen.setdefault(value, [0, sample.at, sample.at])
|
|
159
|
+
entry[0] += 1
|
|
160
|
+
entry[2] = sample.at
|
|
161
|
+
return WatchSummary(
|
|
162
|
+
checks=len(samples),
|
|
163
|
+
new_changes=sum(s.new_change for s in samples),
|
|
164
|
+
rotations=sum(s.rotating for s in samples),
|
|
165
|
+
failures=sum(not s.answered for s in samples),
|
|
166
|
+
values=tuple(SeenValue(v, times, first, last) for v, (times, first, last) in seen.items()),
|
|
167
|
+
)
|
dnskit/py.typed
ADDED
|
File without changes
|
|
@@ -0,0 +1,362 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: dnskit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A command-line DNS troubleshooting toolkit that explains what it finds.
|
|
5
|
+
Project-URL: Homepage, https://github.com/gladkhumalo/dnskit
|
|
6
|
+
Project-URL: Documentation, https://github.com/gladkhumalo/dnskit/blob/main/docs/USER_GUIDE.md
|
|
7
|
+
Project-URL: Issues, https://github.com/gladkhumalo/dnskit/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/gladkhumalo/dnskit/blob/main/CHANGELOG.md
|
|
9
|
+
Project-URL: Source, https://github.com/gladkhumalo/dnskit
|
|
10
|
+
Author: Glad Khumalo
|
|
11
|
+
License-Expression: MIT
|
|
12
|
+
License-File: LICENSE
|
|
13
|
+
Keywords: cli,dkim,dmarc,dns,dnssec,network,spf,troubleshooting
|
|
14
|
+
Classifier: Development Status :: 4 - Beta
|
|
15
|
+
Classifier: Environment :: Console
|
|
16
|
+
Classifier: Intended Audience :: Information Technology
|
|
17
|
+
Classifier: Intended Audience :: System Administrators
|
|
18
|
+
Classifier: Operating System :: MacOS
|
|
19
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
20
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
21
|
+
Classifier: Programming Language :: Python :: 3
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
24
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
25
|
+
Classifier: Topic :: Internet :: Name Service (DNS)
|
|
26
|
+
Classifier: Topic :: System :: Networking :: Monitoring
|
|
27
|
+
Classifier: Typing :: Typed
|
|
28
|
+
Requires-Python: >=3.11
|
|
29
|
+
Requires-Dist: dnspython[dnssec]>=2.6
|
|
30
|
+
Requires-Dist: rich>=13
|
|
31
|
+
Requires-Dist: typer>=0.12
|
|
32
|
+
Provides-Extra: dev
|
|
33
|
+
Requires-Dist: mypy>=1.11; extra == 'dev'
|
|
34
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
35
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
36
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
|
|
39
|
+
# dnskit
|
|
40
|
+
|
|
41
|
+
**Find out why DNS isn't working, in plain English.**
|
|
42
|
+
|
|
43
|
+
dnskit is a command-line DNS troubleshooting toolkit. It tells you why a name doesn't
|
|
44
|
+
resolve, why a site won't load or email doesn't arrive, and whether the problem is your
|
|
45
|
+
computer, your network or the domain itself. Every result comes with an explanation and a
|
|
46
|
+
suggested fix, not just raw records.
|
|
47
|
+
|
|
48
|
+
- **One-command health check** with a score and a ranked list of fixes (`doctor`)
|
|
49
|
+
- **Lookups, reverse lookups and comparisons** across public resolvers and your own
|
|
50
|
+
- **Email checks**: MX, SPF (with the 10-lookup limit), DMARC and DKIM
|
|
51
|
+
- **Your computer's DNS setup**: dead or "ghost" DNS servers, hosts-file overrides, NXDOMAIN
|
|
52
|
+
hijacking, intercepted DNS, broken IPv6, and the command to flush the cache
|
|
53
|
+
- **The full delegation chain** from the root servers (`trace`) and **DNSSEC** validation
|
|
54
|
+
- **Propagation** checks across 14 resolvers worldwide, and **watch** to see a change go live
|
|
55
|
+
- **For scripts**: `--json` on every command, `batch` for lists of domains, and a config file
|
|
56
|
+
- **VPN- and firewall-aware**: says so when DNS to outside servers is blocked, instead of
|
|
57
|
+
just timing out
|
|
58
|
+
|
|
59
|
+
Works on Windows, macOS and Linux. Built on [dnspython](https://www.dnspython.org/),
|
|
60
|
+
[Typer](https://typer.tiangolo.com/) and [Rich](https://rich.readthedocs.io/).
|
|
61
|
+
|
|
62
|
+
📖 **[The dnskit User Guide](https://github.com/gladkhumalo/dnskit/blob/main/docs/USER_GUIDE.md)** covers every command and option, every
|
|
63
|
+
error message, and step-by-step recipes for common DNS problems.
|
|
64
|
+
|
|
65
|
+
## Contents
|
|
66
|
+
|
|
67
|
+
- [Installation](#installation)
|
|
68
|
+
- [Quick start](#quick-start)
|
|
69
|
+
- [How DNS works, in one trace](#how-dns-works-in-one-trace)
|
|
70
|
+
- [Commands](#commands)
|
|
71
|
+
- [JSON, batch, watch and config](#json-batch-watch-and-config)
|
|
72
|
+
- [Exit codes](#exit-codes)
|
|
73
|
+
- [Contributing](#contributing)
|
|
74
|
+
- [License](#license)
|
|
75
|
+
|
|
76
|
+
## Installation
|
|
77
|
+
|
|
78
|
+
dnskit needs **Python 3.11 or newer** (`python --version` to check).
|
|
79
|
+
|
|
80
|
+
**With pipx (recommended).** [pipx](https://pipx.pypa.io/) installs command-line tools in
|
|
81
|
+
their own environment and puts `dnskit` on your PATH, so it works from any terminal:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pipx install dnskit
|
|
85
|
+
dnskit --help
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
`pipx upgrade dnskit` moves to the newest release. For the latest code on `main` instead,
|
|
89
|
+
use `pipx install git+https://github.com/gladkhumalo/dnskit.git`.
|
|
90
|
+
|
|
91
|
+
**With pip, in a virtual environment:**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
python -m venv .venv
|
|
95
|
+
.venv\Scripts\activate # Windows
|
|
96
|
+
# source .venv/bin/activate # macOS / Linux
|
|
97
|
+
pip install dnskit
|
|
98
|
+
dnskit --help
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The `dnskit` command then works whenever the virtual environment is active. See the
|
|
102
|
+
[changelog](https://github.com/gladkhumalo/dnskit/blob/main/CHANGELOG.md) for what's in
|
|
103
|
+
each release.
|
|
104
|
+
|
|
105
|
+
## Quick start
|
|
106
|
+
|
|
107
|
+
The screenshots below are real runs against the reserved example domains, on a demo
|
|
108
|
+
computer whose DNS servers are 1.1.1.1 and 8.8.8.8
|
|
109
|
+
([scripts/readme_screenshots.py](https://github.com/gladkhumalo/dnskit/blob/main/scripts/readme_screenshots.py) regenerates them).
|
|
110
|
+
|
|
111
|
+
Not sure where a problem is? Start with `doctor`. It checks your computer's DNS setup and
|
|
112
|
+
the domain (records, the connection, email and DNSSEC) at the same time, and ranks what it
|
|
113
|
+
finds:
|
|
114
|
+
|
|
115
|
+

|
|
116
|
+
|
|
117
|
+
It separates problems with **this computer** from problems with **the domain**, and lists
|
|
118
|
+
notes (things worth knowing, with nothing to fix) separately. From there:
|
|
119
|
+
|
|
120
|
+
- `dnskit lookup example.com` to see the records themselves
|
|
121
|
+
- `dnskit reach example.com` when a site won't load: is it DNS or the connection?
|
|
122
|
+
- `dnskit local` when everything is slow or broken on one computer
|
|
123
|
+
- `dnskit <command> --help` for any command's options, examples and exit codes
|
|
124
|
+
|
|
125
|
+
## How DNS works, in one trace
|
|
126
|
+
|
|
127
|
+
Nobody has the whole DNS: it's a tree of servers, each responsible for one level of
|
|
128
|
+
names. To find `example.com`, a resolver (your DNS server, or 8.8.8.8) asks its way down
|
|
129
|
+
the tree. `dnskit trace` does exactly that, one step at a time, and shows each step:
|
|
130
|
+
|
|
131
|
+

|
|
132
|
+
|
|
133
|
+
1. **The root servers** (`.`) don't know `example.com`, but they know who runs `com.`.
|
|
134
|
+
They *refer* the question to the `com.` servers. There are 13 root server names,
|
|
135
|
+
hard-coded into every resolver; that's where every lookup starts.
|
|
136
|
+
2. **The `com.` servers** don't know the address either, but they know which nameservers
|
|
137
|
+
the domain's owner chose at the registrar: here `elliott` and `hera.ns.cloudflare.com`.
|
|
138
|
+
This list is the domain's **delegation**.
|
|
139
|
+
3. **The domain's own nameservers** are *authoritative* for `example.com`: they hold its
|
|
140
|
+
records and give the final answer.
|
|
141
|
+
|
|
142
|
+
A resolver then caches the answer for its **TTL** (time to live, in seconds), so the next
|
|
143
|
+
lookup skips the whole walk. That's also why a changed record takes a while to reach
|
|
144
|
+
everyone: resolvers keep serving the old answer until its TTL runs out.
|
|
145
|
+
|
|
146
|
+
When a domain fails for everyone, the trace shows which level breaks. For example, the
|
|
147
|
+
`com.` servers saying "no such domain" means it isn't registered (or expired). A
|
|
148
|
+
nameserver that doesn't answer means the DNS host is down. A *lame delegation* means the
|
|
149
|
+
registrar points at nameservers that don't serve the domain.
|
|
150
|
+
|
|
151
|
+
## Commands
|
|
152
|
+
|
|
153
|
+
| Command | What it answers |
|
|
154
|
+
|---|---|
|
|
155
|
+
| [`doctor`](#quick-start) | Is everything OK? A score and a ranked list of fixes. |
|
|
156
|
+
| [`lookup`](#lookup) | What records does this name have? |
|
|
157
|
+
| [`reverse`](#reverse) | Whose is this IP address? |
|
|
158
|
+
| [`compare`](#compare) | Do public resolvers and mine give the same answer? |
|
|
159
|
+
| [`email`](#email) | Is the domain's email set up right (MX, SPF, DMARC, DKIM)? |
|
|
160
|
+
| [`local`](#local) | Is this computer's DNS setup healthy? |
|
|
161
|
+
| [`resolvers`](#resolvers) | Which of my DNS servers answer, and how fast? |
|
|
162
|
+
| [`reach`](#reach) | A site won't load: is it DNS or the connection? |
|
|
163
|
+
| [`trace`](#how-dns-works-in-one-trace) | Where in the delegation does a domain break? |
|
|
164
|
+
| [`dnssec`](#dnssec) | Is DNSSEC on, and does it validate? |
|
|
165
|
+
| [`propagation`](#propagation) | Has my change reached resolvers worldwide? |
|
|
166
|
+
| [`batch`](#batch) | Check a whole list of domains. |
|
|
167
|
+
| [`watch`](#watch) | Tell me when the answer changes. |
|
|
168
|
+
| [`config`](#config) | My default settings and resolvers. |
|
|
169
|
+
|
|
170
|
+
### lookup
|
|
171
|
+
|
|
172
|
+
Looks up A, AAAA, MX, CNAME, NS and TXT at once, through the fastest of your DNS servers
|
|
173
|
+
(`--type` for one type, `--server` to ask a specific server):
|
|
174
|
+
|
|
175
|
+

|
|
176
|
+
|
|
177
|
+
When a lookup fails, a panel says why ("Domain doesn't exist", "Query timed out", …) and
|
|
178
|
+
what to try next.
|
|
179
|
+
|
|
180
|
+

|
|
181
|
+
|
|
182
|
+
### reverse
|
|
183
|
+
|
|
184
|
+
Finds the hostname for an IPv4 or IPv6 address (its PTR record), for an unknown address in
|
|
185
|
+
a log or to check a mail server's reverse name:
|
|
186
|
+
|
|
187
|
+

|
|
188
|
+
|
|
189
|
+
### compare
|
|
190
|
+
|
|
191
|
+
Asks Google, Cloudflare, Quad9 and each of your own DNS servers the same question, and
|
|
192
|
+
marks any that disagree. Useful when a site works on one network but not another:
|
|
193
|
+
|
|
194
|
+

|
|
195
|
+
|
|
196
|
+
### email
|
|
197
|
+
|
|
198
|
+
Checks where mail is delivered (MX), who may send it (SPF), what receivers do with forged
|
|
199
|
+
mail (DMARC), and the signing keys (DKIM), each as pass, warn or fail with a fix:
|
|
200
|
+
|
|
201
|
+
<details>
|
|
202
|
+
<summary><code>$ dnskit email example.com</code></summary>
|
|
203
|
+
|
|
204
|
+

|
|
205
|
+
|
|
206
|
+
</details>
|
|
207
|
+
|
|
208
|
+
### local
|
|
209
|
+
|
|
210
|
+
Checks this computer: every network adapter and its DNS servers, servers that are dead,
|
|
211
|
+
slow or "ghosts" (left in the configuration by an old adapter or VPN), hosts-file entries
|
|
212
|
+
that override DNS, NXDOMAIN hijacking, interception by the network, and IPv6. It ends with
|
|
213
|
+
the problems found and the command to flush the DNS cache:
|
|
214
|
+
|
|
215
|
+
<details>
|
|
216
|
+
<summary><code>$ dnskit local</code></summary>
|
|
217
|
+
|
|
218
|
+

|
|
219
|
+
|
|
220
|
+
</details>
|
|
221
|
+
|
|
222
|
+
### resolvers
|
|
223
|
+
|
|
224
|
+
Tests each DNS server this computer uses and marks the one dnskit uses (the fastest). The
|
|
225
|
+
choice is remembered for 5 minutes, so commands don't each wait for a dead server:
|
|
226
|
+
|
|
227
|
+

|
|
228
|
+
|
|
229
|
+
### reach
|
|
230
|
+
|
|
231
|
+
"The website won't load": looks the name up, connects to port 443 (or `--port`) on each
|
|
232
|
+
address, and says whether the problem is DNS, the connection, or neither:
|
|
233
|
+
|
|
234
|
+

|
|
235
|
+
|
|
236
|
+
### dnssec
|
|
237
|
+
|
|
238
|
+
Checks every link of the DNSSEC chain of trust from the root down, verifies the signatures
|
|
239
|
+
itself, and warns when this computer's clock is wrong (which breaks validation):
|
|
240
|
+
|
|
241
|
+
<details>
|
|
242
|
+
<summary><code>$ dnskit dnssec example.com</code></summary>
|
|
243
|
+
|
|
244
|
+

|
|
245
|
+
|
|
246
|
+
</details>
|
|
247
|
+
|
|
248
|
+
### propagation
|
|
249
|
+
|
|
250
|
+
After changing a record: asks 14 public resolvers (global anycast ones, plus ones in fixed
|
|
251
|
+
countries) and shows what share give the same answer. It tells a change still spreading
|
|
252
|
+
apart from a CDN's location-based answers:
|
|
253
|
+
|
|
254
|
+
<details>
|
|
255
|
+
<summary><code>$ dnskit propagation example.com</code></summary>
|
|
256
|
+
|
|
257
|
+

|
|
258
|
+
|
|
259
|
+
</details>
|
|
260
|
+
|
|
261
|
+
## JSON, batch, watch and config
|
|
262
|
+
|
|
263
|
+
### JSON
|
|
264
|
+
|
|
265
|
+
Every command takes `--json` and prints one JSON object instead of the report, with the
|
|
266
|
+
same exit code: `command`, `exit_code`, a short `summary`, the plain-English `diagnosis`,
|
|
267
|
+
and the full `report`. Timings are milliseconds, dates ISO 8601. For example, only the
|
|
268
|
+
summary and diagnosis of a `reach`:
|
|
269
|
+
|
|
270
|
+
```text
|
|
271
|
+
$ dnskit reach example.com --json (summary and diagnosis only)
|
|
272
|
+
{
|
|
273
|
+
"summary": {
|
|
274
|
+
"verdict": "reachable"
|
|
275
|
+
},
|
|
276
|
+
"diagnosis": {
|
|
277
|
+
"title": "Neither: DNS and the connection both work",
|
|
278
|
+
"explanation": "example.com resolved to 4 addresses, and 104.20.23.154 accepted a connection on port 443 in 19 ms.",
|
|
279
|
+
"suggestion": "If the site still doesn't load, the problem is past the connection: the web server, its certificate, or the browser. Try another browser or a private window, and flush the DNS cache (dnskit local shows the command)."
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
```
|
|
283
|
+
|
|
284
|
+
```powershell
|
|
285
|
+
$result = dnskit doctor example.com --quick --json | ConvertFrom-Json
|
|
286
|
+
if ($result.summary.score -lt 90) { "example.com: $($result.diagnosis.title)" }
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### batch
|
|
290
|
+
|
|
291
|
+
Runs `lookup`, `doctor` or `email` on every domain in a text file (one per line, `#`
|
|
292
|
+
comments allowed, `-` for standard input), a few at a time, and ends with a summary. For this `domains.txt`:
|
|
293
|
+
|
|
294
|
+
```text
|
|
295
|
+
# Our domains
|
|
296
|
+
example.com
|
|
297
|
+
example.org
|
|
298
|
+
https://www.example.net/
|
|
299
|
+
does-not-exist.example # a typo
|
|
300
|
+
not a domain
|
|
301
|
+
```
|
|
302
|
+
|
|
303
|
+

|
|
304
|
+
|
|
305
|
+
### watch
|
|
306
|
+
|
|
307
|
+
Re-checks a record every few seconds (30 by default) and beeps when the answer changes.
|
|
308
|
+
`--until` stops as soon as the new value is live. Answers that only rotate between
|
|
309
|
+
addresses already seen (a CDN) say "rotating (CDN)" instead of "CHANGED":
|
|
310
|
+
|
|
311
|
+

|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
dnskit watch example.com --until 203.0.113.80 --interval 60
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### config
|
|
318
|
+
|
|
319
|
+
An optional TOML file sets each command's defaults and can replace the resolvers that
|
|
320
|
+
`compare` and `propagation` ask. The command line always wins. `dnskit config --init`
|
|
321
|
+
creates a commented starter file, and `dnskit config` shows where it is and what it sets:
|
|
322
|
+
|
|
323
|
+
```toml
|
|
324
|
+
[defaults]
|
|
325
|
+
server = "1.1.1.1" # ask this DNS server instead of choosing the fastest
|
|
326
|
+
|
|
327
|
+
[doctor]
|
|
328
|
+
quick = true
|
|
329
|
+
|
|
330
|
+
[compare]
|
|
331
|
+
resolvers = [
|
|
332
|
+
{ name = "Google", address = "8.8.8.8" },
|
|
333
|
+
{ name = "Office DNS", address = "10.0.0.53" },
|
|
334
|
+
]
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
The file is `%APPDATA%\dnskit\config.toml` on Windows and `~/.config/dnskit/config.toml`
|
|
338
|
+
elsewhere; set `DNSKIT_CONFIG` to use another.
|
|
339
|
+
|
|
340
|
+
## Exit codes
|
|
341
|
+
|
|
342
|
+
| Code | Meaning |
|
|
343
|
+
|---|---|
|
|
344
|
+
| `0` | Success: the name exists, the check passed, everything agrees. |
|
|
345
|
+
| `1` | A problem was found: the lookup failed, a check failed, resolvers disagree. |
|
|
346
|
+
| `2` | Invalid input: not a domain, an unknown record type, a broken config file. |
|
|
347
|
+
| `3` | `reach` only: DNS works but the connection doesn't. |
|
|
348
|
+
| `130` | `watch` only: stopped with Ctrl+C. |
|
|
349
|
+
|
|
350
|
+
Each command's `--help` lists its own exit codes, and the guide has
|
|
351
|
+
[the full list](https://github.com/gladkhumalo/dnskit/blob/main/docs/USER_GUIDE.md#10-using-dnskit-in-scripts).
|
|
352
|
+
|
|
353
|
+
## Contributing
|
|
354
|
+
|
|
355
|
+
Bug reports and pull requests are welcome. See [CONTRIBUTING.md](https://github.com/gladkhumalo/dnskit/blob/main/CONTRIBUTING.md) for
|
|
356
|
+
setting up a development environment, the architecture, and how changes are tested.
|
|
357
|
+
|
|
358
|
+
## License
|
|
359
|
+
|
|
360
|
+
dnskit is released under the [MIT License](https://github.com/gladkhumalo/dnskit/blob/main/LICENSE): you may use, change and share it,
|
|
361
|
+
including commercially, as long as the copyright notice comes along. It comes with no
|
|
362
|
+
warranty.
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
dnskit/__init__.py,sha256=UIjQsQpy_cTvMYlTQz8jYjQKNEW91tYFAZ0t6m18ahg,380
|
|
2
|
+
dnskit/__main__.py,sha256=sVY0YdpFOm5qWiS6C9YhLGR8NvY62JY2Y6x0tutSpZA,99
|
|
3
|
+
dnskit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
|
+
dnskit/cli/__init__.py,sha256=PaXmQpz1NvQT-Dxw5SZxvRRCzTM2Kl-xLqpELjxGMcU,84
|
|
5
|
+
dnskit/cli/app.py,sha256=Jr9uVdRx03g8X3f55x2Zqb0u_BdKYGG-IhIyDAO_y1g,33791
|
|
6
|
+
dnskit/cli/render.py,sha256=YM3EAjRy5b3wDgrjrEEhfeuXrY2DBkV1IwW9SHCRLQ4,52424
|
|
7
|
+
dnskit/core/__init__.py,sha256=vgNoTbkS13bj32_7ZO6kbDxAMlzC4Gcn5d49803yF_8,6733
|
|
8
|
+
dnskit/core/adapters.py,sha256=DfzgmZ1q-AWtFgXJ10NItg9nKlSO0BOvnPu1gTvirXc,20180
|
|
9
|
+
dnskit/core/batch.py,sha256=kb3ZKaW9VaKXTkKb9UrPivyO_i3j-a8q8e79niQj5z4,7671
|
|
10
|
+
dnskit/core/compare.py,sha256=m_EL6UwmOuUojNvCSAr5f-i4L0O7sntF8inlghtC2s0,6393
|
|
11
|
+
dnskit/core/config.py,sha256=ZCcsIFgplpI8HHSTq8j-ghPZe32HbFbndC17wl31ztY,10021
|
|
12
|
+
dnskit/core/connectivity.py,sha256=FjSDGMZp2mFq4PDF96jSSeW0GKbxhtKwqlth7kta6HE,4939
|
|
13
|
+
dnskit/core/diagnosis.py,sha256=WRo4nhJhx7PveSaaZ2XL8kNa5xQitSxdFKTt2DrkDHU,4637
|
|
14
|
+
dnskit/core/dnssec.py,sha256=s7Za9MONvD-VCPbumbZ5R7ERQkMWZSjWdhGFEc-ar7Q,30752
|
|
15
|
+
dnskit/core/doctor.py,sha256=Xtrl6lcxqM6TCEH7ywV11RQKhWPpDR-LxPSAGtKv1Qs,35041
|
|
16
|
+
dnskit/core/integrity.py,sha256=YFelCgyJR8t8nOl5Tu3kwhx23NQeiDIHPQybdn-X2Is,8406
|
|
17
|
+
dnskit/core/local.py,sha256=GwzU1knvrNneMfOaEFutiMgfeZdjkh3745e3C4ZsOa4,28195
|
|
18
|
+
dnskit/core/lookup.py,sha256=2-xMxX9DswZdsYIvqOh5w2kbI5vcQegsymwHutirN6g,7557
|
|
19
|
+
dnskit/core/mail.py,sha256=Rw4gY7SnOoR380E_8MV_OQs242wR5bb2agawftftzzE,52548
|
|
20
|
+
dnskit/core/nameservers.py,sha256=bTHYTMeQuxPCi5fKr3F7gAJ8St5AGWzRDCFLhDQWcvg,8533
|
|
21
|
+
dnskit/core/outside.py,sha256=lfwHXlZcqp6TUi4TJudDEAYveKTcri8kifGGzzdLe08,5108
|
|
22
|
+
dnskit/core/propagation.py,sha256=P515OzkFThvn2llkI9APdnxjucovkgUMdhzNqe781qo,12199
|
|
23
|
+
dnskit/core/reach.py,sha256=iOkP-D9pCZ9qGf36ppJqdA9Lov4wko_cpqaRR_njfzQ,10745
|
|
24
|
+
dnskit/core/reverse.py,sha256=YLdPK4ukDe7pEDdQGFzEO8GZRC-ZVLpXNb4n0SMLvf4,2027
|
|
25
|
+
dnskit/core/serialize.py,sha256=-Xm6TNO-_FycesrjdrKmo9oxdTM2Cf4pZQhvGqr66CA,2575
|
|
26
|
+
dnskit/core/trace.py,sha256=jNd600cA76cyRsjw30QJA8ZpW-tgN7jSO_D4t-Ix_kw,25148
|
|
27
|
+
dnskit/core/watch.py,sha256=Isxj60UmYoCibAD023pQ3PW0i5QeqSOesuhc1S0L12A,6042
|
|
28
|
+
dnskit-0.1.0.dist-info/METADATA,sha256=pus2pZWAHvXcVtQA-JxQyNM1fn-7oNhE8fCcejDY7h4,15711
|
|
29
|
+
dnskit-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
30
|
+
dnskit-0.1.0.dist-info/entry_points.txt,sha256=jLR9zHHSa3tev8pnPOcLqUpBkmGeIpceZ6MqSlLlADY,46
|
|
31
|
+
dnskit-0.1.0.dist-info/licenses/LICENSE,sha256=LEBSVqyaJqXcNZwKxLizcpAk0oMiDFc4-Jt8b1ETvfM,1069
|
|
32
|
+
dnskit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Glad Khumalo
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|