Skip to content
Tutorials Center
My learning

Topics

Linux Command Reference ยท Networking

Linux traceroute command

Reference for the Linux traceroute command: how TTL probes reveal each hop, UDP, ICMP and TCP modes, reading the output, and tracepath and mtr alternatives.

traceroute shows the path your packets take to a destination, one router (hop) at a time, with the round-trip time to each. It is the tool to reach for when a connection is slow or dead and you want to know where along the way things go wrong.

It works by sending probe packets with a small TTL (time to live). Every router decrements the TTL; the one that sees it hit zero throws the packet away and sends back an ICMP "time exceeded" message, which reveals its address. traceroute starts with TTL 1, then 2, then 3, and so on, until the destination answers.

Terminal
traceroute [OPTIONS] HOST

Try it

traceroute is not installed in our sandbox and there is no network, so this block is read-only:

CONSOLE
$ traceroute -n example.org
traceroute to example.org (93.184.215.14), 30 hops max, 60 byte packets
 1  192.168.1.1     1.021 ms  0.894 ms  0.870 ms
 2  10.20.0.1       8.312 ms  8.290 ms  8.275 ms
 3  * * *
 4  203.0.113.9    14.870 ms 15.112 ms 14.964 ms
 5  93.184.215.14  21.442 ms 21.380 ms 21.401 ms

The idea behind it, a counter that runs down at each step, can be shown in plain Bash:

Bash The TTL idea, simulated

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

Syntax

Terminal
traceroute [-n] [-I | -T | -U] [-m MAX_TTL] [-q QUERIES] [-w SECONDS] [-p PORT] [-i IFACE] [-s SRC] HOST [PACKET_LEN]
Option Description
-n Do not resolve addresses to names (much faster, and clearer).
-I Send ICMP echo requests instead of UDP datagrams.
-T Send TCP SYN packets (default port 80); good for firewalls that block UDP and ICMP.
-U Use UDP (the default) to a high port.
-p PORT Destination port (UDP and TCP modes).
-m N Maximum number of hops (default 30).
-q N Probes per hop (default 3).
-w SECONDS How long to wait for each reply.
-f N Start at hop N instead of 1.
-i IFACE, -s ADDR Choose the outgoing interface or source address.
-4, -6 Force IPv4 or IPv6.

Output: one line per hop: hop number, address (or name), and three round-trip times. * * * means no reply arrived.

Returns: 0 on success; the tool does not use the exit status to say whether the destination was reached.

Usage notes

  • Stars are not always faults. Many routers deprioritise or block the ICMP replies, so a hop can show * * * while traffic passes through it fine. Trouble is real when the stars continue until the end.
  • Latency per hop is rough. A slow middle hop followed by fast later hops usually means that router answers probes slowly, not that traffic is slow.
  • Paths are one-way. The route back can be different from the route out.
  • Modes matter. If plain traceroute stops early, try -I (ICMP) or -T -p 443 (TCP) to look more like real traffic.
  • Privileges. -I and -T usually need root (or a capability); UDP mode works for ordinary users.
  • tracepath needs no root and also reports the path MTU. mtr repeats the trace continuously and shows loss per hop, which is better for intermittent problems.
  • Package. Install it with sudo apt install traceroute or sudo dnf install traceroute; it is not always present by default.