This guide will teach you how to use MTR (My Traceroute) and Traceroute to diagnose network connectivity issues, identify latency points, and analyze the quality of your network connection.
📋 Prerequisites
- A VPS server with root or sudo access
- An active SSH connection
- Ubuntu/Debian (commands are adapted for these distributions)
🔧 Installation
Install Traceroute (basic tool)
Bash# On Ubuntu/Debian sudo apt update sudo apt install traceroute -y
Install MTR (advanced tool)
MTR combines the functionalities of ping and traceroute into a single powerful tool.
Bash1# On Ubuntu/Debian 2sudo apt update 3sudo apt install mtr-tiny -y 4 5# For the full version with graphical interface (optional) 6sudo apt install mtr -y
Verify Installation
Bash1# Verify that traceroute is installed 2traceroute --version 3 4# Verify that MTR is installed 5mtr --version
🛠️ Using Traceroute
Basic Command
Bash1# Traceroute to a destination 2traceroute google.com 3 4# Traceroute to an IP 5traceroute 8.8.8.8 6 7# Limit the number of hops (default 30) 8traceroute -m 20 google.com 9 10# Specify timeout in seconds 11traceroute -w 5 google.com
Useful Options
Bash1# Use UDP (default) 2traceroute -U google.com 3 4# Use TCP (more reliable) 5traceroute -T google.com 6 7# Use ICMP (like ping) 8traceroute -I google.com 9 10# Don't resolve DNS names (faster) 11traceroute -n google.com
Example Output
traceroute to google.com (142.250.185.14), 30 hops max, 60 byte packets
1 10.0.0.1 (10.0.0.1) 0.123 ms 0.089 ms 0.067 ms
2 192.168.1.1 (192.168.1.1) 5.234 ms 5.189 ms 5.145 ms
3 * * *
4 8.8.8.8 (8.8.8.8) 12.456 ms 12.389 ms 12.334 ms
...
🚀 Using MTR (Recommended)
MTR is more powerful because it sends packets continuously and calculates statistics in real-time.
Basic Command
Bash1# MTR in interactive mode (recommended) 2mtr google.com 3 4# MTR with report (non-interactive) 5mtr --report google.com 6 7# MTR with 10 test packets 8mtr --report --report-cycles 10 google.com 9 10# MTR to an IP 11mtr --report 8.8.8.8
Advanced Options
Bash1# Specify the number of packets to send 2mtr --report --report-cycles 50 google.com 3 4# Use TCP instead of ICMP 5mtr --tcp --port 80 google.com 6 7# Use UDP 8mtr --udp --port 53 8.8.8.8 9 10# Don't resolve DNS names 11mtr --no-dns google.com 12 13# Interval between packets (in seconds) 14mtr --interval 2 google.com 15 16# Packet size (in bytes) 17mtr --psize 64 google.com
MTR Interactive Mode
When you launch mtr without the --report option, you enter interactive mode:
- d : Show/hide detailed statistics
- n : Enable/disable DNS mode (name resolution)
- r : Reset statistics
- s : Change packet size
- j : Change interval between packets
- q : Quit MTR
📊 Interpreting Results
Normal Latency
- < 50 ms : Excellent, local network or very close
- 50-100 ms : Good, regional connection
- 100-200 ms : Acceptable, intercontinental connection
- > 200 ms : High, may cause problems
Packet Loss
- 0% : Perfect
- < 1% : Normal for an Internet connection
- 1-5% : Acceptable but may cause problems
- > 5% : Problematic, investigation required
Meaning of Asterisks (*)
In traceroute, a * means:
- A single * instead of a time : The router did not respond to that specific packet
- *Three consecutive 's : The router did not respond at all (timeout or firewall filter)
🎯 Use Cases
Diagnosing High Latency
Bash1# Test to Google DNS 2mtr --report --report-cycles 30 8.8.8.8 3 4# Test to Cloudflare DNS 5mtr --report --report-cycles 30 1.1.1.1 6 7# Identify the problematic hop 8mtr --report --report-cycles 50 your-domain.com
Diagnosing Packet Loss
Bash1# Test with TCP to bypass ICMP filters 2mtr --tcp --port 443 --report --report-cycles 50 google.com 3 4# Test to a specific server 5mtr --report --report-cycles 100 your-server.com
Test from Your VPS to Your Location
Bash1# Test to your public IP address 2# Get your public IP first 3curl ifconfig.me 4 5# Then test from your VPS 6mtr --report --report-cycles 30 YOUR_PUBLIC_IP
🔍 Troubleshooting Common Problems
Problem: High Latency on a Specific Hop
If you see high latency on an intermediate hop:
Bash# Test with different protocols mtr --tcp --port 443 --report google.com mtr --udp --port 53 --report 8.8.8.8 mtr --report google.com
Important: High latency on an intermediate hop may be normal if that router doesn't respond quickly to diagnostic requests, but the final latency remains good.
Problem: Significant Packet Loss
If you see high packet loss:
Bash1# Test with more packets to confirm 2mtr --report --report-cycles 100 destination.com 3 4# Test with TCP if ICMP is filtered 5mtr --tcp --port 80 --report --report-cycles 50 destination.com
Warning: If packet loss appears on all hops, the problem is likely on your VPS or your local connection. If it appears only on a specific hop, the problem is on the network between your VPS and the destination.
Problem: Repeated Timeouts
Bash1# Increase timeout 2mtr --timeout 10 --report destination.com 3 4# Test with different protocols 5mtr --tcp --port 443 --timeout 10 --report destination.com
📝 Useful Commands
Complete Diagnostic Script
Create a script to test multiple destinations:
Bash1#!/bin/bash 2echo "=== MTR Test to Google DNS ===" 3mtr --report --report-cycles 30 8.8.8.8 4 5echo -e "\n=== MTR Test to Cloudflare DNS ===" 6mtr --report --report-cycles 30 1.1.1.1 7 8echo -e "\n=== MTR Test to your domain ===" 9mtr --report --report-cycles 30 your-domain.com
Save Results
Bash1# Save report to a file 2mtr --report --report-cycles 30 google.com > mtr-report-$(date +%Y%m%d).txt 3 4# With CSV format 5mtr --report --report-cycles 30 --csv google.com > mtr-report.csv
✅ Best Practices
- Use MTR rather than traceroute : MTR provides more complete statistics
- Test multiple destinations : Compare results to different servers
- Run multiple tests : Networks can vary, run multiple tests at different times
- Use TCP if ICMP is filtered : Some routers filter ICMP but not TCP
- Interpret results correctly : High latency on an intermediate hop is not always a problem if the final latency is good
🆘 Troubleshooting
MTR Doesn't Display Correctly
Bash1# If MTR doesn't work in interactive mode, use report mode 2mtr --report destination.com 3 4# Check MTR version 5mtr --version
Error "mtr: command not found"
Bash1# Reinstall MTR 2sudo apt update 3sudo apt install mtr-tiny -y 4 5# Or install the full version 6sudo apt install mtr -y
All Results Show Asterisks
If all hops show *, it may mean:
Bash1# Your firewall is blocking ICMP 2# Test with TCP instead 3mtr --tcp --port 443 --report destination.com 4 5# Check firewall rules 6sudo ufw status 7sudo iptables -L
📚 Additional Resources
❓ Frequently Asked Questions
Q: What is the difference between Traceroute and MTR?
A: Traceroute sends a few packets and displays results. MTR sends packets continuously and calculates statistics in real-time, which is more useful for diagnosis.
Q: Why do some hops show asterisks?
A: This means the router did not respond. This can be due to a firewall filter, router configuration, or simply that the router doesn't respond to diagnostic requests.
Q: Should I worry about high latency on an intermediate hop?
A: Not necessarily. If the final latency to the destination is good, high latency on an intermediate hop may be normal. It's the final latency that really matters.
Q: How do I interpret packet loss in MTR?
A: Packet loss < 1% is normal. Between 1-5%, it's acceptable but may cause problems. Beyond 5%, it's problematic and requires investigation.