How to use the MTR command?

How to use the MTR command on Linux?

It is very easy to use the MTR command through the Terminal on your Linux computer. Just follow these 3 steps:

  1. First, you need to be an administrator. That means to have a Linux account with sudo privileges.
  2. Second, you will need to install it. The MTR command is not pre-installed like other popular commands. The package name is “mtr”. For that purpose, you will need to execute one of the following commands, depending on your Linux distro:

Ubuntu, Debian, Linux Mint, and others based on Ubuntu or Debian:

sudo apt-get install mtr

Red Hat, CentOS, and Fedora:

sudo yum install mtr

Arch Linux, Manjaro Linux, and other Arch-based:

pacman -Sy pacman -S mtr

  1. Third, use the basic MTR command or combine it with some of the options that you have for it. See the complete list of options below. 

Basic MTR command: 

mtr domain.com 

*Change the domain name with the one you want. 

Suggested article: What is Traceroute command?

This is the syntax of MTR command on Linux: 

mtr [-hvrctglspni46] [–help] [–version] [–report] [–report-cycles COUNT] [–curses] [–split] [–raw] [–no-dns] [–gtk] [–address IP.ADD.RE.SS [–interval SECONDS] [–psize BYTES | -s BYTES] HOSTNAME [PACKETSIZE]

Options for MTR command on Linux, full list:

OptionDescription
-h–helpShow you the list of all available options.
-v–versionMTR command version.
-r–reportReport mode. You need to use it in combination with “–c” (count) and create statistics after the number of probes are made.  
-w–report-wideWide report mode. Similar to the Report mode. A bit wider report that will include hostnames. 
-c COUNT–report-cycles COUNTSet the number of pings sent. 
-s BYTES–psize BYTES PACKETSIZEDecide on the size of the packets. If you choose a negative value, that will signal random sizes for the packets. 
-t–cursesCurses-based terminal interface.
-n–no-dnsJust IP numbers (no hostname).
-g–gtkGTK+ interface. 
-p–splitSplit-user interface. 
-l–rawRaw output format. 
-a IP.ADD.RE.SS–address IP.ADD.RE.SSBing outgoing packets’ sockets to a particular interface. 
-i SECONDS–interval SECONDSChange the time between each ping probe. The value is in seconds.  
-uUDP.
-4IPv4 only.
-6IPv6 only.

MTR command examples 

Here you have a few examples of the MTR commands, with different options that will better show you what the MTR command is capable of. You can use the examples for your own purposes by changing the host names, IP addresses, or any other parameter of the examples. 

Default MTR command

mtr domain.com 

You will see all the basics – hops, time for the queries, and percentage of packets lost. 

See both IP addresses and hostnames

mtr -b domain.com

Now you will have a richer result, showing you both hostnames and IP addresses for the hops.

Send a custom amount of probes

mtr -c 123 domain.com

With the “-c” letter, you can set the number of pings that you wish to send to the target. Higher numbers will show you more data, which will give you a better idea of the domain’s behavior. In this example, the value is 123, so 123 pings will be sent. 

Save the MTR result in a report

mtr -r -c 123 domain.com >mtr-report

or

$ mtr -rw -c 123 domain.com >mtr-report

First, it will send 123 pings, but it will also save the result to “mtr-report” file, where you can later review it. The difference between “-r” and “-wr” is the final report format. Experiment and see which one you like more. 

Set the time between each of the pings

mtr -i 45 domain.com

Now, each of the pings will go 45 seconds after the previous. You can set it to a high number and leave it checking. Combine the information and save it into a report for later revision. 

Write a Comment

Your email address will not be published. Required fields are marked *