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:
- First, you need to be an administrator. That means to have a Linux account with sudo privileges.
- 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
- 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:
*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:
|-h–help||Show you the list of all available options.|
|-v–version||MTR command version.|
|-r–report||Report mode. You need to use it in combination with “–c” (count) and create statistics after the number of probes are made.|
|-w–report-wide||Wide report mode. Similar to the Report mode. A bit wider report that will include hostnames.|
|-c COUNT–report-cycles COUNT||Set the number of pings sent.|
|-s BYTES–psize BYTES PACKETSIZE||Decide on the size of the packets. If you choose a negative value, that will signal random sizes for the packets.|
|-t–curses||Curses-based terminal interface.|
|-n–no-dns||Just IP numbers (no hostname).|
|-l–raw||Raw output format.|
|-a IP.ADD.RE.SS–address IP.ADD.RE.SS||Bing outgoing packets’ sockets to a particular interface.|
|-i SECONDS–interval SECONDS||Change the time between each ping probe. The value is in seconds.|
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
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
$ 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.