一般对Linux系统的VPS进行路由跟踪是直接安装并使用traceroute命令,但是这个命令并不支持IP归属地显示以及中文显示,不是很方便。如本文标题所示,直接使用IPIP.net的路由跟踪工具BestTrace来对VPS进行路由跟踪,该工具支持IP归属地显示,支持中文显示,看起来更加简单直观。这里补充一句:路由跟踪有两种,一是IMCP,二是TCP;常说的路由跟踪指的就是IMCP。
下载BestTrace:
使用下面命令从IPIP.net官网下载BestTrace Linux版压缩包
wget https://cdn.ipip.net/17mon/besttrace4linux.zip
安装unzip解压工具:
Centos命令:
yum install -y unzip
Ubuntu / Debian命令:
apt-get install -y unzip
解压BestTrace Linux版压缩包
unzip besttrace4linux.zip

解压之后输入ls命令可以看到BestTrace的Linux二进制文件,根据VPS的系统版本选择对应的二进制文件;站长这台VPS使用的是Centos7 X64位,直接使用besttrace就行了。
besttrace besttrace4linux.txt besttrace32 besttracebsd besttracebsd32 besttracemac besttracearm
输入命令chmod +x besttrace,该命令是赋予BestTrace执行权限,然后输入命令./besttrace -q1 -g cn IP,进行路由跟踪。站长这台VPS是搬瓦工洛杉矶DC6机房的CN2 GIA线路VPS,可以看到从VPS回国全程走59.43.*.*的CN2 GIA节点。

输入命令./besttrace -q1 -g cn -T IP,可进行TCP路由跟踪;补充一句:为什么要对VPS进行TCP路由跟踪呢?有些坑爹商家号称xx优质线路,但是IMCP跟TCP走不同的路由链路,属于欺瞒客户;在下图中可以看到搬瓦工的CN2 GIA是正儿八经的CN2 GIA,TCP路由是全程59.43.*.*回国。

BestTrace命令详细解释:
输入命令./besttrace --help并回车,可以查看BestTrace更多命令参数,所有可添加命令参数如下(附有简单翻译)。

-6, --ipv6
Use ipv6.
使用IPv6
-J, --json
Print traceroute result with JSON format.
以JSON格式打印traceroute结果
-g, --lang string
Language only supported cn and en now.语言现在只支持中文和英文
-m, --maxhop int
Specifies the maximum number of hops (max time-to-live value) traceroute will probe. The default is 30. (default 30)
指定traceroute将探测的最大跃点数(最长生存时间值)。默认值为30。(默认值30)
-a, --noas
Do not try to map IP addresses to AS when displaying them.
显示IP地址时不要尝试将其映射到AS。
-n, --nodomain
Do not try to map IP addresses to host names when displaying them.
显示IP地址时不要尝试将其映射到主机名。
-l, --nolocation
Do not try to map IP addresses to location when displaying them.
显示IP地址时不要尝试将其映射到位置。
-q, --queries int
Sets the number of probe packets per hop. The default is 3. (default 3)
设置每个跃点的探测数据包数。默认值为3。(默认值3)
-z, --sendtime int
Minimal time interval between probes (default 0).
探测之间的最小时间间隔(默认值为0)。
If the value is more than 10, then it specifies a number in milliseconds, else it is a number of seconds (float point values allowed too).
如果该值大于10,则指定毫秒数,否则指定秒数(也允许浮点值)。
Useful when some routers use rate-limit for ICMP messages.
当某些路由器对ICMP消息使用速率限制时非常有用。
-f, --starthop int
Specifies with what TTL to start. Defaults to 1. (default 1)
指定要启动的TTL。默认为1。(默认值1)
--sync
Send icmp package by sync.
通过同步发送icmp包。
-T, --tcp
Use TCP SYN for probes.
使用TCP SYN进行探测。
-V, --version
Print the version and exit.
打印版本并退出。
-w, --waittime int
Set the time (in seconds) to wait for a response to a probe. (default 3)
设置等待探测器响应的时间(秒)。(默认值3)
BestTrace支持全系统客户端(Windows、Linux、安卓、IOS、MAC),其它客户端可自行在IPIP.net官网下载。
BestTrace官网地址:https://www.ipip.net/product/client.html
