How to Easily Diagnose Your Network With MTR In Linux

If you’re serious about Linux and the command line, you’ve no doubt used ping to diagnose and troubleshoot your Internet connection. And if you’re serious about Linux and the command line, you’ve no doubt also used traceroute to diagnose your Internet connection. If you’ve wished for a tool that combined both Ping and Tracertoute, you’re in luck.

The tool is called MTR, for Matt’s Traceroute. It’s named after Matt Kimball, the original developer. Roger Wolff has been the maintainer since 1998.

MTR combines the functions of both the standard programs ping and traceroute. Like ping, it sends ICMP requests to a destination, either a domain name or an IP address, and listens for the destination to answer back. Like Traceroute, it also works by setting the Time To Live (TTL), or the number of maximum hops a packet can take over the network, to a low number, increasing with each attempt. This determines the route packets are taking to a destination along the way. The information will update continuously for as long as MTR runs.

mtr

Installing it is easy enough. If you’re on a Debian/Ubuntu system just type:

sudo apt-get install mtr

For other distro that doesn’t include MTR in its repository, you can download the source code and compile it with the command:

./configure
make
make install

MTR works in two modes, a graphical mode that users who aren’t as comfortable with the command line can work with more easily, and in a text-based mode.

Using MTR is pretty easy. If you wanted to test Google, you’d just use this command:

mtr google.com

The version in Ubuntu comes with a graphical interface. When you start MTR, the results will pop up in a window. If you’d rather have it in your terminal window like most Linux users, you have several options.

The easiest way is to call MTR with the “--curses” switch:

mtr --curses google.com

If that’s too much for you as well, you can download the plain text version:

sudo apt-get install mtr-tiny

If you want the graphical bells and whistles (although there really aren’t any in MTR), just use the “--gtk” option.

If you want to test an IP address instead of a hostname, use the “--address” option:

mtr --address 127.0.0.1

Of course, this will test the loopback device, or in other words, your own machine. You can use any IP address you want. It can be useful in case your DNS ever gets hosed.

You can also do some interesting things like change the display node and the way the fields are represented.

Linux is a great platform for learning how the Internet really works, and it’s due in no small part to the availability of tools like MTR. While sophisticated networking tools can cost thousands of dollars on other platforms, you can find quality tools to diagnose and troubleshoot connections available for free on Linux.

Image credit: Medical Instrument With Computer by BigStockPhoto