MTR is known as Matt’s traceroute. It is a simple and cross-platform utility for network diagnostic that is used for most of the command-line systems. This tool is not so popular but provides the features of both traceroute and ping programs. As similar to the traceroute program, the Mtr tool is also used to print the details about the desired route such as how packets initialize from the right host and reach the destination of the specified host. Mtr command displays more information as compared to the traceroute program in which the exact pathway determines between a local machine and a remote access system. It prints the percentage of the response rate and response time of all network hops that route between the host and destination system.
A network administrator must know about the usage of the mtr tool. The certain flags with mtr command increase the network diagnostic productivity. You can customize the desired output by using these flags. In this article, you will learn how mtr command will help you to find the network analysis between the network hops on CentOS 8. In most of the Linux distributions, the mtr tool is pre-installed by default. But, if it is not installed on your CentOS 8 then first you need to install it.
Install mtr command on CentOS 8
- Press Ctrl + Alt + t to open the terminal or open terminal using the desktop, click on the top corner of the “Activities” option, and select terminal from the left sidebar options.
- To install the mtr tool on CentOS 8, you need to log in as a root user. So, type ‘su’ command on the terminal. Now you have been logged in as a root user.
- Run the following command on the terminal to install mtr tool:
$sudo yum install mtr
Mtr tool has been successfully installed on your CentOS 8.0. A “Complete!” status will display on the terminal.
How to work with mtr command?
There are the following ways to use the mtr command in the command line system.
- The mtr command gives the complete traceroute report of a remote system in real-time. Using mtr command, you need to provide the IP address or domain name of the remote system. An output would be displayed on the system that will provide you the updated real-time traceroute report of the remote system. To exit the current program you will hit the “q” key or press “Ctrl+C” from your keyboard.
For example, you will take the domain name as google.com in an argument with the mtr command. Run the following command to view the real-time traceroute report of google.com:
You can display a numeric IP address in the traceroute report instead of displaying the hostname. The -n flag with mtr command is used to display numeric IP addresses. Run the following command on the terminal window to view the numeric IP addresses:
$mtr -n google.com
If you want to display both options IP addresses as well as the hostname then you will use -b flag with mtr command. Run the following command to display both the hostname and IP addresses in traceroute report:
$mtr -b google.com
You can set a specific value to limit the number of pings using mtr command. For this purpose, you will use the mtr command along with -c flag and specified limit value. In this case, you have limited the number of pings to an exact value and should exit after that specified number of pings. You can see the exact number of pings below the “Snt column”. As soon as the number of pings reaches the specified limit then real-time report updates the status of “stops” and you will automatically exit from the program. To easily understand, run the following command on your terminal to perform the above operation:
$mtr -c5 google.com
Using mtr command, you can set report mode. In this case, the report mode will enable that will display the output into a text file. This method is useful for network statistical analysis. Since the output is printed to a text file so you can use these observations for later use. To enable the report mode, you will use -r flag together with -c flag option. You will also mention the specified pings limit with -c flag and also specify the report name. The report name is basically the name of the report that will save after running the mtr command. Run the following command to perform the operation:
$mtr -r -c 5 google.com > mtr-report
The above-mentioned report will be saved by default into the home folder of CentOS 8.0. You can also save a report in other drives of your system to specify the exact path of the saved location.
To use -w flag and r flag with mtr command, it will enable the report mode in which you can print more clear and readable reports of traceroute. Run the following command on the terminal to try this operation:
$mtr -rw -c 5 google.com >mtr-report
By default, the mtr report prints into a specific order. You can rearrange the report output fields in a desired manner to make the output more productive and useful.
For this purpose, you will use -o flag to re-arrange the output. Run the following command on the terminal window to rearrange the output:
$mtr -o "LSDR NBAW JMXI" 220.127.116.11
By default, the ICMP and the ECHO requests have a time interval of 1 second. You can change this interval by changing the interval value. To specify the new time interval, you will use the -i flag with mtr command. Run the following command to see the output:
$mtr -i 2 google.com
If you want to use packets of TCP SYN and UDP datagrams instead of using ICMP ECHO requests then you will use TCP and UDP flags with mtr command. Run the following command to perform the required operation:
$ mtr --tcp google.com
$ mtr --udp google.com
By default, two hops have a time interval of 30 seconds. You can also define the maximum interval limit of two hops between the local machine and the remote system. Using -m flag can change the default limit. Run the following command to try this operation on your CentOS 8.0:
$mtr -m 35 18.104.22.168
Users can check the IP packet size and network quality. Using -s flag you can change the packet size. Run the following command on the terminal to check the output:
$mtr -r -s PACKETSIZE -c 5 google.com >mtr-report
The output will save into the mtr-report file.
You can also print report output in XML format. XML is a better option to make a report for automated processing. Run the following command to generate XML format output:
$mtr --xml google.com
From all the above-mentioned commands, you are able to deal with more mtr commands. To explore more about mtr tool you can run the following commands on the terminal:
In the above article, we have learned how to use the mtr tool on the command line on CentOS 8. Moreover, we have explored different mtr commands that are so helpful for a network administrator. I hope this article will be helpful to you.