Operations 10 min read

Mastering Linux Network Diagnostics: A Deep Dive into the mtr Command

Learn how the powerful mtr (My Traceroute) tool combines traceroute and ping to dynamically trace network paths, display latency and packet loss, interpret its detailed output, and use various command‑line options for reporting, filtering, and installation on Linux systems.

Open Source Linux
Open Source Linux
Open Source Linux
Mastering Linux Network Diagnostics: A Deep Dive into the mtr Command

Linux Network Diagnostic Tool mtr Command Explained

1. Overview of mtr

MTR (My Traceroute) is a powerful network diagnostic tool that combines the functionality of traceroute and ping. It sends ICMP or UDP packets to test network connectivity and displays each router along the path with real‑time response times.

The tool is valuable for network engineers and system administrators to identify latency, packet loss, and overall connection quality.

2. Features of mtr

1. Dynamic routing display

Unlike traditional traceroute, MTR continuously updates the path status, making it useful for detecting transient network issues.

2. Packet type

By default MTR sends UDP packets, but it can be configured to use ICMP Echo requests (similar to ping).

3. Latency and loss display

MTR shows round‑trip time (RTT) for each hop and marks hops where packets are lost.

4. Filtering and logging

Users can apply filters to focus on specific routers or network segments and can save diagnostic results to log files.

5. Network probing

MTR can operate over different protocols and ports to suit various testing needs.

3. Basic usage

1. Syntax

Run mtr target where target is a domain name or IP address.

2. Help

Display help with mtr --help.

3. Common options

-r

: report mode – send a specified number of packets and then stop (e.g., -r 10). -c: continuous mode – send a specified number of packets repeatedly. -i: interval between packets in seconds (default 1). -s: packet size in bytes (default 50). -u: use UDP instead of ICMP. -P: set ICMP type (default type 8 echo request).

4. Output interpretation

1. Typical columns

Host – IP address or hostname of the hop.

Loss% – packet loss percentage at the hop.

Snt – number of packets sent.

Last – RTT of the most recent packet.

Avg – average RTT.

Best – minimum RTT.

Wrst – maximum RTT.

StDev – standard deviation of RTT.

5. Command examples

1. Basic test

mtr www.example.com

2. Report mode

mtr -r www.example.com

3. Set interval

mtr -w 1 www.example.com

4. Show IPs only

mtr -d www.example.com

5. Specify packet count

mtr -c 10 www.example.com

6. Disable DNS resolution

mtr -n 8.8.8.8

7. Change packet size

mtr -s 1500 www.example.com

8. Use UDP

mtr -u www.example.com

9. Save output to file

mtr www.example.com > mtr_output.txt

10. Batch mode

mtr -b www.example.com > output.txt

11. Combine options

mtr -s 100 -p 80 www.example.com

(packet size 100 bytes, test port 80).

6. Installing mtr

1. apt (Debian/Ubuntu)

sudo apt-get install mtr

2. yum (Red Hat/CentOS)

sudo yum install mtr
[root@ecs-52a1 /]# mtr --h
bash: mtr: command not found
[root@ecs-52a1 /]# sudo yum install mtr
...
Complete!
[root@ecs-52a1 /]# mtr --h
usage: mtr [-BfhvrwctglxspQomniuT46] [--help] [--version] ... HOSTNAME
pingtracerouteMTRNetwork Diagnostics
Open Source Linux
Written by

Open Source Linux

Focused on sharing Linux/Unix content, covering fundamentals, system development, network programming, automation/operations, cloud computing, and related professional knowledge.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.