0
0
Linux CLIscripting~5 mins

traceroute for path tracing in Linux CLI - Commands & Configuration

Choose your learning style9 modes available
Introduction
Sometimes you want to see the path your internet data takes to reach a website or server. traceroute helps you find each step your data travels through, showing where delays or problems happen.
When your website is slow and you want to see which server or router is causing the delay
When you want to check if your connection to a remote server is working properly
When you need to understand the route your data takes across the internet for troubleshooting
When you want to verify if your network traffic is going through expected locations
When you are learning how internet routing works by seeing real paths
Commands
This command starts tracing the path from your computer to example.com, showing each step along the way.
Terminal
traceroute example.com
Expected OutputExpected
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.123 ms 0.987 ms 1.045 ms 2 10.10.10.1 (10.10.10.1) 10.234 ms 10.456 ms 10.678 ms 3 203.0.113.1 (203.0.113.1) 20.345 ms 20.567 ms 20.789 ms 4 198.51.100.1 (198.51.100.1) 30.123 ms 30.345 ms 30.567 ms 5 93.184.216.34 (93.184.216.34) 40.123 ms 40.345 ms 40.567 ms
-m - Set the maximum number of hops traceroute will try
-w - Set the time to wait for a response from each probe
This command limits the trace to 5 hops to avoid long output if the destination is far away.
Terminal
traceroute -m 5 example.com
Expected OutputExpected
traceroute to example.com (93.184.216.34), 5 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.123 ms 0.987 ms 1.045 ms 2 10.10.10.1 (10.10.10.1) 10.234 ms 10.456 ms 10.678 ms 3 203.0.113.1 (203.0.113.1) 20.345 ms 20.567 ms 20.789 ms 4 198.51.100.1 (198.51.100.1) 30.123 ms 30.345 ms 30.567 ms 5 93.184.216.34 (93.184.216.34) 40.123 ms 40.345 ms 40.567 ms
-m - Limits the maximum hops to trace
This command sets the wait time for each response to 2 seconds, useful if some hops are slow to respond.
Terminal
traceroute -w 2 example.com
Expected OutputExpected
traceroute to example.com (93.184.216.34), 30 hops max, 60 byte packets 1 192.168.1.1 (192.168.1.1) 1.123 ms 0.987 ms 1.045 ms 2 10.10.10.1 (10.10.10.1) 10.234 ms 10.456 ms 10.678 ms 3 203.0.113.1 (203.0.113.1) 20.345 ms 20.567 ms 20.789 ms 4 198.51.100.1 (198.51.100.1) 30.123 ms 30.345 ms 30.567 ms 5 93.184.216.34 (93.184.216.34) 40.123 ms 40.345 ms 40.567 ms
-w - Sets the wait time for each probe response
Key Concept

If you remember nothing else from traceroute, remember: it shows each step your data takes to reach a destination, helping find where delays or problems happen.

Common Mistakes
Running traceroute without root or sudo on some systems
Traceroute may fail or show incomplete results because it needs permission to send certain packets.
Run traceroute with sudo if needed, like 'sudo traceroute example.com', or use options that don't require root.
Using traceroute on a destination that blocks ICMP or UDP packets
Some servers or firewalls block traceroute packets, causing timeouts or missing hops.
Try using traceroute with TCP mode (if supported) or check connectivity with other tools like ping.
Ignoring the maximum hops limit and getting very long output
Traceroute can produce too much output if the path is long, making it hard to read.
Use the -m flag to limit hops, for example 'traceroute -m 10 example.com'.
Summary
Use 'traceroute example.com' to see the path your data takes to reach example.com.
Use flags like -m to limit the number of hops and -w to set wait time for responses.
Run traceroute with proper permissions and be aware some servers may block traceroute packets.