$devvkit learn --librarie mtr-guide
MTR Guide
[networking][traceroute][latency][cli]
Network Diagnostics
Install
sudo apt install mtr brew install mtr # Windows: WinMTR (GUI) or WSL # macOS: brew install mtr
MTR (My TraceRoute) continuously probes each hop along a network path and reports packet loss and latency statistics per hop. Unlike a single traceroute, MTR runs for many cycles and aggregates stats, making transient packet loss visible.
Use `-r` for report mode (single shot with 10 cycles by default), `-c` to control cycle count, `-n` to skip DNS resolution, `-i` for interval between probes. The default protocol is ICMP; use `-T` for TCP and `-u` for UDP probes.
Packet loss at the first hop usually means your local network/modem issue. Loss only at later hops often means those intermediate routers are rate-limiting ICMP. Loss at the final hop that persists with TCP mode indicates actual network problems.
Basic
Continuous view— Live TUI display.
mtr example.com mtr 8.8.8.8 mtr -n 8.8.8.8 # No DNS (faster) mtr -4 8.8.8.8 # Force IPv4 mtr -6 google.com # Force IPv6
Report Mode
Report mode— Single-shot output.
mtr -r 8.8.8.8 # 10 cycles, then print & exit mtr -r -c 100 8.8.8.8 # 100 cycles mtr -r -c 100 -n 8.8.8.8 # No DNS, 100 cycles mtr -r -c 300 -i 0.5 8.8.8.8 # 300 cycles, 0.5s interval
CSV output— Machine-readable.
mtr -r -c 50 -n --csv 8.8.8.8 > mtr.csv
# Columns: host, loss%, sent, last, avg, best, worst, stddev
mtr -r -c 50 -n --json 8.8.8.8 | jq '.report.hubs[] | {host, loss: .Loss, avg: .Avg}'
mtr -r -c 50 -n --xml 8.8.8.8 > mtr.xmlProtocol Selection
TCP mode— Use TCP SYN instead of ICMP.
sudo mtr -T example.com -P 443 # TCP to port 443 sudo mtr -T -n 1.1.1.1 -P 853 # TCP to DNS-over-TLS port # TCP mode bypasses ICMP rate-limiting on many routers
UDP mode— UDP probes.
sudo mtr -u example.com -P 53 # UDP to DNS port sudo mtr -u -n 8.8.8.8 -P 443 # Some networks treat UDP differently from ICMP/TCP
Advanced
Bandwidth test— Use MTR bandwidth mode.
sudo mtr --report-wide example.com # Wide columns sudo mtr --show-ips 8.8.8.8 # Show IPs per hop sudo mtr --order "L SR DR" 8.8.8.8 # Custom column order
Compare paths— Check multiple routes.
# Run two MTRs simultaneously to compare paths: mtr -r -n -c 30 1.1.1.1 > cloudflare.log & mtr -r -n -c 30 8.8.8.8 > google.log & wait diff cloudflare.log google.log # Also useful: check if traffic takes expected route mtr -r -n -c 10 vpn-gateway.company.com
Trick: detect throttling— Spot traffic shaping.
mtr -r -c 100 -n --report-wide your-server.com # Look for: sudden packet loss at one hop but not later hops # = that hop is rate-limiting ICMP, not actual packet loss # Confirm with TCP mode: mtr -T -r -c 100 -n your-server.com # If TCP shows no loss → it's just ICMP shaping