Skip to main content

Network connectivity checker with DNS, ping, HTTP, and SSL validation. (Published as netcheckx on PyPI to avoid naming conflict with legacy netcheck package)

Project description

Network Connectivity Checker (netcheck)

Version License Platform Python Tests

A premium, cross-platform, production-grade Network Intelligence Engine & CLI written in pure Python 3. Zero external dependencies. High-concurrency diagnostics, structured output (JSON/CSV/XML), watch/loop mode, shell completions, man page, and an integrated Model Context Protocol (MCP) Server for AI assistants.


๐Ÿš€ Key Features

  • Zero-Dependency Core โ€” Built entirely on the Python standard library. No pip install needed to run.
  • Cross-Platform โ€” Native support for Linux, macOS, and Windows with consistent terminal output.
  • 9 Subcommands โ€” Modular tcp, dns, http, ssl, ping, interfaces, traceroute, scan, whois.
  • Watch Mode โ€” Any subcommand loops with --watch and configurable --interval.
  • Structured Output โ€” Every check returns --format text|json|csv|xml.
  • No-Color Mode โ€” --no-color and NO_COLOR env var support for CI/CD pipelines.
  • MCP Server โ€” Turns netcheck into a local tool-server for Claude, ChatGPT, and other AI agents.
  • Lenient Parsing โ€” Accepts CSVs, URLs, bracketed IPv6, IP ranges (192.168.1.1-50), CIDR (10.0.0.0/24), port lists (80,443), port ranges (8000-8100), and ip:port notation.
  • Concurrent Batch Checks โ€” Configurable thread pools (--jobs, default 10) with real-time progress.
  • Environment Variables โ€” NETCHECK_TIMEOUT, NETCHECK_MAX_WORKERS, NO_COLOR for scripting.
  • Shell Completions โ€” Bash and Zsh tab completion for all subcommands and flags.
  • Man Page โ€” Full man netcheck documentation installed by install.sh.

๐Ÿ“ฆ Installation

Option 1: PyPI (recommended โ€” easiest)

pip install netcheckx

Note: Package name is netcheckx (to avoid PyPI conflict). Both commands work:

netcheck --help          # Works
netcheckx --help         # Also works (alias)

Option 2: Snap Store (Linux)

sudo snap install netcheck
sudo snap connect netcheck:network-observe   # enables ping & interfaces

Option 3: Debian package (.deb)

sudo dpkg -i netcheck_2.2.0_amd64.deb

Option 4: Chocolatey (Windows)

choco install netcheck

Option 5: macOS .pkg

sudo installer -pkg netcheck-2.2.0.pkg -target /

Option 6: Linux installer (with shell completions + man page)

git clone https://github.com/farman20ali/network_access_check.git
cd network_access_check
sudo bash packaging/linux/install.sh

Option 7: Developer / local run (no install)

git clone https://github.com/farman20ali/network_access_check.git
cd network_access_check
pip install -e ".[dev]"
python3 -m netcheck --help

๐Ÿ› ๏ธ CLI Reference

Subcommands

Subcommand Description Example
tcp TCP port reachability (ranges, CIDR, IP ranges) netcheck tcp google.com 80,443
dns DNS A/AAAA resolution + CNAME aliases netcheck dns github.com
http HTTP/HTTPS status, size, latency, redirects netcheck http https://google.com
ssl SSL certificate + TLS version/cipher/fingerprint netcheck ssl google.com -V
ping ICMP ping with min/avg/max RTT stats netcheck ping 8.8.8.8 -c 10
interfaces Active network interfaces + public IP netcheck interfaces --all
ports Local listening sockets with process/PID (Docker-aware) netcheck ports -f json
traceroute Hop-by-hop network path trace netcheck traceroute 8.8.8.8 -m 20
scan Concurrent TCP port scanner with service names netcheck scan 192.168.1.1 --ports 1-1024
whois RDAP/WHOIS domain or IP registration lookup netcheck whois google.com

Watch Mode

Any subcommand can be looped with --watch:

netcheck tcp google.com 443 --watch --interval 2    # Refresh every 2s
netcheck http https://api.example.com -w -i 5        # Watch HTTP every 5s
netcheck dns github.com -w                           # Watch DNS (default 2s interval)

Press Ctrl+C to stop.

HTTP Subcommand Options

netcheck http https://api.example.com \
  --method POST \
  -H "Authorization: Bearer token123" \
  -H "Accept: application/json" \
  --auth user:pass
Flag Description
-X, --method HTTP method: GET (default), HEAD, POST, PUT, DELETE, PATCH
-H, --header Custom header Key: Value (repeatable)
--auth Basic auth user:pass

Global Flags

