Skip to content

mtr command in Linux

The mtr command in Linux combines the functionality of ‘traceroute’ and ‘ping’ to provide extensive network diagnostic information. It continuously polls network routers along the path to a destination, displaying data on packet loss, latency, and network congestion. This real-time data visualization helps in troubleshooting network issues and identifying potential bottlenecks. With mtr, users can pinpoint network problems more effectively and make informed decisions to optimize network performance.

Terminal window
mtr [options] [hostname or IP address]
OptionDescription
-hDisplay the help screen
-4Use IPv4 only
-6Use IPv6 only
-cNumber of pings to send
-iInterval between pings (seconds)
-wDestination port number
-rBypass the reverse DNS lookup
-sSet the maximum packet size
-tSet the TCP port number
ParameterDescription
hostname/IPThe hostname or IP address to trace
Terminal window
mtr google.com

Traces the route to the website “google.com” showing the network hops and latency.

Terminal window
mtr 8.8.8.8

Traces the route to the specific IP address “8.8.8.8” displaying network statistics.

Terminal window
mtr -i 5 google.com

Traces the route to “google.com” with an interval of 5 seconds between packets.

Terminal window
mtr -c 10 google.com

Traces the route to “google.com” sending 10 packets before terminating.

Terminal window
mtr -n -r google.com

Traces the route to “google.com” without DNS resolution but showing IP addresses.

Terminal window
mtr -r --report google.com

Traces the route to “google.com” showing the percentage of packet loss.

Trace the Route with Specific TCP/UDP Port

Section titled “Trace the Route with Specific TCP/UDP Port”
Terminal window
mtr --port 80 google.com

Traces the route to “google.com” using port 80 for both TCP and UDP.

Terminal window
mtr google.com > trace_output.txt

Traces the route to “google.com” and saves the output to a file named “trace_output.txt”.

To use the mtr command in Linux, execute the following command:

Terminal window
mtr --report google.com

How do I specify the number of packets to send with mtr in Linux?

Section titled “How do I specify the number of packets to send with mtr in Linux?”

To specify the number of packets to send with mtr in Linux, use the -c option followed by the number of packets. For example:

Terminal window
mtr -c 10 google.com

How can I set an interval between packets in mtr in Linux?

Section titled “How can I set an interval between packets in mtr in Linux?”

To set an interval between packets in mtr in Linux, use the -i option followed by the interval time in seconds. Here is an example:

Terminal window
mtr -i 1 google.com

How do I resolve hostnames to IP addresses in mtr in Linux?

Section titled “How do I resolve hostnames to IP addresses in mtr in Linux?”

To resolve hostnames to IP addresses in mtr in Linux, use the -n option. This option prevents hostname resolution. For example:

Terminal window
mtr -n google.com

How can I specify a custom port in mtr in Linux?

Section titled “How can I specify a custom port in mtr in Linux?”

To specify a custom port in mtr in Linux, use the -P option followed by the port number. Here’s an example:

Terminal window
mtr -P 443 google.com

How do I display AS numbers in mtr in Linux?

Section titled “How do I display AS numbers in mtr in Linux?”

To display AS (Autonomous System) numbers in mtr output in Linux, use the -z option. This will show the AS path to the destination. For example:

Terminal window
mtr -z google.com

How can I change the display mode of mtr in Linux?

Section titled “How can I change the display mode of mtr in Linux?”

To change the display mode of mtr in Linux, use the -t option followed by the desired mode. You can choose from ‘normal’, ‘raw’, or ‘json’. Here’s an example:

Terminal window
mtr -t raw google.com

How do I set a specific timeout for mtr in Linux?

Section titled “How do I set a specific timeout for mtr in Linux?”

To set a specific timeout for mtr in Linux, use the -w option followed by the timeout value in seconds. For example:

Terminal window
mtr -w 2 google.com

How can I specify the network interface to use with mtr in Linux?

Section titled “How can I specify the network interface to use with mtr in Linux?”

To specify the network interface to use with mtr in Linux, use the -i option followed by the interface name. Here’s an example:

Terminal window
mtr -i eth0 google.com
  • Network diagnostics
  • Analyzing network latency
  • Identifying packet loss
  • Traceroute functionality with continuous monitoring
  • Identifying network congestion
  • Troubleshooting network issues
  • Monitoring network performance