MTR command – A network diagnostic tool for Linux
Many network diagnostic tools are already a part of Linux. For example, Nslookup command, Host command, Dig command, Traceroute command, and more. But, sometime in the past, there was a guy called Matt Kimball. He was just not satisfied with the traceroute command in the 90s, so he decided to make a new one – the MTR command.
What is the MTR command?
The MTR command is a great small tool to trace the route to a target and get information for the round-trip. It is an alternative to the common traceroute command and was written by Matt Kimball created in 1997 to perform functions both from traceroute command and ping command. It provides more information in comparison with the other two commands and is just as easy to use on Linux. Roger Wolff further improved the software in 1998, and the name was changed to My Traceroute.
On Linux, you can use the MTR command straight through the Terminal application. If you don’t have it installed on your Linux distro, you first need to install it.
On Ubuntu, you can do it by typing: sudo apt update. Then press Enter and write your password. After that, type: sudo apt -y install mtr. Again press Enter.
How does it work?
The MTR command sends ICMP (Internet Control Message Protocol) data packets to the target you set. The target that you decide could be a hostname/domain name or an IP address (IPv4 or IPv6).
You can use it using the following syntax:
mtr option value target
Mtr – shows which command you are using.
Option – it can use one of the following options to improve your probe further:
-h – help.
-v – version.
-r – report. You need to stop it by pressing the “C” key, and after that, you get a report.
-w – extended report.
-c – number of ICMP messages to be sent.
-s – the size of ICMP data packages.
-t – Curses-based terminal interface.
-n – don’t resolve the hostnames.
-g – GTK+ interface.
-p – split – Split-user interface.
-l – Raw output.
-a – address.
-i – seconds between the ICMP messages.
-u –use UDP.
-4 – IPv4 addresses only.
-6 – IPv6 addresses only.
Value – the value of the option, if it applies. An example of this is a number after the “-i” that indicates seconds between the ICMP messages.
When the command sends the pings, it will wait for them to return. The MTR command will show statistics – round-trip time, lost packets if any, and time to reach the hop)
So, the MTR command is a Linux diagnostic tool used to trace the route and see if you have a connection with the target.