Flag Default Description
-t, --timeout 5 Connection timeout in seconds
-j, --jobs 10 Concurrent thread pool size
-f, --format text Output format: text, json, csv, xml
--retry 1 Number of connection attempts
--retry-delay 1 Delay between retries (seconds)
-V, --verbose โ€” Show extended details (headers, SANs, cipher info)
--no-color โ€” Disable ANSI color output
-w, --watch โ€” Enable watch/loop mode
-i, --interval 2.0 Watch refresh interval in seconds
-v, --version โ€” Print version and exit

Environment Variables

Variable Effect
NETCHECK_TIMEOUT Override default connection timeout (float)
NETCHECK_MAX_WORKERS Override default thread pool size (integer)
NO_COLOR Disable ANSI color output (standard, https://no-color.org/)
NETCHECK_NO_COLOR Alternative for disabling color
NETCHECK_TIMEOUT=10 NETCHECK_MAX_WORKERS=50 netcheck scan 192.168.1.1
NO_COLOR=1 netcheck ssl google.com -f json

Legacy Flags (kept for backward compatibility)

Legacy Equivalent subcommand
-q, --quick <host> <port> netcheck tcp
-d, --dns <host> netcheck dns
-p, --ping <host> netcheck ping
-s, --status <url> netcheck http
--cert <host> netcheck ssl
--my-ip, -ip netcheck interfaces

๐Ÿ” Traceroute & Port Scan

Traceroute

netcheck traceroute google.com             # Full path
netcheck traceroute 8.8.8.8 -m 15        # Limit to 15 hops
netcheck traceroute github.com -f json    # JSON output

Uses raw ICMP sockets if run as root; otherwise falls back to system traceroute/tracepath (Linux/macOS) or tracert (Windows).

Port Scan

netcheck scan 192.168.1.1                  # Scan ~44 common ports
netcheck scan google.com --ports 80,443,8080
netcheck scan 10.0.0.1 --ports 1-1024 --jobs 100

WHOIS / RDAP Lookup

netcheck whois google.com      # Domain registrar + creation date
netcheck whois 8.8.8.8         # IP network block + organization

Uses modern RDAP (HTTP JSON API) first; falls back to classic WHOIS port 43.


๐Ÿค– MCP Server

netcheck ships an integrated Model Context Protocol server that exposes all diagnostic functions to AI assistants.

netcheck --mcp
# or
python3 -m netcheck.mcp.server

Claude Desktop claude_desktop_config.json:

{
  "mcpServers": {
    "netcheck": {
      "command": "python3",
      "args": ["-m", "netcheck.mcp.server"],
      "env": { "PYTHONPATH": "/path/to/network_access_check" }
    }
  }
}

Exposed MCP tools (v2.2.0):

Tool Description
check_tcp_connectivity TCP port reachability
dns_lookup DNS A/AAAA resolution
check_http_status HTTP response check
check_ssl_certificate SSL certificate validation
ping_host ICMP ping
get_network_interfaces List local interfaces
get_public_ip Get public IP
traceroute Trace network path
scan_ports TCP port scanner
whois_lookup Domain/IP registration

๐Ÿ—๏ธ Building Packages

All packaging is orchestrated by build_packages.py. Templates live in packaging/.

packaging/
โ”œโ”€โ”€ chocolatey/        โ† Windows Chocolatey (.nupkg)
โ”‚   โ””โ”€โ”€ tools/
โ”œโ”€โ”€ linux/             โ† install.sh / uninstall.sh / netcheck.1 / completions
โ”œโ”€โ”€ macos/             โ† macOS .pkg scripts
โ”œโ”€โ”€ snap/              โ† snapcraft.yaml template
โ””โ”€โ”€ windows/           โ† NSIS installer script (.nsi)

Common build commands

# Check available tools on this machine
python3 build_packages.py --check

# Sync a new version across all config files
python3 build_packages.py --sync-version 2.2.0

# Build all packages for the current OS
python3 build_packages.py --all

# Individual targets
python3 build_packages.py --pypi      # wheel + sdist
python3 build_packages.py --deb       # Debian .deb
python3 build_packages.py --snap      # Snap .snap
python3 build_packages.py --win       # Windows .exe + NSIS + Chocolatey
python3 build_packages.py --mac       # macOS binary + .pkg

๐Ÿ”ง Shell Completions

Bash

# System-wide (requires root)
sudo cp packaging/linux/netcheck.bash-completion /etc/bash_completion.d/netcheck

# Per-user
mkdir -p ~/.local/share/bash-completion/completions
cp packaging/linux/netcheck.bash-completion ~/.local/share/bash-completion/completions/netcheck

Zsh

mkdir -p ~/.zsh/completions
cp packaging/linux/netcheck.zsh-completion ~/.zsh/completions/_netcheck
# Add to ~/.zshrc:
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
echo 'autoload -U compinit && compinit' >> ~/.zshrc

The installer script (packaging/linux/install.sh) does all of this automatically.


โš™๏ธ CI/CD Integration

All subcommands produce machine-readable structured JSON output when -f json is set. Use this to build health-gate scripts, monitoring alerts, or GitHub Actions checks:

# Check if a TCP port is open โ€” fail the step if not
netcheck tcp prod.example.com 443 -f json | python3 -c \
  "import sys, json; d=json.load(sys.stdin); sys.exit(0 if d['results'][0]['status']=='success' else 1)"

# Extract DNS IPs with jq
netcheck dns api.example.com -f json | jq '.ips[]'

# List open ports as JSON array
netcheck scan 192.168.1.1 --ports 1-1024 -f json | jq '.open_ports[] | {port, service}'

# Get SSL days-until-expiry, alert if < 30
netcheck ssl prod.example.com -f json | jq -e '.days_until_expiry > 30'

# Traceroute hop count for latency monitoring
netcheck traceroute 8.8.8.8 -f json | jq '.hops | length'

# Listening ports as CSV for spreadsheet import
netcheck ports -f csv > listening_ports.csv

# Use NO_COLOR to suppress ANSI in logs
NO_COLOR=1 netcheck tcp prod.example.com 443

# Override timeout and workers for fast CI checks
NETCHECK_TIMEOUT=3 NETCHECK_MAX_WORKERS=50 netcheck scan 10.0.0.1 --ports 80,443,8080 -f json

Exit Codes

Code Meaning
0 All checks succeeded
1 One or more checks failed
2 Argument / usage error

๐Ÿงช Running Tests

# Using Make
make test

# Using pytest directly
PYTHONPATH=. python3 -m pytest tests/ -v

# With coverage
PYTHONPATH=. python3 -m pytest tests/ --cov=netcheck --cov-report=term-missing

๐Ÿ“ Repository Structure

network_access_check/
โ”œโ”€โ”€ netcheck/                  โ† Python package
โ”‚   โ”œโ”€โ”€ __init__.py            โ† version string
โ”‚   โ”œโ”€โ”€ __main__.py            โ† python3 -m netcheck entry point
โ”‚   โ”œโ”€โ”€ cli.py                 โ† CLI argument parsing & dispatch
โ”‚   โ”œโ”€โ”€ mcp/                   โ† MCP server + tool definitions
โ”‚   โ”œโ”€โ”€ modules/               โ† dns, tcp, http, ssl, ping, interfaces,
โ”‚   โ”‚                             traceroute, port_scanner, whois
โ”‚   โ””โ”€โ”€ utils/                 โ† formatters, retry, concurrency, services
โ”œโ”€โ”€ packaging/                 โ† Platform packaging templates
โ”‚   โ”œโ”€โ”€ chocolatey/
โ”‚   โ”œโ”€โ”€ linux/                 โ† install.sh, netcheck.1, bash/zsh completions
โ”‚   โ”œโ”€โ”€ macos/
โ”‚   โ”œโ”€โ”€ snap/
โ”‚   โ””โ”€โ”€ windows/
โ”œโ”€โ”€ tests/                     โ† pytest test suite (60 tests)
โ”œโ”€โ”€ docs/                      โ† Guides and release notes
โ”œโ”€โ”€ .github/workflows/         โ† CI (ci.yml) + Release (release.yml)
โ”œโ”€โ”€ build_packages.py          โ† Build orchestration script
โ”œโ”€โ”€ pyproject.toml             โ† Package metadata & build config
โ”œโ”€โ”€ python-requirements.txt    โ† Local dev setup shortcut
โ””โ”€โ”€ Makefile                   โ† make install / test / clean

๐Ÿ›ก๏ธ License

Distributed under the GNU General Public License v3 (GPL-3.0). See LICENSE for details.

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

netcheckx-2.2.0.tar.gz (55.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netcheckx-2.2.0-py3-none-any.whl (51.3 kB view details)

Uploaded Python 3

File details

Details for the file netcheckx-2.2.0.tar.gz.

File metadata

  • Download URL: netcheckx-2.2.0.tar.gz
  • Upload date:
  • Size: 55.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for netcheckx-2.2.0.tar.gz
Algorithm Hash digest
SHA256 c9c97e4936190a23f27ec425e9ff5be3ebcff43465c59b0b10ac117b1331a3ff
MD5 2b05b185c6c3d40cc45735ae1a11a8a2
BLAKE2b-256 14d1295ab159ad3d68894a3241650b921e8e0deedb3b32085609c201b06b116d

See more details on using hashes here.

File details

Details for the file netcheckx-2.2.0-py3-none-any.whl.

File metadata

  • Download URL: netcheckx-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 51.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for netcheckx-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 357a4870f57dd5d8054ef7dfa91455be7e1eb2f9168cfc6b0fd03f14ae3c856c
MD5 42dc9bc346a924f5c2f244a8033a524a
BLAKE2b-256 7f28b178cbf566d77d140fd6d20432b56f8724fb7da50f60670103b7e1f96491

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page