Traceroute

Traceroute is a network diagnostic command that maps the path packets travel from source to destination, showing each hop and round-trip time.

Traceroute is a command-line network diagnostic tool that traces the path Internet Protocol (IP) packets travel from source to destination, displaying each hop and round-trip time (RTT), on Linux, macOS, and Windows.

What Traceroute Does and When to Use It

Traceroute maps the network path between a local machine and a remote host. The tool identifies every intermediate router (hop) along the route and measures the round-trip time for each hop. Network administrators use traceroute to diagnose routing problems, detect packet loss, locate network bottlenecks, and verify that traffic follows the expected path through gateways and Internet service provider (ISP) networks.

Traceroute is available on all major operating systems. Linux and macOS provide the traceroute command, which sends User Datagram Protocol (UDP) probes by default. Windows provides the tracert command, which sends Internet Control Message Protocol (ICMP) Echo Request packets by default. Both implementations use the Time to Live (TTL) field in IP packet headers to discover each hop along the route.

Use traceroute when a remote server is unreachable, when connections are slow to a specific destination, or when packets appear to take an unexpected path. For basic connectivity tests without path information, ping is a simpler alternative. For combined continuous traceroute and ping statistics, My Traceroute (mtr) provides a real-time interactive view.

How to Install Traceroute

Traceroute ships preinstalled on macOS and Windows. On Linux, install traceroute through the package manager.

Ubuntu / Debian:

sudo apt update && sudo apt install traceroute

CentOS / RHEL / Fedora:

sudo dnf install traceroute

macOS:

Traceroute is preinstalled. Verify the installation:

traceroute --version

Windows:

Windows includes tracert as a built-in command. Open Command Prompt or PowerShell and run:

tracert example.com

Core Concepts of Traceroute

Traceroute TTL (Time to Live) Mechanism

Traceroute discovers each hop by manipulating the Time to Live (TTL) field in the IP packet header. Every router that forwards a packet decrements the TTL by 1. When a router receives a packet with a TTL of 0, the router discards the packet and sends an ICMP Time Exceeded (Type 11, Code 0) message back to the source.

Traceroute exploits this behavior by sending the first set of probes with a TTL of 1. The first router decrements the TTL to 0, discards the packet, and returns an ICMP Time Exceeded response — revealing its IP address and round-trip time. Traceroute then sends the next set of probes with a TTL of 2, which reaches the second router before expiring. This process repeats, incrementing the TTL by 1 each round, until the probes reach the destination or the maximum hop count (default: 30) is exhausted.

Traceroute Probes and Protocols

Traceroute sends three probes per hop by default. Each probe measures an independent round-trip time, which reveals latency variation (jitter) at that hop.

Linux and macOS traceroute sends UDP packets to high-numbered destination ports (starting at port 33434) by default. When the probes reach the destination, the target host responds with an ICMP Port Unreachable (Type 3, Code 3) message, which signals traceroute to stop. Linux and macOS traceroute also supports ICMP mode ( -I) and TCP mode ( -T) as alternatives.

Windows tracert sends ICMP Echo Request packets by default. When the probes reach the destination, the target responds with an ICMP Echo Reply, which signals tracert to stop.

Traceroute Output Columns

Traceroute displays one line per hop. Each line contains the hop number, three round-trip time measurements (one per probe), and the IP address or hostname of the responding router. An asterisk ( *) replaces a round-trip time when a probe receives no response within the timeout period (default: 5 seconds). Three consecutive asterisks ( * * *) indicate that the router at that hop does not respond to traceroute probes — often because a firewall blocks ICMP or UDP traffic.

Traceroute how it works

Common Tasks with Traceroute

How to Run a Basic Traceroute to a Host

Traceroute traces the path to a destination by passing the hostname or IP address as an argument:

traceroute example.com

On Windows, use the tracert command:

tracert example.com

Traceroute example command

For details on interpreting the output, see How to Read Traceroute Results.

How to Limit the Maximum Hop Count with Traceroute

Traceroute sets the maximum number of hops with the -m flag on Linux and macOS, or the -h flag on Windows. This stops traceroute from probing beyond the specified hop count:

