mtr网络诊断_Linux Mtr命令教程以及网络诊断示例

mtr是Linux中一个结合了traceroute和ping功能的网络诊断工具,提供交互式Traceroute、多种输出格式(如CSV、XML、JSON)、设定Ping计数、从文件读取主机名等特性。它还支持不解析DNS和显示AS号,有助于快速定位网络问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

mtr网络诊断

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命令同时提供了tracerouteping命令的功能。 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
CSV Output
CSV Output
CSV输出

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
Xml Output
Xml Output
Xml输出

杰森输出(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
Json Output
Json Output
杰森输出

设定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
Show AS Number
Show AS Number
显示AS号
LEARN MORE  Windows Performance Recorder (wpr) Command Tutorial with Examples To Record Performance Metrics
了解更多Windows Performance Recorder(wpr)命令教程,并带有记录性能指标的示例

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

mtr网络诊断

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值