首页·终端命令

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