MTR, a tool for network analysis from the terminal

mtr terminal about

In the next article we are going to take a look at MTR. It is a network analysis tool and that we are going to use from the command line. It is a simple and multiplatform program that combines the functionality of the traceroute and ping programs in a single tool.

Once MTR is running, it will explore the network connection between the local system and a remote host that we specify. First you set the address of each network hop between the hosts. It then pings each one to determine the quality of the link to each machine.

Like traceroute, this program prints information about the path taken by packets. From the host where MTR is running to a user-specified target host. It will also be possible to determine the path to a remote machine while printing the response percentage, as well as the response times of all network hops between the local system and the remote machine.

During the course of this operation, MTR generates some useful statistics on each machine. These are updated in real time, by default. When executing the program, ICMP packets are sent adjusting the time to live (TTL), to see the series of jumps that the packet makes between the origin and the destination. A sudden increase in packet loss or response time can be a sign of a bad connection, an overloaded host, or even a man-in-the-middle attack.

Install MTR

We will find this tool pre-installed on most Gnu / Linux distributions and it is quite easy to use. If you can't find MTR installed, you can install it on Ubuntun using the default package manager. We will only have to open a terminal (Ctrl + Alt + T) and write in it:

sudo apt install mtr

Some examples of using MTR

basic mtr example

The simplest example we can use with MTR is to supply the domain name or IP address of the remote machine as an argument, for example google.com or 216.58.223.78. This command will show us a traceroute report updated in real time, until we close the program, pressing q or Ctrl + C.

mtr google.com

View numeric IP addresses

numeric ip mtr

We will be able to force MTR to show IP addresses instead of host names. For this we will only have to use -n as shown below:

mtr -n google.com

View host names and numeric IPs

view hosts and numeric ips mtr

If we are interested in MTR showing both host names and IP, we will only have to use -b:

mtr -b google.com

Limit the number of pings

mtr limit number of pings

To limit the number of pings to a specific value and exit MTR after those pings, we'll use -c. If we look at the Snt column, once the specified number of pings is reached, the live update stops and the program exits. In this example, 4 pings will be fired.

mtr -c 4 google.com

Generate network statistics

This program can be configured in report mode. To do this, we will use -r, which is a useful option to generate statistics on network quality. We can use this option together with -c to specify the number of pings. Since the statistics are printed on standard output, we will be able to redirect them to a file for further analysis.

mtr -r -c 4 google.com  > mtr-reporte

Organize the output fields

mtr organize fields

We will also be able to organize the output fields in the way that interests us the most. This is possible thanks to the -o option as shown below. It can see the MTR man page for the meaning field labels.

mtr -o "LSDR NBAW JMXI" 216.58.223.78

Interval between ICMP ECHO requests

The default interval between ICMP ECHO requests is one second. This can be changed by specifying a new interval between requests changing the value using -i.

mtr -i 2 google.com

Specify the maximum number of jumps

We will be able to specify a maximum number of jumps. The default is 30. With this we will be able to probe between the local system and the remote machine. To do this we use -m followed by the value that interests us.

mtr -m 35 216.58.223.78

Set the size of the packet used

By testing the quality of the network, we will be able to set the packet size. This is specified in bytes using -s. In the following command we will have to give a numerical value to the PACKETSIZE field:

mtr -r -s PACKETSIZE -c 5 google.com > mtr-reporte

MTR Help

Any user who needs it can get help with this program by taking a look at the man page. In it we will find more options for use.

man mtr

help mtr

We can also make use of the help menu offered by the program from its interface by pressing the H key.


Leave a Comment

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

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.