mtr (My Traceroute)¶
Installation:
# Debian/Ubuntu
sudo apt-get install mtr
# CentOS/RHEL
sudo yum install mtr
# macOS
brew install mtr
Basic Usage:
# Interactive mode
mtr [ hostname ]
# Report mode (run N cycles and exit)
mtr --report --report-cycles 10 [ hostname ]
# No DNS resolution
mtr -n [ hostname ]
# TCP mode (instead of ICMP)
mtr --tcp [ hostname ]
# UDP mode
mtr --udp [ hostname ]
# Specify port
mtr --tcp --port 443 [ hostname ]
# Wide report
mtr --report-wide [ hostname ]
Advanced Usage:
# CSV output
mtr --csv [ hostname ]
# JSON output
mtr --json [ hostname ]
# XML output
mtr --xml [ hostname ]
# Continuous with interval
mtr --interval 1 [ hostname ]
# Set packet size
mtr --psize 1000 [ hostname ]
# Set max TTL
mtr --max-ttl 20 [ hostname ]
# Both directions (requires cooperation)
mtr --both [ hostname ]
Reading mtr Output:
My traceroute [v0.95]
host ([ ip_address ]) 2024-02-15T20:00:00+0000
Keys: Help Display mode Restart statistics Order of fields quit
Packets Pings
Host Loss% Snt Last Avg Best Wrst StDev
1. [ ip_address ] 0.0% 10 1.2 1.3 1.1 1.8 0.2
2. [ ip_address ] 0.0% 10 8.5 8.7 8.3 9.2 0.3
3. [ ip_address ] 10.0% 10 12.3 12.5 12.1 13.5 0.4
4. [ ip_address ] 0.0% 10 15.2 15.4 15.0 16.1 0.3
Key Columns:
- Loss%: Packet loss at this hop
- Snt: Packets sent
- Last: Last RTT
- Avg: Average RTT
- Best: Best RTT
- Wrst: Worst RTT
- StDev: Standard deviation (jitter)
Use Cases:
```bash
Find where packet loss occurs¶
mtr --report --report-cycles 100 [ hostname ]
Trace to specific port¶
mtr --tcp --port 443 [ hostname ]
Save report to file¶
mtr --report --report-cycles 50 [ hostname ] > [ hostname ]
Monitor continuously¶
mtr --interval 1 --curses [ hostname ]
Quick 10-cycle report¶
mtr -r -c 10 [ hostname ]