There are many small network tools out there: Ping, Traceroute, Dig, Host, etc.
But, it is not so often when one of these small command-line utilities has combined the functionality of two in a single program. MTR command is such a case. It is a combination of ping and traceroute.
What is the MTR command?
MTR (Matt’s traceroute) is a program with a command-line interface that serves for network diagnostic and troubleshooting. The original code was created by Matt Kimball in 1997. One year later, Roger Wolff continue its work and rename it to My traceroute.
The advantage of this software is that it combines the functionality of the Ping command and the Traceroute. Just like a typical traceroute query, a query from the MTR command will show the route from a computer to a specified host.
The advantage over the traditional is that it will also provide a lot of statistics about each hop, like response time and percentage.
So, using the MTR command, you will get more information about the route and see problematic devices on the way. If you see a sudden increase in time of response or packet loss, you have found a bad link.
In a brief, the MTR command serves you for the following:
- Check the connectivity from the computer with the command to a destination.
- See packet loss. It will indicate the quality of the connectivity between the points.
- Time for a round-trip. You can see the exact time it takes for the packets to reach the destination and provide a report.
The MTR command is available on Unix-based OSes like Linux (Ubuntu, CentOS, Fedora, etc.), macOS, and FreeBSD. There is a version of MTR for Windows, but with limited functionality. There is also WinMTR for Windows, but its code is different.
How to use the MTR command?
How to use the MTR command on Linux or FreeBSD?
*You will need administrative privileges for MTR on Linux and FreeBSD (sudo)
- First, you will need to open the Terminal application.
- To get the MTR command on Linux (Ubuntu or Debian), you will need to install it with this command “sudo apt-get install mtr”, “sudo yum install mtr” for CentOS, Fedora or “sudo pkg iWnstall package_name” on FreeBSD.
- Use the following command “mtr -rw [destination_host]” for basic information or check the syntax and the examples below, to do more advanced tasks. Change the destination_host with the one you like. Use it for 10-15 minutes.
How to use the MTR command on macOS?
*You will need administrative privileges for MTR on macOS (sudo). The command won’t be pre-installed, so you will need to install it first.
- You will need Brew to install it. Go to Brew’s site and there choose a language.
- Under it, you will see a text command, copy it.
- On your Mac computer, go to Applications, then Utilities, and there open the Terminal application.
- Inside the Terminal, paste the text and press Enter.
- You will be prompted a message to put your password. Do it and press Enter.
- After Brew is already installed, you will need to write a new command: “brew install mtr” and press Enter.
- When the MTR gets installed, you can start it with “sudo mtr” and Enter. Use this code “mtr -rw [destination_host]” to perform a basic check. Change the destination_host with the one you like. Run it for 10-15 minutes.
- Now you can start using the MTR command on macOS. See the syntax below and the examples to learn how to do more complex tasks.
How to use the MTR command on Windows?
- First, you need to download WinMTR from GitHub.
- Get the file called WinMTR-v100-static.zip, unzip it, and there will be two versions: WinMTR.exe (32bit) and WinMTR64.exe.
- Choose depending on your version of Windows and double click it.
- Put the host you want to check in the Host box. If you need extra options, you can see them in “Options”
- Press start and run it for a while (10-15 minutes).
- Stop it when you think you got enough information. You can copy the text and save it in a text file.
MTR command syntax and list of options
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]
You can see all the available options for MTR command on Linux:
|-h–help||Show all the available options.|
|-v–version||Show the version of the MTR command.|
|-r–report||This starts the report mode. In this mode, it will run the specified by “–c” number of times and show statistics at the end.|
|-w–report-wide||Wide report mode. The difference with the previous is that it won’t cut hostnames in the report.|
|-c COUNT–report-cycles COUNT||Specify the number of pings.|
|-s BYTES–psize BYTES PACKETSIZE||Set the size of the packets. If set to a negative number, it will send packets of random size.|
|-t–curses||Force curses-based terminal interface.|
|-n–no-dns||Show numeric IP numbers and no hostname resolving.|
|-g–gtk||Force GTK+ interface.|
|-p–split||Set the mtr command for the split-user interface.|
|-l–raw||With the letter “L”, you can set the use of the 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||Set the time in seconds between each ICMP ECHO request.|
|-u||Force UDP use instead of ICMP ECHO.|
|-4||Force IPv4 only.|
|-6||Force IPv6 only.|
MTR command examples
We will show you multiple examples of the MTR command and how to use it on Linux. You can use the same examples when you are using macOS or FreeBSD (there might be small differences). We will use Google.com as a hostname and some public IP addresses. You can change them and use them for your purposes.
The basic mtr command
$ mtr google.com
It will show you the basic statistics: each hop (hostnames) with time and loss%.
Show numeric IP addresses
$ mtr -g google.com
If you use “-g” you will get IP addresses (numbers) instead of hostnames. You can use the IP addresses with another tool for further diagnostic.
Show the numeric IP addresses and hostnames too
$ mtr -b google.com
Now you will see both hostnames and IP addresses. The addresses will be inside brackets.
Set the number of pings that you want to send
$ mtr -c 10 google.com
In this case, you are setting the number of pings that you want to send (10 in this case). You can set it to a big number like 1000 to check a hostname for a longer period and get a better idea of the connectivity.
Get a report of the MTR command result
$ mtr -r -c 10 google.com >mtr-command-google
$ mtr -rw -c 10 google.com >mtr-command-google
We do that with the “-r”. Here we have set the number of pings to 10, and the last part, “mtr-command-google”, is the name that you can change the way you like.
When you use the “-rw” you can get a cleaner report, easier on the eyes.
Rearrange the report
$ mtr -o “LSDR NBAW JMXI” google.com
The “-o” is for output. You can change the report format with this code, so you get the information the way you like.
Time intervals between ICMP ECHO requests
$ mtr -i 10 google.com
With “-c”, we set the number of pings. With the “-i” you set the time interval between the ICMP ECHO pings.
$ mtr –tcp google.com
Force the use of the TCP instead of the ICMP.
$ mtr –udp google.com
Force the use of the UDP instead of the ICMP.
Set the maximum amount of hops
$ mtr -m 35 22.214.171.124
We will use “-m” and a value of 35 to a specific IP address. You can change it to a more significant value if the query does more hops on the way.
Define the packet size
$ mtr -r -s 50 google.com
You can decide the specific packet size for the pings. In this example of a MTR command, we are using 50 bytes.
Print to CSV Output
$ mtr –csv google.com
Use it if the CSV format works better for you than the traditional report.
Print to XML Output
$ mtr –xml google.com
Use it if the XML format works better for you than the regular report.
More information and help
$ man mtr
$ mtr –help
Those two commands can give you more information about the MTR command and how to use it
The MTR command is a good combination between two popular tools: Ping and Traceroute. It is easy to use and you can find it on different OSes.
If you want to check more network utility programs, check the following links:
Hi, I’m Martin Pramatarov. I have two degrees, a Technician of Computer Networks and an MBA (Master of Business Administration). My passion is storytelling, but I can’t hide my nerdish side too. I never forgot my interest in the Hi-tech world. I have 10 years and thousands of articles written about DNS, cloud services, hosting, domain names, cryptocurrencies, hardware, software, AI, and everything in between. I have seen the Digital revolution, the Big migration to the cloud, and I am eager to write about all the exciting new tech trends in the following years. AI and Big Data are here already, and they will completely change the world!
I hope you enjoy my articles and the excellent services of ClouDNS!