
mtr网络诊断
Linux mtr
command provides both functionality of traceroute
and ping
commands. mtr
can provide reports and xml, json, csv output. There is also Gtk interface provided for mtr
.
Linux mtr
命令同时提供了traceroute
和ping
命令的功能。 mtr
可以提供报告以及xml,json,csv输出。 还为mtr
提供了Gtk接口。
交互式Traceroute (Interactive Traceroute)
One of the simple use case for mtr
is providing the remote hostname or IP address we want to traceroute. This will open a new interactive window which shows each intermediate hop. This will also send continuous ICMP packets to get new time and related metrics and show in the screen.
mtr
的简单用例之一就是提供我们要跟踪路由的远程主机名或IP地址。 这将打开一个新的交互式窗口,其中显示每个中间跃点。 这还将发送连续的ICMP数据包以获取新的时间和相关指标并显示在屏幕中。
$ mtr google.com

We can exit from this screen with CTRL+C
我们可以使用CTRL + C从此屏幕退出
显示Gtk界面(Show Gtk Interface)
mtr
command can be used with GUI interface. We will provide –g
in order to start with Gtk interface.
mtr
命令可与GUI界面一起使用。 我们将提供– g
,以便从Gtk界面开始。
$ mtr -g google.com
CSV输出 (CSV Output)
We can create CSV type output. CSV type output will delimit the columns with ,
. We will provide --csv
option with the remote hostname.
我们可以创建CSV类型的输出。 CSV类型的输出将与分隔列,
。 我们将为--csv
选项提供远程主机名。
$ mtr --csv google.com

Xml输出(Xml Output)
Another supported output is xml
. We can generate xml format output for the given remote hostname. We will use --xml
option for this. Xml format is better suited for automated processing.
另一个受支持的输出是xml
。 我们可以为给定的远程主机名生成xml格式的输出。 我们将为此使用--xml
选项。 Xml格式更适合自动处理。
$ mtr --xml google.com

杰森输出(Json Output)
We can also generate Json output. Json format is mainly used by Javascript applications. We can use --json
option to generate JSON output.
我们还可以生成Json输出。 Json格式主要由Javascript应用程序使用。 我们可以使用--json
选项生成JSON输出。
$ mtr --json google.com

设定Ping计数(Set Ping Count)
mtr
command will generate ping packets continuously. We can specify the ping count with –c
and the packet count. In this example we will set ping count to 5 .
mtr
命令将连续生成ping数据包。 我们可以使用– c
和数据包计数来指定ping计数。 在此示例中,我们将ping计数设置为5。
$ mtr -c 5 google.com
从文件读取主机名 (Read Hostnames From File)
We can provide multiple hostnames to ping. In order to provide multiple remote hosts we should put them in to a file line by line. Then we will read this file with -F
option with the file name. In this example we will read remote hosts from file named ping.txt
.
我们可以提供多个主机名来ping。 为了提供多个远程主机,我们应该将它们逐行放入一个文件中。 然后,我们将使用带有-F
选项的文件名来读取该文件。 在此示例中,我们将从名为ping.txt
文件中读取远程主机。
$ mtr -F ping.txt
不解析DNS (Do Not Resolve DNS)
Another standard feature of mtr
is disabling DNS resolving. This will made operations faster because extra DNS resolving will create more traffic and wait time. We can disable DNS resolving with -n
option.
mtr
另一个标准功能是禁用DNS解析。 这将使操作更快,因为额外的DNS解析将创建更多的流量和等待时间。 我们可以使用-n
选项禁用DNS解析。
$ mtr -n google.com
显示AS号 (Show AS Number)
Autonomous systems are cells in internet network each of them connects each other in a mesh way. During ping and traceroute operations send packets are transmitted trough these Autonomous systems. We can all intermediate hosts autonomous numbers with --aslookup
option.
自治系统是Internet网络中的单元,每个单元都以网状方式相互连接。 在ping和traceroute操作期间,通过这些自治系统发送数据包。 我们可以使用--aslookup
选项将所有中间主机的自治编号。
$ mtr --aslookup google.com

翻译自: https://www.poftut.com/linux-mtr-command-tutorial-examples-network-diagnostics/
mtr网络诊断