首頁·終端機命令

mtr

網路

用法

mtr -rwc <count> <host>

把 traceroute 和 ping 合成一張持續更新的表,正是抓時斷時續掉包的工具;中間某跳顯示的掉包通常只是那台路由器在限速回應,只有一直延續到最後一跳的掉包才是真問題。

常用選項

選項含義
-rReport mode: run, print a table and exit. Made for pasting into a ticket.
-c 100How many cycles to run before reporting.
-wWide report so long host names are not cut off.
-nNo reverse DNS.
-T -P 443Probe with TCP to a real port instead of ICMP.
-bShow both the host name and the address.

範例

mtr -rwc 100 8.8.8.8

A hundred cycles summarised, the report to attach to a complaint.

sudo mtr -T -P 443 example.com

Trace with TCP when ICMP is filtered.

連不上的時候,這些能把範圍縮小——是名稱解析不了、沒有路由,還是連接埠被擋。

怎麼看

  • 方括號 [ ] 表示這部分可以不寫。
  • 省略號 … 表示可以寫多個。
  • 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。

常見問題

Q. mtr 是做什麼的?

把 traceroute 和 ping 合成一張持續更新的表,正是抓時斷時續掉包的工具;中間某跳顯示的掉包通常只是那台路由器在限速回應,只有一直延續到最後一跳的掉包才是真問題。

Q. 怎麼寫?

mtr -rwc <count> <host> —— 方括號表示可以省略的部分。

Q. 值得記的選項有幾個?

這裡列了 6 個,完整列表在 man mtr。這條命令屬於網路。

相關命令

man 手冊: man mtr