首页·终端命令

traceroute

网络

用法

traceroute -n <host>

逐行列出数据包到目的地途经的路由器;中间出现 `* * *` 不代表链路断了,只是那一跳不愿意回应。

常用选项

选项含义
-nSkip reverse DNS, which makes it much faster.
-m 20Stop after twenty hops instead of the default thirty.
-q 1One probe per hop instead of three.
-w 1Wait one second per probe.
-IUse ICMP echo instead of UDP; needs root.
-T -p 443Use TCP to a real port, which firewalls usually let through (Linux).

示例

traceroute -n 8.8.8.8

The path packets take, without name lookups.

sudo traceroute -T -p 443 example.com

Trace over TCP 443 when UDP probes are blocked (Linux).

连不上的时候,这些能把范围缩小——是名字解析不了、没有路由,还是端口被挡。

怎么看

  • 方括号 [ ] 表示这部分可以不写。
  • 省略号 … 表示可以写多个。
  • 选项区分大小写——有些命令里 -r 和 -R 不是一回事。

常见问题

Q. traceroute 是做什么的?

逐行列出数据包到目的地途经的路由器;中间出现 `* * *` 不代表链路断了,只是那一跳不愿意回应。

Q. 怎么写?

traceroute -n <host> —— 方括号表示可以省略的部分。

Q. 值得记的选项有几个?

这里列了 6 个,完整列表在 man traceroute。这条命令属于网络。

相关命令

man 手册: man traceroute