mtr (My TraceRoute) — usage and practice

Ruslan Kh.
5 min readApr 9, 2023

--

The mtr (My Traceroute) command is a network diagnostic tool that combines the functionality of the traceroute and ping utilities into a single tool. It is used to trace the route of packets from your system to a remote host, displaying latency and packet loss statistics along the way.

Here’s a breakdown of the columns in the mtr output:

  1. Hop (counter in Host column): The number of hops on the route from your system to the target host.
  2. Hostname: The hostname (or IP address) of the network node at each hop.
  3. Loss%: The percentage of packets lost at each hop.
  4. Snt: The total number of packets sent at each hop.
  5. Last: The latency of the last packet, in milliseconds.
  6. Avg: The average latency of all packets sent to this hop, in milliseconds.
  7. Best: The lowest (best) latency of all packets sent to the hop, in milliseconds.
  8. Worst: The highest (worst) latency of all packets sent to the hop, in milliseconds.
  9. StDev: The standard deviation of the latency values for each hop, in milliseconds.

In the mtr output, the “Loss” column represents the percentage of packets lost at each hop (network node) along the path. Packet loss is calculated by comparing the number of packets sent to a hop with the number of packets received back from that hop. This information can be useful in identifying problematic network links or nodes that may be causing performance problems.

By analyzing the “Loss” column, you can get an idea of where problems might be occurring in the network path, which can be helpful when troubleshooting or optimizing network performance.

mtr is a versatile tool that provides valuable information about the network path between your system and a remote host. Here are some usage examples:

  1. Basic usage:

To run mtr with default settings, simply specify the target hostname or IP address:

mtr example.com
mtr example.com
mtr example.com

2. Display IP addresses instead of hostnames in the output:

By default, mtr displays hostnames in the output. Use the -n option to show IP addresses instead:

mtr -n example.com

3. Set the number of pings per hop:

Use the -c option to set the number of pings (ICMP Echo Requests) sent to each hop before mtr moves on to the next:

mtr -c 20 example.com

4. Specify the interval between pings:

Use the -i option to set the interval (in seconds) between sending pings to each hop. The default is 1 second:

mtr -i 0.5 example.com
mtr — interval setting example

5. Use TCP or UDP instead of ICMP:

You can use the --tcp or --udp options to use TCP or UDP respectively. By default, mtr uses ICMP for probing:

mtr --tcp -P 80 example.com

This example will use TCP probes on port 80 (the default HTTP port).

6. Display the results in another format:

mtr supports several output formats, such as JSON, XML, CSV or plain text. Use the --report option for a plain text report, or the --json, --xml or --csv options for the corresponding formats:

mtr --report example.com

7. Save the output to a file:

You can save the output of mtr to a file using shell redirection:

mtr --report example.com > ~/mtr_report.txt

These examples should help you get started using mtr to diagnose network problems and better understand the path between your system and a remote host.

Installation.

To install mtr on various platforms, follow the instructions below:

Debian-based Linux distributions (e.g., Ubuntu, Debian, Linux Mint).

Open a terminal and run the following command:

sudo apt-get update sudo apt-get install mtr

RHEL-based Linux distributions (e.g., Fedora, CentOS, RHEL).

Open a terminal and run the following command:

sudo yum install mtr -y

On newer versions of Fedora, you might need to use `dnf` instead of `yum`:

sudo dnf install mtr -y

Arch-based Linux distributions (e.g., Arch Linux, Manjaro).

Open a terminal and run the following command:

sudo pacman -S mtr

OpenSUSE.

Open a terminal and run the following command:

sudo zypper install mtr

macOS.

If you have Homebrew installed, open a terminal and run the following command:

brew install mtr

If you have MacPorts installed, open a terminal and run the following command:

sudo port install mtr

cat << EOF > ~/.bash_profile
# fix MTR (MacPorts)
export MTR_PACKET=/usr/local/bin
EOF

Windows.

While mtr is not natively available for Windows, you can use a Windows-compatible version called “WinMTR.” You can download it from the following URL https://sourceforge.net/projects/winmtr/ .

Download and extract the ZIP file, then run `WinMTR.exe` to use the tool.

These installation steps should help you get `mtr` up and running on your system. Once installed, you can use it to diagnose and troubleshoot network issues by tracing packet paths and analyzing network performance.

--

--

Ruslan Kh.

I love technology, programming, computers, tech devices and the world of tomorrow