NextTrace¶
Debian系统安装¶
nano nexttrace.sh
chmod +x nexttrace.sh
./nexttrace.sh
脚本内容:
#!/usr/bin/env bash
#
# install-nexttrace-debian.sh
# 在 Debian 12/13 上通过官方 APT 仓库安装 NextTrace
set -euo pipefail
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
PLAIN='\033[0m'
require_root() {
if [[ $EUID -ne 0 ]]; then
echo -e "${RED}本脚本需要 root 权限。${PLAIN}"
echo -e "请使用:${GREEN}sudo -i${PLAIN} 后再执行。"
exit 1
fi
}
detect_debian() {
if [[ -f /etc/os-release ]]; then
. /etc/os-release
if [[ "${ID:-}" == "debian" ]]; then
# VERSION_ID 可能是 "12" / "13" / "trixie" 等,统一视为支持
return 0
fi
fi
return 1
}
add_nexttrace_repo() {
echo -e "${YELLOW}[*] 创建 keyrings 目录...${PLAIN}"
install -d /etc/apt/keyrings
if [[ ! -f /etc/apt/keyrings/nexttrace.gpg ]]; then
echo -e "${YELLOW}[*] 下载 NextTrace 仓库 GPG 密钥...${PLAIN}"
curl -fsSL \
https://github.com/nxtrace/nexttrace-debs/releases/latest/download/nexttrace-archive-keyring.gpg \
| tee /etc/apt/keyrings/nexttrace.gpg >/dev/null
else
echo -e "${YELLOW}[*] 已存在 /etc/apt/keyrings/nexttrace.gpg,跳过下载。${PLAIN}"
fi
if [[ ! -f /etc/apt/sources.list.d/nexttrace.sources ]]; then
echo -e "${YELLOW}[*] 写入 NextTrace APT 源配置...${PLAIN}"
cat << 'EOF' > /etc/apt/sources.list.d/nexttrace.sources
Types: deb
URIs: https://github.com/nxtrace/nexttrace-debs/releases/latest/download/
Suites: ./
Signed-By: /etc/apt/keyrings/nexttrace.gpg
EOF
else
echo -e "${YELLOW}[*] 已存在 /etc/apt/sources.list.d/nexttrace.sources,跳过创建。${PLAIN}"
fi
}
install_nexttrace() {
echo -e "${YELLOW}[*] 更新 APT 索引...${PLAIN}"
apt update
echo -e "${YELLOW}[*] 安装 nexttrace...${PLAIN}"
apt install -y nexttrace
if command -v nexttrace >/dev/null 2>&1; then
echo -e "${GREEN}[✓] NextTrace 安装完成,可直接运行:nexttrace${PLAIN}"
else
echo -e "${RED}[✗] 安装完成后未检测到 nexttrace 命令,请手动排查。${PLAIN}"
exit 1
fi
}
main() {
require_root
if ! detect_debian; then
echo -e "${RED}当前系统不是 Debian(12/13),本脚本仅适用于 Debian。${PLAIN}"
exit 1
fi
if command -v nexttrace >/dev/null 2>&1; then
echo -e "${GREEN}[✓] 已检测到 nexttrace,当前版本:$(nexttrace -v 2>&1 || echo '')${PLAIN}"
echo -e "${YELLOW}如需升级,请手动执行:apt update && apt install --only-upgrade nexttrace${PLAIN}"
exit 0
fi
add_nexttrace_repo
install_nexttrace
}
main "$@"
测试IP¶
ip_list=("219.141.147.210" "202.106.50.1" "221.179.155.161" \
"202.96.209.133" "210.22.97.1" "211.136.112.200" \
"202.96.128.86" "210.21.196.6" "120.196.165.24" \
"118.112.11.12" "119.6.6.6" "211.137.96.205" \
"202.112.14.151"\
"202.101.103.55" "202.101.103.54" \
"218.85.157.99" "202.101.98.55" )
ip_addr=("北京电信" "北京联通" "北京移动" \
"上海电信" "上海联通" "上海移动" \
"广州电信" "广州联通" "广州移动" \
"成都电信" "成都联通" "成都移动" \
"成都教育网"\
"厦门电信1" "厦门电信2" \
"福州电信1" "福州电信2" )
测试¶
# 只探测 1 次、禁用反向解析(更快更干净,适合脚本):
# -n 不做 rDNS,-q 控制每跳探测次数。
nexttrace -n -q 1 202.96.209.133
nexttrace 202.96.209.133 -q 1
# 用 TCP SYN(绕过部分 ICMP 限制,默认端口 80,可配合 -p):
nexttrace -T -p 443 www.baidu.com
# 用 UDP(默认端口 53,常用于对比):
nexttrace -U -p 53 8.8.8.8
# 表格模式
nexttrace --table 1.0.0.1
# 机器可解析输出
nexttrace --raw 1.0.0.1
nexttrace --json 1.0.0.1
# 限制最大/最小跳数
nexttrace -m 10 202.96.209.133 # 最多 10 跳
nexttrace --first 5 -m 15 1.1.1.1 # 从第 5 跳开始,到第 15 跳结束
# 控制并发与速率(网络较差或多路由时用):
nexttrace --parallel-requests 1 1.1.1.1 # 单探针串行,避免多路混乱
nexttrace -n -z 1000 1.1.1.1 # 每个探测包间隔 1000ms
# 指定出口 IP 或网卡(多网卡主机很常用):
nexttrace -n -s 192.168.1.8 1.1.1.1 # 指定源 IP
nexttrace -n -D eth1 1.1.1.1 # 指定出口网卡