Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Linux Network Diagnostic tool MTR

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article is about how to use MTR, a Linux network diagnostic tool. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

In linux, we can use mtr, which can not only be used to track routes, but also test packet loss rate and network delay.

Introduction to MTR

Once you run mtr, it will detect the network connection between the local system and the remote host you specify. It first establishes the address of each network hop (bridge, router, gateway, etc.) between hosts, and then ping each hop (sends a sequence of ICMP ECHO requests) to determine the quality of the link to each machine.

During this operation, by default, mtr outputs useful statistics about each machine-real-time updates.

This tool is pre-installed on most Linux distributions and can be easily used once you have passed the example of the 10 mtr command for Linux network diagnostics, which is described below.

If mtr is not installed, you can install it on their respective Linux distribution using the default package manager, as shown in the figure.

$sudo apt install mtr$ sudo yum install mtr$ sudo dnf install mtr10 examples of the use of MTR network diagnostic tools

1. The simplest example of using mtr is to provide the domain name or IP address of the remote machine as a parameter, such as google.com or 216.58.223.78. This command displays a real-time updated traceroute report until you exit the program (by pressing Q or Ctrl + C).

$mtr google.comOR$ mtr 216.58.223.78Start: Thu Jun 28 12:10:13 2018HOST: HowToing Loss% Snt Last Avg Best Wrst StDev1. |-- 192.168.0.1 0.0% 5 0.3 0.3 0.4 0.02. |-- 5.5.5.211 0.0% 50. 7 0.9 0.7 1.3 0.03. |-- 209.snat-111-91-120.hns.n 80.0% 5 7.1 7.1 7.1 0.04. |-- 72.14.194.226 0.0% 51.9 2.9 1.9 4.4 1.15. |-- 108.170.248.161 0% 5 2.9 3.5 2.0 4.3 0.76. |-- 216.239.62.237 0.0% 5 3.06.2 2.9 18.3 6.77. |-- bom05s12-in-f14.1e100.net 0.0% 5 2.1 2.4 2.0 3.8 0.5

two。 You can use the-n flag to force mtr to display numeric IP addresses instead of hostnames (usually FQDN-fully qualified domain names), as shown in the figure.

$mtr-n google.comStart: Thu Jun 28 12:12:58 2018HOST: HowToing Loss% Snt Last Avg Best Wrst StDev1. |-- 192.168.0.1 0.0% 5 0.3 0.3 0.4 0.02. |-- 5.5.5.211 0.0% 50.9 0.8 1.1 0.03. |--? 100.0 5 0.0 0.0 0.0 0.04. |-- 72.14.194.226 0.0% 5 2.0 2.0 1.9 2.0 0.05. |-- 108.170.248.161 0.0% 5 2.3 2.3 2.2 2.4 0.06. |-- 216.239.62.237 0.0% 5 3.0 3.2 3.0 3.3 0.07. |-- 172.217.160.174 0.0% 53.7 3.6 2.0 5.3 1.4

* * 3.notify * if you want mtr to display both the host name and the numeric IP number, use the-b flag, as shown in the figure.

$mtr-b google.comStart: Thu Jun 28 12:14:36 2018HOST: HowToing Loss% Snt Last Avg Best Wrst StDev1. |-- 192.168.0.1 0.0% 5 0.3 0.3 0.4 0.02. |-- 5.5.5.211 0.0% 5 0.70.8 0.6 1.0 0.03. |-- 209.snat-111-91-120.hns.n 0.0% 5 1.4 1.6 1.3 2.1 0.04. |-- 72.14.194.226 0.0% 51.8 2.1 1.8 2.6 0.05. |-- 108.170.248.209 0.09 5 2.0 1.9 1.8 2.0 0.06. |-- 216.239.56.115 0.0% 5 2.4 2.7 2.4 2.9 0.07. |-- bom07s15-in-f14.1e100.net 0.0% 5 3.7 2.2 1.7 3.7 0.9

4. To limit the number of ping to a specific value and exit mtr after these ping, use the-c flag. If you observe from the Snt column, once the specified number of ping is reached, the real-time update stops and the program exits.

$mtr-c5 google.com

5. You can set it to report mode using the-r flag, which is a useful option for generating statistics about network quality. You can use this option and the-c option to specify the number of ping. Because statistics are printed to standard output, you can redirect them to a file for later analysis.

$mtr-r-c 5 google.com > mtr-report

The-w flag enables a wide range of reporting modes for clearer output.

$mtr- rw-c 5 google.com > mtr-report

* * 6.output * you can also rearrange the output fields the way you want, with the-o flag shown (see the mtr man page for the meaning of the field label).

$mtr-o "LSDR NBAW JMXI" 216.58.223.78 MTR Station and order

MTR Station and order

7. The default interval between ICMP ECHO requests is 1 second. You can specify the interval between ICMP ECHO requests by changing the value with the-I flag, as shown in the figure.

$mtr-I 2 google.com

* * 8.requests * you can use TCP SYN packets or UDP datagrams instead of the default ICMP ECHO request, as shown in the figure.

$mtr-tcp test.comOR$ mtr-udp test.com

9. To specify the maximum number of hops to detect between the local system and the remote computer (the default is 30), use the-m flag.

$mtr-m 35 216.58.223.78

When probing network quality, you can use the-s flag to set the byte packet size used, as shown below.

$mtr-r-s PACKETSIZE-c 5 google.com > mtr-report

With these examples, you should make good use of mtr, see the man page for more usage options.

$man mtr

Thank you for reading! This is the end of this article on "how to use Linux Network Diagnostic tool MTR". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report