Mastering mtr: Advanced Network Diagnostics on Linux

Overview

When network bottlenecks, jitter, or intermittent dropouts occur, isolating root causes using standard ping and traceroute independently often produces disjointed results. By unifying continuous reachability testing with hop-by-hop route discovery, mtr acts as an indispensable troubleshooting utility for systems administrators. Rather than sifting through extensive man documentation, this tutorial walks through practical flag combinations and automated reporting techniques directly on Ubuntu.

Installing mtr and Running Initial Baseline Diagnostics

Before initiating diagnostic runs, update the package repository cache and install mtr-tiny, a lightweight build stripped of graphical dependencies that is ideal for server consoles.

Installing mtr-tiny via apt

Verify the operational readiness of the utility by inspecting its installed binary release version.
⚙️ [Primary Command Options]

-c, --report-cycles : Sets the total count of probe rounds dispatched per transit hop in report mode.
-r, --report : Generates a static tabular summary upon completion instead of launching the interactive curses interface.
-w, --report-wide : Prevents hostname truncation, preserving full domain visibility across all hops.
-n, --no-dns : Disables reverse DNS lookups, presenting intermediate nodes strictly as raw IP addresses.
-b, --show-ips : Displays discovered hostnames alongside their respective numeric IP addresses simultaneously.
-u, --udp : Substitutes default ICMP ECHO packets with UDP datagrams to map upstream transit paths.
-T, --tcp : Sends TCP SYN segments to probe specific listening ports and inspect stateful firewall boundaries.
-p, --port : Designates the destination port number when operating in TCP or UDP modes.
-i, --interval : Configures the wait interval between successive probing bursts in seconds.
-4 : Restricts routing traversal solely to the IPv4 address family.
-6 : Constrains all diagnostic packets strictly to the IPv6 protocol stack.

Checking installed mtr version

Launch a baseline diagnostic against Google Public DNS (8.8.8.8), sending 5 packets per hop to compile average transit delays and drop rates into a clean summary table.
Intermediary hops displaying ??? indicate filtering routers or upstream edge appliances that explicitly discard ICMP transit replies. Even with non-responsive hops present, latency trends and overall drop ratios all the way to dns.google remain clear and measurable.

Running mtr report mode against Google DNS

Leveraging Report Summaries and Disabling Reverse DNS Lookups

Dispatching 10 probe cycles toward Cloudflare DNS (1.1.1.1) via -c 10 produces a stabilized latency profile.
Increasing probe counts filters out transitory traffic spikes, yielding highly reliable calculations for mean latency (Avg) and per-hop failure rates (Loss%).

Generating a 10-cycle diagnostic report for Cloudflare DNS

Target Google’s secondary resolver (8.8.4.4) across 5 iterations while appending --no-dns to suppress reverse PTR queries.
Omitting nameserver resolution avoids external lookups completely, printing numerical IP paths immediately and preventing DNS timeouts from clouding the analysis.

Bypassing reverse DNS lookups during route tracing

Path Tracing Across Specific TCP and UDP Service Ports

Trace the network route toward Google’s web endpoint (google.com) by combining --tcp with --port 443 to emulate legitimate HTTPS client connections.
Because perimeter security hardware frequently filters traditional ICMP messages, evaluating latency over actual web application ports exposes true service reachability and real-world packet delivery.

Probing network routes using TCP port 443

Route diagnostic datagrams toward Cloudflare (1.1.1.1) using --udp across standard DNS --port 53.
Evaluating the UDP layer directly assists in discovering upstream stateful firewall rules and highlighting packet drop issues impacting name resolution services.

Probing routes with UDP datagrams targeting port 53

Archiving Diagnostic Output and Structuring JSON Exports

Construct an isolated workspace to organize and archive network diagnostic files, then switch into that directory.

Creating and entering the network testing directory

Send 5 probe iterations toward Google DNS (8.8.8.8) using --raw to capture unparsed measurement records into a plain text file (mtr_raw_output.txt).
These low-level packet timestamps and hop status codes provide ideal source material for custom downstream analytics scripts and log ingestors.

Dumping raw mtr metrics to a text file

Query Cloudflare DNS (1.1.1.1) across 3 cycles while applying the --json option to record structured diagnostic telemetry directly into mtr_report.json.
Emitting structured data enables seamless integration into automated alert pipelines, log collectors, and monitoring dashboards.

Exporting mtr test results in JSON formatting

Review the initial 20 entries of mtr_report.json with head -n 20 to verify schema integrity.
The parsed document encapsulates source and destination configurations alongside detailed transit hubs, documenting domain identifiers, latency figures, and packet loss metrics (Loss%) within valid JSON arrays.

Inspecting structured JSON network reports

By fusing the continuous responsiveness of ping with the hop-level visibility of traceroute, mtr delivers comprehensive insight into upstream carrier paths and infrastructure health. Integrating these command patterns into everyday maintenance workflows empowers teams to pinpoint routing anomalies and intermittent loss with exceptional speed.