How to Install Traceroute: Guide with apt install traceroute
Introduction
Ever wondered why your internet connection feels slow or why you can't reach a specific website? If you're running Ubuntu or Debian, there's a handy tool called traceroute that can help you figure out exactly what's going on with your network connection.
Traceroute is like a GPS tracker for your internet data. It shows you the exact path your data takes from your computer to its destination, revealing every stop along the way. Pretty cool, right? The best part is that installing it on your Linux system is super easy with just one simple command: apt install traceroute
.
In this guide, I'll walk you through everything you need to know about installing and using traceroute on Ubuntu and Debian systems. Whether you're a complete beginner or just need a quick refresher, I've got you covered.

What is Traceroute?
Think of traceroute as a detective tool for your internet connection. When you send data from your computer to a website, it doesn't just magically appear there instantly. Instead, it hops through multiple servers and routers across the internet, kind of like how a letter passes through different post offices before reaching its destination.
Traceroute reveals this entire journey. It shows you:
- Each "hop" or stop your data makes
- How long each hop takes
- The IP addresses of the servers handling your data
This is different from the ping command, which only tells you if you can reach a destination and how long it takes. Traceroute gives you the full story of what happens behind the scenes.
System Requirements
Before we jump into the installation, let's make sure you have everything you need:
Supported Systems:
- Ubuntu (all recent versions)
- Debian (all recent versions)
- Linux Mint
- Other Debian-based distributions
What You'll Need:
- Administrator privileges (sudo access)
- An active internet connection
- A terminal or command line interface
Don't worry if you're not super comfortable with the command line – the process is straightforward, and I'll explain each step clearly.
Installation Steps
Ready to install traceroute? Here's how to do it in three simple steps:
Step 1: Update Your Package List
First, let's make sure your system has the latest information about available packages:
sudo apt update
This command refreshes your system's package database. It's like updating your phone's app store to see the latest available apps.
Step 2: Install Traceroute
Now for the main event – installing traceroute:
sudo apt install traceroute
That's it! The system will download and install traceroute automatically. You might see some text scrolling by as it works – that's totally normal.
Step 3: Verify the Installation
Let's make sure everything installed correctly:
traceroute --version
If you see version information displayed, congratulations! Traceroute is now installed and ready to use.
Basic Usage
Now that traceroute is installed, let's learn how to use it. The basic syntax is simple:
traceroute [options] destination
The destination can be either a website name (like google.com) or an IP address. Here are some common options you might find useful:
-n
: Show IP addresses instead of hostnames (faster)-w
: Set timeout for each hop-m
: Set maximum number of hops
Most of the time, you'll just use the basic command without any special options.
Practical Examples
Let's try some real-world examples to see traceroute in action:
Example 1: Trace Route to Google
traceroute google.com
This will show you the path your data takes to reach Google's servers. You'll see something like:
traceroute to google.com (142.250.191.14), 30 hops max, 60 byte packets
1 192.168.1.1 (192.168.1.1) 2.345 ms 2.123 ms 2.456 ms
2 10.0.0.1 (10.0.0.1) 15.234 ms 14.567 ms 15.123 ms
3 203.0.113.1 (203.0.113.1) 25.678 ms 24.890 ms 25.123 ms
...
Each line represents a "hop" in your data's journey. The three time measurements show how long each attempt took (traceroute tries three times for accuracy).
Example 2: Using IP Address
traceroute 8.8.8.8
This traces the route to Google's DNS server using its IP address directly.
Example 3: Faster Results with -n Option
traceroute -n google.com
This skips the hostname lookup process, giving you results faster by showing only IP addresses.
Troubleshooting Common Issues
Sometimes things don't go as planned. Here are the most common issues and how to fix them:
Permission Problems
Error: "traceroute: command not found"
Solution: Make sure you installed traceroute correctly using sudo apt install traceroute
Network Connection Issues
Error: "Network is unreachable"
Solution: Check your internet connection first. Try pinging a simple address like ping 8.8.8.8
Firewall Blocking
Error: Timeouts or asterisks (***) in results Solution: Some firewalls block traceroute packets. This is normal for certain networks, especially corporate ones.
Alternative Tools
If traceroute isn't working for you, try these alternatives:
-
tracepath: Usually pre-installed on most Linux systems
tracepath google.com
-
mtr: A more advanced tool that combines ping and traceroute
sudo apt install mtr mtr google.com
Advanced Usage
Once you're comfortable with the basics, here are some advanced features:
Understanding the Output
When you run traceroute, each line tells you:
- Hop number: The step in the journey
- Router name/IP: The server handling your data
- Response times: Three measurements in milliseconds
Useful Parameters
-I
: Use ICMP packets instead of UDP (sometimes works better)-T
: Use TCP packets (good for troubleshooting web connections)-p
: Specify a port number
Combining with Other Tools
Traceroute works great with other network tools:
# First, see if you can reach the destination
ping -c 4 google.com
# Then trace the route
traceroute google.com
# For continuous monitoring
mtr google.com
Frequently Asked Questions (FAQ)
Q: Do I need to install traceroute on all Linux systems?
A: Not necessarily! Some Linux distributions come with traceroute pre-installed. You can check if it's already available by typing traceroute --version
in your terminal. If you get a "command not found" error, then you'll need to install it using apt install traceroute
.
Q: What's the difference between traceroute and tracepath?
A: Great question! Both tools do similar things, but tracepath is usually pre-installed on most Linux systems and doesn't require root privileges. Traceroute is more feature-rich and gives you more control over the tracing process. If you just need basic route tracing, tracepath might be sufficient. For advanced network diagnostics, traceroute is the better choice.
Q: Why do I see asterisks (***) in my traceroute results?
A: Those asterisks mean that particular router didn't respond within the timeout period. This is totally normal and doesn't necessarily indicate a problem. Some routers are configured not to respond to traceroute packets for security reasons. Your data is still getting through – you just can't see that particular hop.
Q: Can I use traceroute without sudo?
A: Yes and no. The basic traceroute
command usually requires sudo privileges because it needs to send special network packets. However, you can use traceroute -T
(TCP mode) or tracepath
without sudo in most cases. Some modern systems also allow regular users to run traceroute without sudo.
Q: How long should I wait for traceroute to complete?
A: Most traceroute commands finish within 30-60 seconds. If it's taking much longer, you can press Ctrl+C to stop it. Some destinations might be unreachable or heavily firewalled, causing longer delays.
Q: What does "30 hops max" mean in the output?
A: This means traceroute will try up to 30 different routers/servers before giving up. Most destinations are reachable within 10-15 hops. If you need to trace further, you can increase this limit with the -m
option: traceroute -m 50 google.com
.
Q: Is it normal for traceroute to show different paths each time?
A: Absolutely! Internet routing is dynamic, and your data might take different paths depending on network conditions, load balancing, or routing changes. This is actually a feature of the internet that helps ensure reliability and performance.
Q: Can I save traceroute results to a file?
A: Yes! You can redirect the output to a file like this:
traceroute google.com > traceroute_results.txt
Or to see the results on screen and save them simultaneously:
traceroute google.com | tee traceroute_results.txt
Q: Why is my first hop always my router?
A: That's completely normal! The first hop is almost always your local router or gateway (usually something like 192.168.1.1 or 10.0.0.1). This is the device that connects your home network to the internet.
Q: What should I do if traceroute shows high latency at a specific hop?
A: High latency at one hop might indicate network congestion or a slow router. However, don't panic immediately – sometimes individual routers are configured to deprioritize traceroute packets. Look at the overall pattern and the final destination times to get a better picture.
Q: Can I use traceroute to test my own website?
A: Definitely! This is actually a great way to understand how visitors reach your website. Just run traceroute yourdomain.com
to see the path from your location to your server.
Q: Does traceroute work with IPv6 addresses?
A: Yes! For IPv6 addresses, use traceroute6
instead of traceroute
. You might need to install it separately with sudo apt install traceroute6
on some systems.
Q: What's the difference between the three time measurements?
A: Traceroute sends three packets to each hop and measures the response time for each one. The three numbers represent the round-trip time for each packet in milliseconds. This gives you a better idea of consistency – if the times vary wildly, there might be network instability.
Q: Can I trace routes to local network devices?
A: Yes! You can use traceroute to trace paths to devices on your local network. For example, traceroute 192.168.1.100
will show the path to a device on your home network.
Q: Is traceroute safe to use?
A: Absolutely! Traceroute is a standard network diagnostic tool that's completely safe to use. It only sends small test packets to map the route – it doesn't access, modify, or harm any systems along the way.