LinuxCommandLibrary

mtr

Combine traceroute and ping functionality

TLDR

Traceroute to a host and continuously ping all intermediary hops

$ mtr [example.com]
copy

Disable IP address and host name mapping
$ mtr [[-n|--no-dns]] [example.com]
copy

Generate output after pinging each hop 10 times
$ mtr [[-w|--report-wide]] [example.com]
copy

Force IP IPv4 or IPV6
$ mtr -4 [example.com]
copy

Wait for a given time (in seconds) before sending another packet to the same hop
$ mtr [[-i|--interval]] [10] [example.com]
copy

Display the Autonomous System Number (ASN) for each hop
$ mtr [[-z|--aslookup]] [example.com]
copy

Display both IP address and reverse DNS name
$ mtr [[-b|--show-ips]] [example.com]
copy

SYNOPSIS

mtr [options] hostname|IP_address

PARAMETERS

-r, --report
    Displays output in report mode (non-interactive), suitable for scripting or logging.

-c, --report-cycles
    Number of pings (cycles) to send in report mode before exiting.

-n, --no-dns
    Displays numeric IP addresses instead of resolving hostnames.

-z, --as-lookup
    Displays autonomous system (AS) numbers for each hop.

-i, --interval
    Interval in seconds between sending ICMP ECHO requests. Default is 1 second.

-s, --psize
    Specifies the packet size in bytes.

-a, --address
    Binds outgoing packets to a specified IP address (useful on multi-homed systems).

-T, --tcp
    Uses TCP SYN packets instead of ICMP ECHO for probes (requires root).

-U, --udp
    Uses UDP DGRAM packets instead of ICMP ECHO for probes (requires root).

-P, --port
    Specifies the destination port for TCP or UDP probes.

-L, --lsr
    Enables Loose Source Record Route (LSRR) option in IP header.

-F, --filename
    Reads a list of hostnames from a specified file, one per line.

-h, --help
    Displays help information and exits.

-v, --version
    Displays version information and exits.

DESCRIPTION


mtr (My Traceroute) is a powerful network diagnostic tool that ingeniously combines the functionalities of the ping and traceroute commands into a single, continuously updating display. Unlike traceroute, which shows a single path measurement, or ping, which only measures end-to-end latency, mtr continuously sends packets to a specified destination host. As these packets traverse the network, mtr gathers crucial information about the network path, including every router (hop) along the way, the round-trip time to each hop, and the percentage of packet loss experienced at each individual hop.

This continuous monitoring allows users to observe network performance in real-time, making it invaluable for identifying and diagnosing various network problems such as bottlenecks, overloaded links, router failures, and packet loss occurring at specific points in the network path. Its interactive interface updates statistics dynamically, providing a live snapshot of network health, while its report mode offers a concise summary for analysis or sharing. By providing a clear, hop-by-hop breakdown of network performance, mtr significantly aids in pinpointing the exact location of network issues, making troubleshooting much more efficient.

CAVEATS

  • Root Privileges: Some advanced features, such as using TCP (-T) or UDP (-U) probes, or binding to specific source addresses (-a), may require root privileges.
  • Firewall Blocking: Network devices (routers, firewalls) may block or rate-limit ICMP, TCP, or UDP packets, leading to "???" or "no response" in the output, which can obscure the true network path or performance. This doesn't necessarily indicate a problem, but rather a configuration on the device.
  • Asymmetric Routing: Network paths can be asymmetric, meaning the forward path (outbound) and return path (inbound) may differ. mtr only shows the outbound path.
  • Load Balancing: Intermediate routers might employ load balancing, causing subsequent packets to take different paths. This can lead to varying statistics for a single hop.

INTERPRETING OUTPUT

The mtr output typically includes columns like Host, Loss% (packet loss percentage), Snt (number of packets sent), Recv (number of packets received), Last (last round-trip time), Avg (average RTT), Best (shortest RTT), Wrst (longest RTT), and StDev (standard deviation of RTT). High Loss% or StDev at a particular hop often indicates congestion or issues at that network segment.

INTERACTIVE MODE

In interactive mode, mtr updates statistics in real-time. Pressing 'h' shows help, 'd' toggles display modes, 'p' pauses, and 'q' quits. This dynamic view is crucial for monitoring transient network problems.

HISTORY

mtr was originally written by Matt Kimball in the late 1990s as a combination of ping and traceroute functionalities. It quickly gained popularity for its interactive and continuous monitoring capabilities, which offered a significant improvement over the static output of traditional tracing tools. Over the years, it has been maintained and enhanced by various contributors within the open-source community, adding features like AS number lookups, different probe types (TCP/UDP), and report generation options, solidifying its status as a standard utility for network diagnostics on Unix-like operating systems.

SEE ALSO

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

Copied to clipboard