{"id":12713,"date":"2019-03-28T14:21:40","date_gmt":"2019-03-28T14:21:40","guid":{"rendered":"http:\/\/www.appservgrid.com\/paw92\/?p=12713"},"modified":"2019-03-28T14:21:40","modified_gmt":"2019-03-28T14:21:40","slug":"mtr-a-network-diagnostic-tool-for-linux","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/mtr-a-network-diagnostic-tool-for-linux\/","title":{"rendered":"MTR \u2013 A Network Diagnostic Tool for Linux"},"content":{"rendered":"<p><strong>MTR<\/strong>\u00a0is a simple, cross-platform command-line network diagnostic tool that combines the functionality of commonly used\u00a0<strong>traceroute<\/strong>\u00a0and\u00a0<strong>ping<\/strong>\u00a0programs into a single tool. In a similar fashion as\u00a0<strong>traceroute<\/strong>,\u00a0<strong>mtr<\/strong>\u00a0prints information about the route that packets take from the host on which mtr is run to a user specified destination host.<\/p>\n<p><strong>Read Also<\/strong>:\u00a0<a href=\"https:\/\/www.tecmint.com\/audit-network-performance-security-and-troubleshooting-in-linux\/\" target=\"_blank\" rel=\"noopener\">How to Audit Network Performance, Security and Troubleshoot in Linux<\/a><\/p>\n<p>However,\u00a0<strong>mtr<\/strong>\u00a0shows a wealth of information than\u00a0<strong>traceroute<\/strong>: it determines the pathway to a remote machine while printing response percentage as well as response times of all network hops in the internet route between the local system and a remote machines.<\/p>\n<h4>How Does MTR Work?<\/h4>\n<p>Once you run\u00a0<strong>mtr<\/strong>, it probes the network connection between the local system and a remote host that you have specified. It first establishes the address of each network hop (bridges, routers and gateways etc.) between the hosts, it then\u00a0<strong>pings<\/strong>\u00a0(sends a sequence\u00a0<strong>ICMP ECHO<\/strong>\u00a0requests to) each one to determine the quality of the link to each machine.<\/p>\n<p>During the course of this operation,\u00a0<strong>mtr<\/strong>\u00a0outputs some useful statistics about each machine \u2013 updated in real-time, by default.<\/p>\n<p>This tool comes pre-installed on most Linux distributions and is fairly easy to use once you go through the\u00a0<strong>10 mtr command examples<\/strong>\u00a0for network diagnostics in Linux, explained below.<\/p>\n<p>If mtr not installed, you can install it on your respective Linux distributions using your default package manager as shown.<\/p>\n<pre>$ sudo apt install mtr\r\n$ sudo yum install mtr\r\n$ sudo dnf install mtr\r\n<\/pre>\n<h3>10 MTR Network Diagnostics Tool Usage Examples<\/h3>\n<p><strong>1.<\/strong>\u00a0The simplest example of using\u00a0<strong>mtr<\/strong>\u00a0is to provide the domain name or IP address of the remote machine as an argument, for example\u00a0<strong>google.com<\/strong>\u00a0or\u00a0<strong>216.58.223.78<\/strong>. This command will show you a\u00a0<strong>traceroute<\/strong>\u00a0report updated in real-time, until you exit the program (by pressing\u00a0<code>q<\/code>\u00a0or\u00a0<code>Ctrl + C<\/code>).<\/p>\n<pre><strong>$ mtr google.com<\/strong>\r\nOR\r\n<strong>$ mtr 216.58.223.78<\/strong>\r\n\r\nStart: Thu Jun 28 12:10:13 2018\r\nHOST: TecMint                     Loss%   Snt   Last   Avg  Best  Wrst StDev\r\n  1.|-- 192.168.0.1                0.0%     5    0.3   0.3   0.3   0.4   0.0\r\n  2.|-- 5.5.5.211                  0.0%     5    0.7   0.9   0.7   1.3   0.0\r\n  3.|-- 209.snat-111-91-120.hns.n 80.0%     5    7.1   7.1   7.1   7.1   0.0\r\n  4.|-- 72.14.194.226              0.0%     5    1.9   2.9   1.9   4.4   1.1\r\n  5.|-- 108.170.248.161            0.0%     5    2.9   3.5   2.0   4.3   0.7\r\n  6.|-- 216.239.62.237             0.0%     5    3.0   6.2   2.9  18.3   6.7\r\n  7.|-- bom05s12-in-f14.1e100.net  0.0%     5    2.1   2.4   2.0   3.8   0.5\r\n<\/pre>\n<p><strong>2.<\/strong>\u00a0You can force mtr to display numeric IP addresses instead of host names (typically\u00a0<strong>FQDNs<\/strong>\u00a0\u2013\u00a0<strong>Fully Qualified Domain Names<\/strong>), using the\u00a0<code>-n<\/code>\u00a0flag as shown.<\/p>\n<pre><strong>$ mtr -n google.com<\/strong>\r\n\r\nStart: Thu Jun 28 12:12:58 2018\r\nHOST: TecMint                     Loss%   Snt   Last   Avg  Best  Wrst StDev\r\n  1.|-- 192.168.0.1                0.0%     5    0.3   0.3   0.3   0.4   0.0\r\n  2.|-- 5.5.5.211                  0.0%     5    0.9   0.9   0.8   1.1   0.0\r\n  3.|-- ???                       100.0     5    0.0   0.0   0.0   0.0   0.0\r\n  4.|-- 72.14.194.226              0.0%     5    2.0   2.0   1.9   2.0   0.0\r\n  5.|-- 108.170.248.161            0.0%     5    2.3   2.3   2.2   2.4   0.0\r\n  6.|-- 216.239.62.237             0.0%     5    3.0   3.2   3.0   3.3   0.0\r\n  7.|-- 172.217.160.174            0.0%     5    3.7   3.6   2.0   5.3   1.4\r\n<\/pre>\n<p><strong>3.<\/strong>\u00a0If you would like mtr to display both host names as well as numeric IP numbers use the\u00a0<code>-b<\/code>\u00a0flag as shown.<\/p>\n<pre><strong>$ mtr -b google.com<\/strong>\r\n\r\nStart: Thu Jun 28 12:14:36 2018\r\nHOST: TecMint                     Loss%   Snt   Last   Avg  Best  Wrst StDev\r\n  1.|-- 192.168.0.1                0.0%     5    0.3   0.3   0.3   0.4   0.0\r\n  2.|-- 5.5.5.211                  0.0%     5    0.7   0.8   0.6   1.0   0.0\r\n  3.|-- 209.snat-111-91-120.hns.n  0.0%     5    1.4   1.6   1.3   2.1   0.0\r\n  4.|-- 72.14.194.226              0.0%     5    1.8   2.1   1.8   2.6   0.0\r\n  5.|-- 108.170.248.209            0.0%     5    2.0   1.9   1.8   2.0   0.0\r\n  6.|-- 216.239.56.115             0.0%     5    2.4   2.7   2.4   2.9   0.0\r\n  7.|-- bom07s15-in-f14.1e100.net  0.0%     5    3.7   2.2   1.7   3.7   0.9\r\n<\/pre>\n<p><strong>4.<\/strong>\u00a0To limit the number of\u00a0<strong>pings<\/strong>\u00a0to a specific value and exit\u00a0<strong>mtr<\/strong>\u00a0after those pings, use the\u00a0<code>-c<\/code>\u00a0flag. If you observe from the\u00a0<strong>Snt<\/strong>\u00a0column, once the specified number of pings is reached, the live update stops and the program exits.<\/p>\n<pre><strong>$ mtr -c5 google.com<\/strong>\r\n<\/pre>\n<p><strong>5.<\/strong>\u00a0You can set it into report mode using the\u00a0<code>-r<\/code>\u00a0flag, a useful option for producing statistics concerning network quality. You can use this option together with the\u00a0<code>-c<\/code>\u00a0option to specify the number of pings. Since the statistics are printed to\u00a0<strong>std<\/strong>\u00a0output, you can redirect them to a file for later analysis.<\/p>\n<pre>$ mtr -r -c 5 google.com &gt;mtr-report\r\n<\/pre>\n<p>The\u00a0<code>-w<\/code>\u00a0flag enables wide report mode for a clearer output.<\/p>\n<pre>$ mtr -rw -c 5 google.com &gt;mtr-report\r\n<\/pre>\n<p><strong>6.<\/strong>\u00a0You can also re-arrange the output fields the way you wish, this is made possible by the\u00a0<code>-o<\/code>\u00a0flag as shown (see the mtr man page for meaning of field labels).<\/p>\n<pre>$ mtr -o \"LSDR NBAW JMXI\" 216.58.223.78\r\n<\/pre>\n<div id=\"attachment_29912\" class=\"wp-caption aligncenter\">\n<p><a href=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/specify-order-of-output-fields.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-29912\" src=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/specify-order-of-output-fields.png\" sizes=\"auto, (max-width: 1112px) 100vw, 1112px\" srcset=\"https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/specify-order-of-output-fields.png 1112w, https:\/\/www.tecmint.com\/wp-content\/uploads\/2018\/06\/specify-order-of-output-fields-768x277.png 768w\" alt=\"MTR Fields and Order\" width=\"1112\" height=\"401\" aria-describedby=\"caption-attachment-29912\" data-lazy-loaded=\"true\" \/><\/a><\/p>\n<p id=\"caption-attachment-29912\" class=\"wp-caption-text\">MTR Fields and Order<\/p>\n<\/div>\n<p><strong>7.<\/strong>\u00a0The default interval between\u00a0<strong>ICMP ECHO<\/strong>\u00a0requests is one second, you can specify interval between ICMP ECHO requests by changing the value using the\u00a0<code>-i<\/code>\u00a0flag as shown.<\/p>\n<pre>$ mtr -i 2 google.com\r\n<\/pre>\n<p><strong>8.<\/strong>\u00a0You can use TCP SYN packets or UDP datagrams instead of the default ICMP ECHO requests as shown.<\/p>\n<pre>$ mtr --tcp test.com\r\nOR\r\n$ mtr --udp test.com \r\n<\/pre>\n<p><strong>9.<\/strong>\u00a0To specify the maximum number of\u00a0<strong>hops<\/strong>\u00a0(default is\u00a0<strong>30<\/strong>) to be probed between the local system and the remote machine, use the\u00a0<code>-m<\/code>\u00a0flag.<\/p>\n<pre>$ mtr -m 35 216.58.223.78\r\n<\/pre>\n<p><strong>10.<\/strong>\u00a0While probing network quality, you can set the packet size used in bytes using the\u00a0<code>-s<\/code>\u00a0flag like so.<\/p>\n<pre>$ mtr -r -s PACKETSIZE -c 5 google.com &gt;mtr-report\r\n<\/pre>\n<p>With these examples, you should be good to go with using\u00a0<strong>mtr<\/strong>, see man page for more usage options.<\/p>\n<pre>$ man mtr \r\n<\/pre>\n<p>Also check out these useful guides about Linux network configurations and troubleshooting:<\/p>\n<ol>\n<li><a href=\"https:\/\/www.tecmint.com\/linux-network-configuration-and-troubleshooting-commands\/\" target=\"_blank\" rel=\"noopener\">13 Linux Network Configuration and Troubleshooting Commands<\/a><\/li>\n<li><a href=\"https:\/\/www.tecmint.com\/block-ping-icmp-requests-to-linux\/\" target=\"_blank\" rel=\"noopener\">How to Block Ping ICMP Requests to Linux Systems<\/a><\/li>\n<\/ol>\n<p>That\u2019s it for now!\u00a0<strong>MTR<\/strong>\u00a0is a simple, easy-to-use and above all cross-platform network diagnostics tool. In this guide, we have explained\u00a0<strong>10 mtr command<\/strong>\u00a0examples in Linux. If you have any questions, or thoughts to share with us, use the comment form below.<\/p>\n<p><a href=\"https:\/\/www.tecmint.com\/mtr-a-network-diagnostic-tool-for-linux\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MTR\u00a0is a simple, cross-platform command-line network diagnostic tool that combines the functionality of commonly used\u00a0traceroute\u00a0and\u00a0ping\u00a0programs into a single tool. In a similar fashion as\u00a0traceroute,\u00a0mtr\u00a0prints information about the route that packets take from the host on which mtr is run to a user specified destination host. Read Also:\u00a0How to Audit Network Performance, Security and Troubleshoot in &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw92\/index.php\/2019\/03\/28\/mtr-a-network-diagnostic-tool-for-linux\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;MTR \u2013 A Network Diagnostic Tool for Linux&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-12713","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12713","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/comments?post=12713"}],"version-history":[{"count":1,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12713\/revisions"}],"predecessor-version":[{"id":12717,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/posts\/12713\/revisions\/12717"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/media?parent=12713"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/categories?post=12713"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw92\/index.php\/wp-json\/wp\/v2\/tags?post=12713"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}