Well, the title is a bit misleading, as mtr is not just an alternative for ping but also for traceroute.
What is does is it combines the features of ping and traceroute in an ncurses interface. A GTK version is also available.
MTR stands for My traceroute, but was originally known as Matt's traceroute (source). There are many reviews of mtr available on the Internet, but still I feel that not enough people know about it. What's surprising is that it is by no means a new software, with the initial version being released in 1997.
You can install mtr using your distribution's package manager. For Arch Linux, you can do:
# pacman -S mtr or, for the GTK version # pacman -S mtr-gtk
Alternatively, you can get the tarball from here, and install it using the usual:
- make install
When you start mtr without any switches or hostname / IP, it pings the localhost.
When you do specify a hostname or an IP, for example:
$ mtr yahoo.com
the output looks like:
On the left side of the interface, you will find the hop numbers, followed by the hostnames or the IPs. If you don't want to resolve the host names, you can use the
If you focus on the left side of the image, you will notice that some hop numbers have multiple hosts next to them. For example, on hop number 7, there are 5 hosts shown. This is one of the features of mtr that I love the most. It shows the different servers used for routing on the same hop. It probably happens when load balancing, or Content Distribution Networks (CDNs) are involved.
The right side of the interface lists the important stuff like packet loss, number of packets sent, and time taken by the pings (in milliseconds).
It shows all this stuff per host, in realtime, without cluttering your terminal's output, and in a beautiful format.
Some useful options
One drawback of mtr is that sometimes the output goes beyond the bottom of the screen, and there is no way to scroll down and see the hidden part (probably an ncurses limitation). But, it can be worked around with the
--report-wide switch, which doesn't run mtr in ncurses mode, and instead presents the output on the stdout. The
-c or --report-cycles switch comes in handy with the
--report-wide switch, as it lets you specify the number of packets to send, similar to
--report-wide switch, you can save the output to a file and keep it for comparison, or share it with a networking expert.
Note: There is a switch named
--report available too, but it truncates long hostnames from the output.
Well, this concludes this mini-review/primer of mtr. It is by no means an exhaustive review of mtr, but I hope it should be enough to get you interested and play around with it. Believe me, after getting a taste of mtr, you'll find yourself using it much more frequently than ping, or even traceroute.