Skip to content

DNS.COMPUTER/blog

Tech Blog

How to use Linux MTR command?

Posted on April 5, 2021July 20, 2021 By Martin Pramatarov No Comments on How to use Linux MTR command?
Commands

There are plenty of programs for network diagnostic. You might wonder, do we need one more? 

If you want to trace the route of a query, yes! The MTR command could slightly outperform the traditional Traceroute command and give some more data, so it has a reason to exist. 

What is MTR command?

MTR comes from Matt’s traceroute. First written by Matt Kimball in 1997 and later updated with Roger Wolff’s help, this is software with CLI that helps you see the route of a query. 

It is based on the traditional traceroute command, but it presents each of the hops on the way, with a table-like view and data like data loss, amount of packets sent, the time of the return of each hop. 

MTR command syntax

How to use Linux MTR command? 

It is a command for Linux distros, but it doesn’t come pre-installed. 

  1. Open the Terminal application. 
  2. Now use this command for installing it. 

For Ubuntu, Debian, or distros that are closely based on them, write:

sudo apt-get install mtr

Write your password and press Enter. 

For CentOS, Feroda, or RedHat:

sudo yum install mtr

Again, password and Enter. 

  1. Now you can try to ping a particular domain that you want with: mtr domainname.com. Change the Domainname.com with the one you want. 

The full syntax is:

 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]

Use additional options and extend the functionality of the MTR command.

*You can easily install the MTR command on macOS with Brew (brew install mtr) or on FreeBSD (sudo pkg iWnstall package_name).

MTR available options on Linux

OptionWhat is does?
-h–helpSee all the available options.
-v–versionVersion of the MTR command.
-r–reportThis starts the report mode. Will run, depending on the count value (–c).  
-w–report-wideWide report mode (+hostnames). 
-c COUNT–report-cycles COUNTNumber of pings. 
-s BYTES–psize BYTES PACKETSIZEPackets’ size in bytes. 
-t–cursesCurses-based terminal interface.
-n–no-dnsShow IP numbers instead of hostname.
-g–gtkGTK+ interface. 
-p–splitSplit-user interface. 
-l–rawSet to raw output format. 
-a IP.ADD.RE.SS–address IP.ADD.RE.SSSet outgoing packets’ sockets to a specified interface. 
-i SECONDS–interval SECONDSInterval, between the ICMP ECHO requests. 
-uUDP for queries.
-4IPv4 only.
-6IPv6 only.

Examples of how to use the MTR command

Use these examples of the MTR command, and apply them with your domain names and IP addresses by simply changing that part from them.

See the route of a query

mtr domainname.com

You can see the individual hops with their hostnames and statistics about the time it took and packets’ lost. You can use an IP address instead of a domain name. When you get enough data, press “Ctrl+C” to stop it. 

Set a number of pings 

If you want to set a particular amount of queries, you can use the “-c” option and put the number. When it finishes, it will auto-exit. 

mtr -c 99 domainname.com

Print the result with the Report Mode

You can use the so-called Report Mode and put the result directly into a TXT file. It makes it practical if you want to see the result later. 

mtr -r -c 99 domainname.com >TXT file name

Set time interval between the pings

You can set time in seconds, from one ICMP ECHO to another. 

mtr -i 99 domainname.com

Use UDP or TCP instead of the ICMP ECHO

If you want to use one of these protocols, you can with these MTR commands: 

mtr –udp domainname.com

mtr –tcp domainname.com

Set the packets’ size

You can decide what packets’ size to use for your queries. The size will be in bytes. 

mtr -r -s 64 domainname.com

Set maximum time between hops

The default time is already set to 30 seconds, but you can increase it and allow a bit more waiting time for each hop. The time we set here is 60 seconds, and we use the IP address 1.2.3.4.

mtr -m 60 1.2.3.4

Tags: Linux MTR MTR command

Post navigation

❮ Previous Post: What is Master (Primary) DNS zone?
Next Post: What is Round-Robin DNS? ❯

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Categories

  • Commands
  • DNS
  • DNS records
  • DNS services
  • Security

Recent Posts

  • DNSSEC breakdown
  • Usage and Advantages of Dynamic DNS
  • Differences between A record and PTR record
  • NSlookup command – what is it?
  • What is a DNS flood?

Archives

  • June 2022
  • March 2022
  • December 2021
  • September 2021
  • August 2021
  • July 2021
  • June 2021
  • April 2021
  • March 2021
  • February 2021

Copyright © 2023 DNS.COMPUTER/blog.

Theme: Oceanly by ScriptsTown