Thanks to visit codestin.com
Credit goes to lib.rs

#ping #cli #http-ping #tcp-ping

app pingx

A efficient network diagnostic tool to replace system ping/ping6, supporting multi-target concurrent probing via ICMP, TCP, and HTTP

9 releases

Uses new Rust 2024

new 0.1.10 Jan 15, 2026
0.1.9 Jan 13, 2026
0.1.6 Dec 27, 2025

#111 in Command line utilities

MIT license

81KB
2K SLoC

PingX

🇬🇧 English🇨🇳 中文

PingX is a simple and practical network diagnostic tool designed to replace system ping and ping6 commands. It supports ICMP Ping, TCP Ping (via SYN handshake), and HTTP Ping (via HEAD requests), allowing for comprehensive connectivity testing across IPv4 and IPv6.

Features

  1. Multi-Protocol: ICMP, TCP, and HTTP probing.
  2. Dual Stack: Full support for IPv4, IPv6, and domain resolution.
  3. Concurrency: Probe multiple targets simultaneously.

Installation

Install with Cargo

cargo install pingx

Linux Permissions

On Linux systems, pingx attempts to use unprivileged DGRAM sockets first, which work without root privileges if net.ipv4.ping_group_range covers the user's group.

If that fails, it falls back to RAW sockets, which require CAP_NET_RAW capability. To enable this:

sudo setcap cap_net_raw+ep $(which pingx)

Note: The permissions will be lost if you reinstall or recompile pingx. You'll need to run the command again.

Usage

Basic Usage (ICMP)

# IPv4
pingx 1.1.1.1

# IPv6
pingx 2400:3200::1

# Domain (IPv6 preferred)
pingx example.com

Protocol Modes

Auto-Detection Mode

PingX automatically selects the protocol based on the target format:

  • Starts with http:// or https://: Uses HTTP protocol.
  • Format <host>:<port>: Uses TCP protocol.
  • Others: Defaults to ICMP protocol.
# Auto-detected as HTTP
pingx https://www.google.com

# Auto-detected as TCP (port 80)
pingx 1.1.1.1:80

Forced Mode

Use flags to force specific protocols (target must match required format):

  • -4: Force IPv4 ICMP.
  • -6: Force IPv6 ICMP.
  • -T / --tcp: Force TCP protocol (Target must include port, e.g., ip:port).
  • -H / --http: Force HTTP protocol.
# Force IPv4
pingx -4 example.com

# Force TCP
pingx -T example.com:443

Concurrent Probing

Supports probing multiple targets simultaneously. Results are displayed interleaved unless quiet mode (-q) is enabled.

pingx 1.1.1.1 www.github.com

Common Options

  • -c <COUNT>: Stop after sending count packets.
  • -i <INTERVAL>: Wait interval seconds between sending each packet (default 1.0s).
  • -w <DEADLINE>: Stop running after deadline seconds.
  • -W <TIMEOUT>: Time to wait for a response, in seconds (default 1.0s).
  • -t <TTL>: Set the IP Time to Live (default 64).
  • -s <SIZE>: Size of ICMP payload in bytes (default 56).
  • -q: Quiet output. Only displays summary statistics.

PingX (中文)

🇨🇳 中文🇬🇧 English

PingX 是一款简单实用的网络诊断工具,旨在替代系统的 pingping6 命令。它不仅支持标准的 ICMP Ping,还支持 TCP Ping(发送 SYN 握手报文)和 HTTP Ping(发送 HEAD 请求),可对 IPv4 和 IPv6 目标进行全面的连通性测试。

特性

  1. 多协议支持: 支持 ICMP、TCP 和 HTTP 协议探测。
  2. 双栈支持: 完美支持 IPv4、IPv6 地址及域名解析。
  3. 并发探测: 支持同时对多个目标发起探测。

安装

使用 Cargo 安装

cargo install pingx

Linux 权限设置

在 Linux 系统上,PingX 会优先尝试使用非特权 DGRAM socket。如果系统配置了 net.ipv4.ping_group_range,则无需 root 权限即可运行。

如果 DGRAM 模式不可用,程序会回退到 RAW socket 模式,此时需要 CAP_NET_RAW 权限:

sudo setcap cap_net_raw+ep $(which pingx)

注意:如果重新安装或重新编译 pingx,权限将会丢失,需要重新运行上述命令。

用法

基础用法 (ICMP)

# IPv4
pingx 1.1.1.1

# IPv6
pingx 2400:3200::1

# 域名 (优先使用 IPv6)
pingx example.com

指定协议模式

自动识别模式

PingX 会根据目标格式自动选择协议:

  • http://https:// 开头:使用 HTTP 协议。
  • <host>:<port> 格式:使用 TCP 协议。
  • 其他:默认为 ICMP 协议。
# 自动识别为 HTTP
pingx https://www.google.com

# 自动识别为 TCP (端口 80)
pingx 1.1.1.1:80

强制模式

使用参数强制指定协议(此时参数必须符合特定格式):

  • -4: 强制使用 ICMP 协议检测 IPv4 目标。
  • -6: 强制使用 ICMP 协议检测 IPv6 目标。
  • -T / --tcp: 强制使用 TCP 协议 (目标必须包含端口,如 ip:port)。
  • -H / --http: 强制使用 HTTP 协议。
# 检测 IPv4
pingx -4 example.com

# 强制使用 TCP 协议
pingx -T example.com:443

并发探测

pingx 可以并发对多个目标以不同协议进行检测。结果将交替显示,除非开启安静模式 (-q)。

pingx 1.1.1.1 www.github.com

常用参数

  • -c <COUNT>: 发送数据包的数量。
  • -i <INTERVAL>: 发包间隔(秒),默认 1.0 秒。
  • -w <DEADLINE>: 持续运行的时间限制(秒)。
  • -W <TIMEOUT>: 等待响应的超时时间(秒),默认 1.0 秒。
  • -t <TTL>: 设置 IP 生存时间 (TTL),默认 64。
  • -s <SIZE>: ICMP 数据包大小(默认 56 字节)。
  • -q: 安静模式,不显示逐个包的详细信息,仅显示统计结果。

Dependencies

~8–25MB
~300K SLoC