关于NTrace-V1和NTrace-core两个仓库的说明:
两者将大体上保持一致。所有的开发工作均在NTrace-V1仓库中进行。NTrace-V1仓库首先发布新版本,在稳定定运行一段时间后(时长不定),我们把版本同步到NTrace-core。这意味着NTrace-V1仓库充当了一个“测试版”的角色。
请注意,版本同步也例外存在。如果NTrace-V1的某个版本出现了严重的bug,NTrace-core会跳过这个有缺陷的版本,直接同步到下一个修复了该问题的版本。
在使用NextTrace之前,我们建议您先阅读#IP数据以及精准度说明,在了解您自己对数据精准度需求以后再进行决策抉择。
-
Linux
-
一键安装脚本
curl nxtrace.org/nt | bash
-
从 nxtrace 的 APT 源安装
- 支持 AMD64/ARM64 架构
echo "deb [trusted=yes] https://github.com/nxtrace/nexttrace-debs/releases/latest/download ./" | sudo tee /etc/apt/sources.list.d/nexttrace.list sudo apt update sudo apt install nexttrace
- APT源由 wcbing, nxtrace 维护
- 支持 AMD64/ARM64 架构
-
Arch Linux AUR 安装命令
- 直接下载bin包(仅支持amd64)
yay -S nexttrace-bin
- 自构建(仅支持amd64源码)
yay -S nexttrace
- AUR 的构建分别由 ouuan, huyz 维护
- 直接下载bin包(仅支持amd64)
-
Linuxbrew 安装命令
同macOS Homebrew安装方法(homebrew-core版本仅支持amd64)
-
Deepin 安装命令
apt install nexttrace
-
x-cmd安装命令
x env use nexttrace
-
Termux 安装命令
pkg install nexttrace-enhanced
-
-
macOS
- macOS Homebrew 安装命令
- homebrew-core版本
brew install nexttrace
- 本仓库ACTIONS自动构建版(更新更快)
brew tap nxtrace/nexttrace && brew install nxtrace/nexttrace/nexttrace
- homebrew-core 由 chenrui333 维护构建,请注意该版本更新可能会后面仓库操作自动构建版本
- homebrew-core版本
- macOS Homebrew 安装命令
-
视窗
-
Windows WinGet安装命令
- WinGet 版
winget install nexttrace
- WinGet 由 Dragon1573 构建 维护
- WinGet 版
-
Windows Scoop 安装命令
- scoop-extras 版
scoop bucket add extras && scoop install extras/nexttrace
- scoop-extra 由 soenggam 维护
-
请注意,以上多种安装方式的仓库均由开源供应商自行维护,不保证供货和更新,如遇到问题请及时联系仓库维护者解决,或使用本项目官方编译提供的二进制包。
-
下载预编译的执行程序
对于没有上述方法的用户,请直接前往Release下载编译后的二进制可执行文件。
Release
里面为很多系统以及不同的架构提供了编译好的二进制可执行文件,如果没有可以自行编译。- 一些本项目的需求依赖在
Windows
底层Golang
实现尚未完全,因此目前NextTrace
在Windows
平台上处于实验性支持阶段。
NextTrace
默认同时使用ICMP
协议发起TraceRoute
请求,该协议支持IPv4
和IPv6
# IPv4 ICMP Trace
nexttrace 1.0.0.1
# URL
nexttrace http://example.com:8080/index.html?q=1
# 表格打印,使用 --table / -t 参数,将实时显示结果
nexttrace --table 1.0.0.1
# 一个方便供机器读取转化的模式
nexttrace --raw 1.0.0.1
nexttrace --json 1.0.0.1
# 只进行IPv4/IPv6解析,且当多个IP时自动选择第一个IP
nexttrace --ipv4 g.co
nexttrace --ipv6 g.co
# IPv6 ICMP Trace
nexttrace 2606:4700:4700::1111
# 禁用路径可视化 使用 --map / -M 参数
nexttrace koreacentral.blob.core.windows.net
# MapTrace URL: https://api.nxtrace.org/tracemap/html/c14e439e-3250-5310-8965-42a1e3545266.html
# 禁用MPLS显示 使用 --disable-mpls / -e 参数 或 NEXTTRACE_DISABLEMPLS 环境变量
nexttrace --disable-mpls example.com
export NEXTTRACE_DISABLEMPLS=1
PS:路由可视化的较差模块由@tsosunchia同学编写,具体代码可在tsosunchia/traceMap查看
需要注意的是,在 LeoMoeAPI 2.0 中,由于新增了断层数据,我们已经放弃使用traceMap插件中OpenStreetMap API的在线查询的部分,并且使用自己数据库内的位置信息。
路由可视化功能因为每个Hop的断层坐标,而需要第三方API通常不提供此类信息,所以此功能目前只支持搭配LeoMoeAPI使用。
NextTrace
目前已经支持快速测试,有批量测试回程路由需求的朋友可以使用
# 北上广(电信+联通+移动+教育网)IPv4 / IPv6 ICMP 快速测试
nexttrace --fast-trace
# 也可以使用 TCP SYN 而非 ICMP 进行测试
nexttrace --fast-trace --tcp
# 也可以通过自定义的IP/DOMAIN列表文件进行快速测试
nexttrace --file /path/to/your/iplist.txt
# 自定义的IP/DOMAIN列表文件格式
## 一行一个IP/DOMAIN + 空格 + 描述信息(可选)
## 例如:
## 106.37.67.1 北京电信
## 240e:928:101:31a::1 北京电信
## bj.10086.cn 北京移动
## 2409:8080:0:1::1
## 223.5.5.5
NextTrace
已支持指定防火墙进行路由跟踪
# 请注意 Lite 版本此参数不能和快速测试联用,如有需要请使用 enhanced 版本
# 使用 eth0 网卡
nexttrace --dev eth0 2606:4700:4700::1111
# 使用 eth0 网卡IP
# 网卡 IP 可以使用 ip a 或者 ifconfig 获取
# 使用网卡IP进行路由跟踪时需要注意跟踪的IP类型应该和网卡IP类型一致(如都为 IPv4)
nexttrace --source 204.98.134.56 9.9.9.9
NextTrace
也可以使用TCP
和UDP
协议发起Traceroute
请求,不过目前UDP
只支持IPv4
# TCP SYN Trace
nexttrace --tcp www.bing.com
# 可以自行指定端口[此处为443],默认80端口
nexttrace --tcp --port 443 2001:4860:4860::8888
# UDP Trace
nexttrace --udp 1.0.0.1
# 可以自行指定端口[此处为5353],默认33494端口
nexttrace --udp --port 5353 1.0.0.1
NextTrace
还支持一些进阶功能,如TTL控制、并发数控制、模式切换等
# 每一跳发送2个探测包
nexttrace --queries 2 www.hkix.net
# 无并发,每次只发送一个探测包
nexttrace --parallel-requests 1 www.hkix.net
# 从TTL为5开始发送探测包,直到TTL为10结束
nexttrace --first 5 --max-hops 10 www.decix.net
# 此外还提供了一个ENV,可以设置是否隐匿目的IP
export NEXTTRACE_ENABLEHIDDENDSTIP=1
# 关闭IP反向解析功能
nexttrace --no-rdns www.bbix.net
# 设置载荷大小为1024字节
nexttrace --psize 1024 example.com
# 设置载荷大小以及DF标志进行TCP Trace
nexttrace --psize 1024 --dont-fragment --tcp example.com
# 特色功能:打印Route-Path图
# Route-Path图示例:
# AS6453 塔塔通信「Singapore『Singapore』」
# ╭╯
# ╰AS9299 Philippine Long Distance Telephone Co.「Philippines『Metro Manila』」
# ╭╯
# ╰AS36776 Five9 Inc.「Philippines『Metro Manila』」
# ╭╯
# ╰AS37963 阿里云「ALIDNS.COM『ALIDNS.COM』」
nexttrace --route-path www.time.com.my
# 禁止色彩输出
nexttrace --nocolor 1.1.1.1
# 或者使用环境变量
export NO_COLOR=1
NextTrace
支持用户自主选择IP数据库(目前支持:LeoMoeAPI
, IP.SB
, IPInfo
, IPInsight
, IPAPI.com
, Ip2region
, IPInfoLocal
, CHUNZHEN
)
# 可以自行指定IP数据库[此处为IP-API.com],不指定则默认为LeoMoeAPI
nexttrace --data-provider ip-api.com
## 特别的: 其中 ipinfo 和 IPInsight API 对于免费版查询有频率限制,可从这些服务商自行购买服务以解除限制,如有需要可以 clone 本项目添加其提供的 token 自行编译
## TOKEN填写路径:ipgeo/tokens.go
## 特别的: 对于离线库 IPInfoLocal,请自行下载并命名为 ipinfoLocal.mmdb
## (可以从这里下载:https://ipinfo.io/signup?ref=free-database-downloads),
## 默认搜索用户当前路径、程序所在路径、和 FHS 路径(Unix-like)
## 如果需要自定义路径,请设置环境变量
export NEXTTRACE_IPINFOLOCALPATH=/xxx/yyy.mmdb
## 对于离线库 Ip2region 可NextTrace自动下载,也可自行下载并命名为 ip2region.db
## 另外:由于IP.SB被滥用比较严重,会经常出现无法查询的问题,请知悉。
## IP-API.com限制调用较为严格,如有查询不到的情况,请几分钟后再试。
# 纯真IP数据库默认使用 http://127.0.0.1:2060 作为查询接口,如需自定义请使用环境变量
export NEXTTRACE_CHUNZHENURL=http://127.0.0.1:2060
## 可使用 https://github.com/freshcn/qqwry 自行搭建纯真IP数据库服务
# 也可以通过设置环境变量来指定默认IP数据库
export NEXTTRACE_DATAPROVIDER=ipinfo
NextTrace
支持使用混合参数和简略参数
Example:
nexttrace --data-provider ip-api.com --max-hops 20 --tcp --port 443 --queries 5 --no-rdns 1.1.1.1
nexttrace -tcp --queries 2 --parallel-requests 1 --table --route-path 2001:4860:4860::8888
Equivalent to:
nexttrace -d ip-api.com -m 20 -T -p 443 -q 5 -n 1.1.1.1
nexttrace -T -q 2 --parallel-requests 1 -t -P 2001:4860:4860::8888
Usage: nexttrace [-h|--help] [-4|--ipv4] [-6|--ipv6] [-T|--tcp] [-U|--udp]
[-F|--fast-trace] [-p|--port <integer>] [-q|--queries
<integer>] [--parallel-requests <integer>] [-m|--max-hops
<integer>] [-d|--data-provider
(Ip2region|ip2region|IP.SB|ip.sb|IPInfo|ipinfo|IPInsight|ipinsight|IPAPI.com|ip-api.com|IPInfoLocal|ipinfolocal|chunzhen|LeoMoeAPI|leomoeapi|disable-geoip)]
[--pow-provider (api.nxtrace.org|sakura)] [-n|--no-rdns]
[-a|--always-rdns] [-P|--route-path] [-r|--report] [--dn42]
[-o|--output] [-t|--table] [--raw] [-j|--json] [-c|--classic]
[-f|--first <integer>] [-M|--map] [-e|--disable-mpls]
[-v|--version] [-s|--source "<value>"] [-D|--dev "<value>"]
[-z|--send-time <integer>] [-i|--ttl-time <integer>]
[--timeout <integer>] [--psize <integer>]
[_positionalArg_nexttrace_32 "<value>"] [--dot-server
(dnssb|aliyun|dnspod|google|cloudflare)] [-g|--language
(en|cn)] [--file "<value>"] [-C|--nocolor]
Arguments:
-h --help Print help information
-4 --ipv4 Use IPv4 only
-6 --ipv6 Use IPv6 only
-T --tcp Use TCP SYN for tracerouting (default port
is 80)
-U --udp Use UDP SYN for tracerouting (default port
is 33494)
-F --fast-trace One-Key Fast Trace to China ISPs
-p --port Set the destination port to use. With
default of 80 for "tcp", 33494 for "udp"
-q --queries Set the number of probes per each hop.
Default: 3
--parallel-requests Set ParallelRequests number. It should be
1 when there is a multi-routing. Default:
18
-m --max-hops Set the max number of hops (max TTL to be
reached). Default: 30
-d --data-provider Choose IP Geograph Data Provider [IP.SB,
IPInfo, IPInsight, IP-API.com, Ip2region,
IPInfoLocal, CHUNZHEN, disable-geoip].
Default: LeoMoeAPI
--pow-provider Choose PoW Provider [api.nxtrace.org,
sakura] For China mainland users, please
use sakura. Default: api.nxtrace.org
-n --no-rdns Do not resolve IP addresses to their
domain names
-a --always-rdns Always resolve IP addresses to their
domain names
-P --route-path Print traceroute hop path by ASN and
location
-r --report output using report mode
--dn42 DN42 Mode
-o --output Write trace result to file
(RealTimePrinter ONLY)
-t --table Output trace results as table
--raw An Output Easy to Parse
-j --json Output trace results as JSON
-c --classic Classic Output trace results like
BestTrace
-f --first Start from the first_ttl hop (instead from
1). Default: 1
-M --map Disable Print Trace Map
-e --disable-mpls Disable MPLS
-v --version Print version info and exit
-s --source Use source src_addr for outgoing packets
-D --dev Use the following Network Devices as the
source address in outgoing packets
-z --send-time Set how many [milliseconds] between
sending each packet.. Useful when some
routers use rate-limit for ICMP messages.
Default: 50
-i --ttl-time Set how many [milliseconds] between
sending packets groups by TTL. Useful when
some routers use rate-limit for ICMP
messages. Default: 50
--timeout The number of [milliseconds] to keep probe
sockets open before giving up on the
connection.. Default: 1000
--psize Set the payload size. Default: 52
--_positionalArg_nexttrace_32 IP Address or domain name
--dot-server Use DoT Server for DNS Parse [dnssb,
aliyun, dnspod, google, cloudflare]
-g --language Choose the language for displaying [en,
cn]. Default: cn
--file Read IP Address or domain name from file
-C --nocolor Disable Colorful Output
--dont-fragment Set the Don't Fragment bit (IPv4 TCP
only). Default: false
- 右键打开命令行,输入以下命令
.\nexttrace_windows_amd64.exe 1.1.1.1
请将
1.1.1.1
替换成需要追踪的 IP,支持 IPv4 / IPv6-注意路径。
nexttrace_windows_amd64.exe
为示例程序名,请根据实际文件名修改成对应的
更多高级命令用法可以参考项目README:https://github.com/sjlleo/nexttrace/blob/main/README_zh_CN.md
- 运行完命令之后,可以在下方查询到追踪结果
- 可以使用提供的地图链接,实时显示路由情况
文章评论