首頁·終端機命令

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