- Linux Mtr Command Tutorial with Examples To Network Diagnostics
- Interactive Traceroute
- Show Gtk Interface
- CSV Output
- Xml Output
- Json Output
- Set Ping Count
- Read Hostnames From File
- Do Not Resolve DNS
- Show AS Number
- MTR – A Network Diagnostic Tool for Linux
- How Does MTR Work?
- 10 MTR Network Diagnostics Tool Usage Examples
- If You Appreciate What We Do Here On TecMint, You Should Consider:
- mtr(8) — Linux man page
- Synopsis
- Description
- Options
- Contact Information
- mtr (8) — Linux Man Pages
- mtr: a network diagnostic tool
- SYNOPSIS
- DESCRIPTION
- OPTIONS
- ENVIRONMENT
- INTERACTIVE CONTROL
- CONTACT INFORMATION
Linux Mtr Command Tutorial with Examples To Network Diagnostics
Linux mtr command provides both functionality of traceroute and ping commands. mtr can provide reports and xml, json, csv output. There is also Gtk interface provided for mtr .
Interactive Traceroute
One of the simple use case for mtr is providing the remote hostname or IP address we want to traceroute. This will open a new interactive window which shows each intermediate hop. This will also send continuous ICMP packets to get new time and related metrics and show in the screen.
We can exit from this screen with CTRL+C
Show Gtk Interface
mtr command can be used with GUI interface. We will provide – g in order to start with Gtk interface.
CSV Output
We can create CSV type output. CSV type output will delimit the columns with , . We will provide —csv option with the remote hostname.
CSV Output
Xml Output
Another supported output is xml . We can generate xml format output for the given remote hostname. We will use —xml option for this. Xml format is better suited for automated processing.
Xml Output
Json Output
We can also generate Json output. Json format is mainly used by Javascript applications. We can use —json option to generate JSON output.
Set Ping Count
mtr command will generate ping packets continuously. We can specify the ping count with – c and the packet count. In this example we will set ping count to 5 .
Read Hostnames From File
We can provide multiple hostnames to ping. In order to provide multiple remote hosts we should put them in to a file line by line. Then we will read this file with -F option with the file name. In this example we will read remote hosts from file named ping.txt .
Do Not Resolve DNS
Another standard feature of mtr is disabling DNS resolving. This will made operations faster because extra DNS resolving will create more traffic and wait time. We can disable DNS resolving with -n option.
Show AS Number
Autonomous systems are cells in internet network each of them connects each other in a mesh way. During ping and traceroute operations send packets are transmitted trough these Autonomous systems. We can all intermediate hosts autonomous numbers with —aslookup option.
Show AS Number
Источник
MTR – A Network Diagnostic Tool for Linux
MTR is a simple, cross-platform command-line network diagnostic tool that combines the functionality of commonly used traceroute and ping programs into a single tool. In a similar fashion as traceroute, mtr prints information about the route that packets take from the host on which mtr is run to a user specified destination host.
However, mtr shows a wealth of information than traceroute: it determines the pathway to a remote machine while printing response percentage as well as response times of all network hops in the internet route between the local system and a remote machines.
How Does MTR Work?
Once you run mtr, it probes the network connection between the local system and a remote host that you have specified. It first establishes the address of each network hop (bridges, routers and gateways etc.) between the hosts, it then pings (sends a sequence ICMP ECHO requests to) each one to determine the quality of the link to each machine.
During the course of this operation, mtr outputs some useful statistics about each machine – updated in real-time, by default.
This tool comes pre-installed on most Linux distributions and is fairly easy to use once you go through the 10 mtr command examples for network diagnostics in Linux, explained below.
If mtr not installed, you can install it on your respective Linux distributions using your default package manager as shown.
10 MTR Network Diagnostics Tool Usage Examples
1. The simplest example of using mtr is to provide the domain name or IP address of the remote machine as an argument, for example google.com or 216.58.223.78. This command will show you a traceroute report updated in real-time, until you exit the program (by pressing q or Ctrl + C ).
2. You can force mtr to display numeric IP addresses instead of host names (typically FQDNs – Fully Qualified Domain Names), using the -n flag as shown.
3. If you would like mtr to display both host names as well as numeric IP numbers use the -b flag as shown.
4. To limit the number of pings to a specific value and exit mtr after those pings, use the -c flag. If you observe from the Snt column, once the specified number of pings is reached, the live update stops and the program exits.
5. You can set it into report mode using the -r flag, a useful option for producing statistics concerning network quality. You can use this option together with the -c option to specify the number of pings. Since the statistics are printed to std output, you can redirect them to a file for later analysis.
The -w flag enables wide report mode for a clearer output.
6. You can also re-arrange the output fields the way you wish, this is made possible by the -o flag as shown (see the mtr man page for meaning of field labels).
MTR Fields and Order
7. The default interval between ICMP ECHO requests is one second, you can specify interval between ICMP ECHO requests by changing the value using the -i flag as shown.
8. You can use TCP SYN packets or UDP datagrams instead of the default ICMP ECHO requests as shown.
9. To specify the maximum number of hops (default is 30) to be probed between the local system and the remote machine, use the -m flag.
10. While probing network quality, you can set the packet size used in bytes using the -s flag like so.
With these examples, you should be good to go with using mtr, see man page for more usage options.
Also check out these useful guides about Linux network configurations and troubleshooting:
That’s it for now! MTR is a simple, easy-to-use and above all cross-platform network diagnostics tool. In this guide, we have explained 10 mtr command examples in Linux. If you have any questions, or thoughts to share with us, use the comment form below.
If You Appreciate What We Do Here On TecMint, You Should Consider:
TecMint is the fastest growing and most trusted community site for any kind of Linux Articles, Guides and Books on the web. Millions of people visit TecMint! to search or browse the thousands of published articles available FREELY to all.
If you like what you are reading, please consider buying us a coffee ( or 2 ) as a token of appreciation.
We are thankful for your never ending support.
Источник
mtr(8) — Linux man page
Synopsis
Description
mtr combines the functionality of the traceroute and ping programs in a single network diagnostic tool.
As mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME. by sending packets with purposly low TTLs. It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME. A sudden increase in packetloss or response time is often an indication of a bad (or simply overloaded) link.
Options
If set to a negative number, every iteration will use a different, random packetsize upto that number. -t —curses
Use this option to force mtr to use the curses based terminal interface (if available). -n —no-dns
Use this option to force mtr to display numeric IP numbers and not try to resolve the host names. -o fields order —order fields order
Use this option to specify the fields and their order when loading mtr.
Example: -o «LSD NBAW» -g —gtk
Use this option to force mtr to use the GTK+ based X11 window interface (if available). GTK+ must have been available on the system when mtr was built for this to work. See the GTK+ web page at http://www.gimp.org/gtk/ for more information about GTK+. -p —split
Use this option to set mtr to spit out a format that is suitable for a split-user interface. -l —raw
Use this option to tell mtr to use the raw output format. This format is better suited for archival of the measurement results. It could be parsed to be presented into any of the other display methods. -a IP.ADD.RE.SS —address IP.ADD.RE.SS
Use this option to bind outgoing packets’ socket to specific interface, so that any packet will be sent through this interface. NOTE that this option doesn’t apply to DNS requests (which could be and could not be what you want). -i SECONDS —interval SECONDS
Use this option to specify the positive number of seconds between ICMP ECHO requests. The default value for this parameter is one second. -u
Use UDP datagrams instead of ICMP ECHO. -4
Use IPv4 only. -6
Use IPv6 only.
Some modern routers give a lower priority to ICMP ECHO packets than to other network traffic. Consequently, the reliability of these routers reported by mtr will be significantly lower than the actual reliability of these routers.
Contact Information
For the latest version, see the mtr web page at http://www.bitwizard.nl/mtr/.
Subscribe to the mtr mailing list. All mtr related announcements are posted to the mtr mailing list. To subscribe, send email to majordomo@lists.xmission.com with subscribe mtr in the body of the message. To send a message to the mailing list, mail to mtr@lists.xmission.com.
Bug reports and feature requests should be sent to the mtr mailing list.
Источник
mtr (8) — Linux Man Pages
mtr: a network diagnostic tool
Command to display mtr manual in Linux: $ man 8 mtr
mtr — a network diagnostic tool
SYNOPSIS
DESCRIPTION
As mtr starts, it investigates the network connection between the host mtr runs on and HOSTNAME by sending packets with purposely low TTLs. It continues to send packets with low TTL, noting the response time of the intervening routers. This allows mtr to print the response percentage and response times of the internet route to HOSTNAME . A sudden increase in packet loss or response time is often an indication of a bad (or simply overloaded) link.
The results are usually reported as round-trip-response times in milliseconds and the percentage of packetloss.
OPTIONS
Ctrl -L clears spurious error messages that may overwrite other parts of the display.
—displaymode MODE Use this option to select the initial display mode: 0 (default) selects statistics, 1 selects the stripchart without latency information, and 2 selects the stripchart with latency information. -g , —gtk Use this option to force mtr to use the GTK+ based X11 window interface (if available). GTK+ must have been available on the system when mtr was built for this to work. See the GTK+ web page at for more information about GTK+. -l , —raw Use the raw output format. This format is better suited for archival of the measurement results. It could be parsed to be presented into any of the other display methods. Example of the raw output format: -C , —csv Use the Comma-Separated-Value (CSV) output format. (Note: The separator is actually a semi-colon ‘;’.) Example of the CSV output format: -j , —json Use this option to tell mtr to use the JSON output format. This format is better suited for automated processing of the measurement results. -p , —split Use this option to set mtr to spit out a format that is suitable for a split-user interface. -n , —no-dns Use this option to force mtr to display numeric IP numbers and not try to resolve the host names. -b , —show-ips Use this option to tell mtr to display both the host names and numeric IP numbers. In split mode this adds an extra field to the output. In report mode, there is usually too little space to add the IPs, and they will be truncated. Use the wide report (-w) mode to see the IPs in report mode. -o FIELDS , —order FIELDS Use this option to specify which fields to display and in which order. You may use one or more space characters to separate fields.
Available fields:
L | Loss ratio |
D | Dropped packets |
R | Received packets |
S | Sent Packets |
N | Newest RTT(ms) |
B | Min/Best RTT(ms) |
A | Average RTT(ms) |
W | Max/Worst RTT(ms) |
V | Standard Deviation |
G | Geometric Mean |
J | Current Jitter |
M | Jitter Mean/Avg. |
X | Worst Jitter |
I | Interarrival Jitter |
Example: -o «LSD NBAW X» -y n , —ipinfo n Displays information about each IP hop. Valid values for n are:
0 | Display AS number (equivalent to -z ) |
1 | Display IP prefix |
2 | Display country code of the origin AS |
3 | Display RIR (ripencc, arin, . ) |
4 | Display the allocation date of the IP prefix |
It is possible to cycle between these fields at runtime (using the y key). -z , —aslookup Displays the Autonomous System (AS) number alongside each hop. Equivalent to —ipinfo 0 . Example (columns to the right not shown for clarity): -i SECONDS , —interval SECONDS Use this option to specify the positive number of seconds between ICMP ECHO requests. The default value for this parameter is one second. The root user may choose values between zero and one. -c COUNT , —report-cycles COUNT Use this option to set the number of pings sent to determine both the machines on the network and the reliability of those machines. Each cycle lasts one second. -s PACKETSIZE , —psize PACKETSIZE This option sets the packet size used for probing. It is in bytes, inclusive IP and ICMP headers.
If set to a negative number, every iteration will use a different, random packet size up to that number. -B NUM , —bitpattern NUM Specifies bit pattern to use in payload. Should be within range 0 — 255. If NUM is greater than 255, a random pattern is used. -G SECONDS , —gracetime SECONDS Use this option to specify the positive number of seconds to wait for responses after the final request. The default value is five seconds. -Q NUM , —tos NUM Specifies value for type of service field in IP header. Should be within range 0 — 255. -e , —mpls Use this option to tell mtr to display information from ICMP extensions for MPLS (RFC 4950) that are encoded in the response packets. -I NAME , —interface NAME Use the network interface with a specific name for sending network probes. This can be useful when you have multiple network interfaces with routes to your destination, for example both wired Ethernet and WiFi, and wish to test a particular interface. -a ADDRESS , —address ADDRESS Use this option to bind the outgoing socket to ADDRESS , so that all packets will be sent with ADDRESS as source address. NOTE that this option doesn’t apply to DNS requests (which could be and could not be what you want). -f NUM , —first-ttl NUM Specifies with what TTL to start. Defaults to 1. -m NUM , —max-ttl NUM Specifies the maximum number of hops (max time-to-live value) traceroute will probe. Default is 30. -U NUM , —max-unknown NUM Specifies the maximum unknown host. Default is 5. -u , —udp Use UDP datagrams instead of ICMP ECHO. -T , —tcp Use TCP SYN packets instead of ICMP ECHO. PACKETSIZE is ignored, since SYN packets can not contain data. -S , —sctp Use Stream Control Transmission Protocol packets instead of ICMP ECHO. -P PORT , —port PORT The target port number for TCP/SCTP/UDP traces. -L LOCALPORT , —localport LOCALPORT The source port number for UDP traces. -Z SECONDS , —timeout SECONDS The number of seconds to keep probe sockets open before giving up on the connection. Using large values for this, especially combined with a short interval, will use up a lot of file descriptors. -M MARK , —mark MARK Set the mark for each packet sent through this socket similar to the netfilter MARK target but socket-based. MARK is 32 unsigned integer. See socket (7) for full description of this socket option.
ENVIRONMENT
MTR_OPTIONS =-4 -c 1 mtr -6 localhost
would send one probe (because of -c 1 ) towards ::1 (because of -6 , which overrides the -4 passed in MTR_OPTIONS ). MTR_PACKET A path to the mtr-packet executable, to be used for sending and receiving network probes. If MTR_PACKET is unset, the PATH will be used to search for an mtr-packet executable. DISPLAY Specifies an X11 server for the GTK+ frontend.
INTERACTIVE CONTROL
CONTACT INFORMATION
For the latest version, see the mtr web page at
For patches, bug reports, or feature requests, please open an issue on GitHub at:
Источник