Linux / macOS:

traceroute -m 15 example.com

Windows:

tracert -h 15 example.com

How to Skip DNS Resolution with Traceroute

Traceroute displays numeric IP addresses without resolving hostnames when the -n flag is used. This speeds up the trace by eliminating DNS lookups at each hop:

Linux / macOS:

traceroute -n example.com

Windows:

tracert -d example.com

How to Use ICMP Probes with Traceroute on Linux

Traceroute on Linux sends UDP probes by default. Switch to ICMP Echo Request probes with the -I flag. ICMP probes often pass through firewalls that block UDP:

sudo traceroute -I example.com

ICMP mode requires root or sudo privileges on Linux.

How to Trace an IPv6 Route with Traceroute

Traceroute traces IPv6 paths using traceroute6 on Linux and macOS, or tracert -6 on Windows:

Linux / macOS:

traceroute6 example.com

Windows:

tracert -6 example.com

For the full procedure, see How to Use Traceroute with IPv6.

Traceroute Options Reference

Traceroute accepts different flags on Linux/macOS and Windows. The table below covers the most commonly used options.

FlagPlatformDescriptionDefaultExample
-nLinux / macOSDisplay numeric IP addresses without resolving hostnames, which eliminates DNS lookup delaysResolve hostnamestraceroute -n example.com
-dWindowsDo not resolve addresses to hostnames in tracert outputResolve hostnamestracert -d example.com
-m max_ttlLinux / macOSSet the maximum TTL (hop count) for outgoing probes. Range: 1--25530traceroute -m 20 example.com
-h max_hopsWindowsSet the maximum number of hops to search for the target in tracert30tracert -h 20 example.com
-w wait_timeLinux / macOSSet the timeout in seconds to wait for an ICMP response at each hop5traceroute -w 3 example.com
-w timeoutWindowsSet the timeout in milliseconds to wait for each reply in tracert4000tracert -w 3000 example.com
-q nqueriesLinux / macOSSet the number of probe packets sent per hop3traceroute -q 1 example.com
-ILinux / macOSUse ICMP Echo Request probes instead of UDP. Requires root privilegesUDPsudo traceroute -I example.com
-TLinux / macOSUse TCP SYN probes instead of UDP. Requires root privilegesUDPsudo traceroute -T example.com
-p portLinux / macOSSet the base UDP destination port number used in traceroute probes33434traceroute -p 44434 example.com
-i initial_ttlLinux / macOSSet the starting TTL value, which skips hops closer than the specified count1traceroute -i 5 example.com
-4BothForce traceroute to use IPv4Autotraceroute -4 example.com
-6BothForce traceroute to use IPv6Autotracert -6 example.com

For the full reference, see Traceroute References.

Traceroute Troubleshooting

Traceroute reports error codes when an intermediate router or the destination returns an ICMP Destination Unreachable message. The table below summarizes common errors.

ErrorICMP CodeMeaningFix
!AType 3, Code 13Administratively prohibited — a firewall or access control list (ACL) blocks the trafficFull article
!NType 3, Code 0Network unreachable — no route exists to the destination networkFull article
!PType 3, Code 2Protocol unreachable — the destination does not support the transport protocol used by the probeFull article
!HType 3, Code 1Host unreachable — the destination host cannot be reached on the target networkCheck host status and local routing table
* * *N/ANo response — the router at that hop does not reply to probes within the timeout periodFirewall filtering, or the router silently drops ICMP/UDP probes

ping tests basic connectivity and measures round-trip time to a single host without revealing the path. Use ping for quick reachability checks. See pingfor usage.

My Traceroute (mtr) combines traceroute and ping into a single tool that continuously updates hop-by-hop statistics including packet loss percentage, average latency, and jitter. mtr is the preferred alternative for ongoing network path monitoring.

pathping (Windows) combines the functionality of ping and tracert. pathping computes packet loss statistics at each hop over a 25-second observation period.

nslookup queries DNS servers to resolve domain names to IP addresses. See nslookupfor DNS lookup tasks.