Adaptive internet connectivity diagnostics. Run one binary when something is wrong and it pinpoints which layer is broken — from the local interface all the way up to the application and captive portals.
Fast when healthy (parallel probes with early-return), thorough when not: on failure it escalates to a dependency-ladder diagnosis and exits with the number of the first failing stage.
From crates.io (once published):
cargo install check_inetFrom a local checkout:
cargo install --path .From git:
cargo install --git https://github.com/geibos/check_inetAll of these install a binary named check-inet.
check-inet [TARGET] [-t <TIMES>] [-d <DELAY>]TARGET— optionalhost[:port]orip[:port]to check at the application layer (defaultya.ru:443). A hostname also exercises the DNS stage; an IP skips per-target DNS.-t, --times— number of phase-1 attempts (default 1).-d, --delay— delay between attempts, in seconds (default 1.0).
Phase 1 runs three probes in parallel — default gateway, public internet
(8.8.8.8), and the application target. If all pass, it prints the results and
exits 0.
If any fail, it escalates into a full diagnosis: local IP, deep DNS (raw UDP to the system resolvers with public fallback), captive-portal detection, and an informational IPv6 check — then prints a verdict naming the root-cause stage.
The exit code is the number of the first broken stage (bottom-up), or 0 when
healthy:
| Code | Stage | Meaning |
|---|---|---|
| 0 | — | everything healthy |
| 1 | local IP | no local address (link/DHCP) |
| 2 | gateway | default gateway unreachable |
| 3 | internet | no route to the public internet (ISP/routing) |
| 4 | DNS | name resolution broken |
| 5 | application | TLS/HTTP to the target fails |
| 6 | captive portal | network requires sign-in |
A Connection refused/reset counts as reachable for the gateway and
internet stages: the host answered, so that layer is up. IPv6 is informational
only and never changes the verdict.
$ check-inet 10.255.255.1:443
172.20.10.1 | 🟢 | 1.0553
8.8.8.8 | 🟢 | 0.0708
10.255.255.1:443 | 🛑 | 0.0754 | Connection refused (os error 61)
--- диагностика ---
10.216.1.4 | 🟢 | 0.0003
dns | 🟢 | 0.4868
captive-portal | 🟢 | 0.3114
ipv6 | 🛑 | 1.0012 | No route to host (informational)
корень: [5] уровень приложения — TLS/HTTP до цели не отвечает
$ echo $?
5
Linux and macOS. Gateway detection uses ip route (Linux) / route -n get default (macOS); resolver discovery uses /etc/resolv.conf (Linux) /
scutil --dns (macOS).
Licensed under either of MIT or Apache-2.0 at your option.