LinuxCommandLibrary

tracepath

Trace network path to a destination

TLDR

A preferred way to trace the path to a host

$ tracepath -p [33434] [host]
copy

Specify the initial destination port, useful with non-standard firewall settings
$ tracepath -p [destination_port] [host]
copy

Print both hostnames and numerical IP addresses
$ tracepath -b [host]
copy

Specify a maximum TTL (number of hops)
$ tracepath -m [max_hops] [host]
copy

Specify the initial packet length (defaults to 65535 for IPv4 and 128000 for IPv6)
$ tracepath -l [packet_length] [host]
copy

Use only IPv6 addresses
$ tracepath -6 [host]
copy

SYNOPSIS

tracepath [options] destination

PARAMETERS

-p port
    Specifies the destination port number to use for the probes. Defaults to a high, unused UDP port.

-m max_hops
    Sets the maximum number of hops (TTL) to probe. Defaults to 30.

-l pktlen
    Specifies the initial size of the probing packet in bytes. tracepath will increase this size to discover MTU.

-n
    Do not resolve hostnames for IP addresses, displaying only numeric IP addresses. This can speed up execution.

-b
    Prints both the numeric IP addresses and their resolved hostnames for each hop.

-e
    Shows ICMP extensions, as defined by RFC4884, if present in the ICMP errors received.

-V
    Displays the version information for the tracepath utility.

DESCRIPTION

tracepath is a powerful Linux command-line utility used to trace the network path from the local host to a specified destination, similar to traceroute. Its primary strength lies in its ability to discover the Path Maximum Transmission Unit (PMTU) along the route. Unlike traditional traceroute which often requires root privileges (though modern versions can use unprivileged methods), tracepath typically does not, as it relies on unprivileged UDP sockets for its probes.

The command sends UDP packets of increasing size to the destination and listens for ICMP "Packet Too Big" messages, which indicate when a router along the path needs to fragment the packet because it exceeds the MTU of an outgoing interface. By analyzing these messages, tracepath can accurately determine the smallest MTU on the entire path, which is crucial for efficient network communication and avoiding fragmentation. It reports each hop, the round-trip time, and the discovered MTU at various stages, providing valuable insights for troubleshooting connectivity and performance issues, especially those related to large packet transfers.

CAVEATS

tracepath relies on ICMP "Packet Too Big" messages (Type 3, Code 4) for its MTU discovery functionality. If firewalls or network devices along the path are configured to block or filter these ICMP messages, the MTU discovery may fail or report an inaccurate PMTU.

Similarly, if UDP probes on the chosen port are filtered by firewalls, the command may fail to reach the destination or report "no reply" for certain hops.

It primarily uses UDP probes and does not offer the same level of protocol control (e.g., TCP or ICMP echo probes) as some traceroute implementations.

HOW IT DIFFERS FROM TRACEROUTE

While both commands trace network paths, tracepath's core focus is on Path MTU Discovery. It actively tries to determine the largest packet size that can traverse the entire path without fragmentation by sending packets of increasing size and analyzing ICMP "Packet Too Big" messages. traceroute, by default, primarily focuses on mapping the hops and measuring latency, often using fixed-size packets. tracepath also generally does not require root privileges, unlike older traceroute versions that used raw sockets.

PATH MTU DISCOVERY (PMTUD)

tracepath is an excellent tool for debugging PMTUD issues. PMTUD is a mechanism by which a sending host determines the largest MTU that can be used on the entire path to a destination without fragmentation. If PMTUD is failing (e.g., due to ICMP filtering), applications might experience slow performance or connection timeouts when trying to send large packets. tracepath helps diagnose where such MTU black holes might exist.

HISTORY

tracepath is part of the iputils package, a collection of network utilities for Linux. It was primarily developed by Alexey Kuznetsov, a key figure in the Linux kernel's networking subsystem and the author of iproute2. Its development aimed to provide a more effective and unprivileged tool for Path MTU Discovery (PMTUD) compared to traditional traceroute tools, which often required elevated permissions or were less focused on MTU. It was designed to work seamlessly with modern Linux networking stacks and their PMTUD mechanisms.

SEE ALSO

traceroute(8), ping(8), ip(8)

Copied to clipboard