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 --no-dns [example.com]
copy

Generate output after pinging each hop 10 times
$ mtr --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 --interval [10] [example.com]
copy

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

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

SYNOPSIS

mtr [options] hostname

PARAMETERS

--help
    Display help information and exit.

--version
    Display version information and exit.

-4
    Force IPv4 resolution only.

-6
    Force IPv6 resolution only.

-r, --report
    Report mode. Produce a report similar to traceroute but with statistics on each hop.

-n, --no-dns
    Do not resolve hostnames.

-a address, --address address
    Set the source address for outgoing packets.

-i interval, --interval interval
    Set the ICMP query interval in seconds (default is 1 second).

-c count, --report-cycles count
    Set the number of pings to send in report mode.

-s packetsize, --psize packetsize
    Set the packet size of ICMP queries in bytes.

-u, --udp
    Use UDP datagrams instead of ICMP ECHO.

-T, --tcp
    Use TCP SYN packets instead of ICMP ECHO.

-p port, --port port
    Use specified TCP or UDP port.

--raw
    Use raw sockets.

--tos tos
    Set the type of service (TOS) flag.

--show-ips
    Show IP addresses even when DNS is used.

--json
    Output in JSON format.

DESCRIPTION

mtr is a network diagnostic tool that combines the functionality of traceroute and ping. It traces the route taken by packets to a specified destination, displaying response times at each hop along the path. Unlike a single traceroute, mtr continues sending probes to each hop, providing near real-time statistics about packet loss and latency.
This makes it invaluable for identifying network bottlenecks, unstable connections, and generally understanding the health and performance of the network path to a server. mtr can operate in either report mode, printing a single report and exiting, or interactive mode, providing a constantly updated display in a terminal. It supports both UDP and ICMP probes, and offers options to customize probe parameters such as packet size and number of probes per second.

CAVEATS

mtr relies on ICMP or UDP/TCP packets being allowed through firewalls. If firewalls block these packets, mtr may show incomplete or misleading results. Also, some routers may implement rate limiting, affecting mtr's accuracy.

INTERACTIVE MODE KEYS

In interactive mode:
'?' - Show help.
'd' - Switch display mode.
'q' - Quit.

INTERPRETING RESULTS

High packet loss or latency at a particular hop can indicate a problem with that hop's network. Consistent packet loss across multiple hops often suggests an issue closer to the destination. '???' or 'no response' typically indicate a host that is not responding to probes or is blocking ICMP/UDP/TCP.

HISTORY

mtr was originally developed by Matt Kimball. It was designed to provide a more persistent and comprehensive network diagnostic tool compared to standard traceroute implementations. Over time, it has been updated with features such as IPv6 support, JSON output, and more flexible probing options. Its interactive mode and continuous monitoring capabilities quickly made it a popular tool for network administrators and developers.

SEE ALSO

traceroute(8), ping(8), tcpdump(1)

Copied to clipboard