mtr: Usage, Options & Common CI Errors
mtr traces the network path to a host and shows per-hop loss and latency.
mtr merges traceroute and ping into a live per-hop view. In CI you must use report mode (-r) so it runs a fixed number of cycles and exits instead of running interactively forever.
What it does
mtr sends probes along the route to a host and continuously reports, per hop, the packet loss and latency. Report mode emits a static table after a set number of probe cycles, suitable for logging in CI.
Common usage
mtr -r -c 10 example.com # report mode, 10 cycles
mtr -rw -c 20 example.com # wide report (full hostnames)
mtr -r -c 10 -T -P 443 example.com # TCP probes to port 443
mtr -r -n -c 5 example.com # numeric (no DNS)
mtr --json -c 10 example.comOptions
| Flag | What it does |
|---|---|
| -r / --report | Run cycles then print a report and exit |
| -c <N> | Number of probe cycles (with -r) |
| -w / --report-wide | Do not truncate hostnames |
| -T -P <port> | Use TCP SYN probes to a port |
| -n | Skip DNS resolution of hops |
| --json / --csv | Machine-readable output |
Common errors in CI
Without -r, mtr runs interactively and never exits, hanging the job - always use -r (report) with -c. "mtr: unable to get raw sockets: Operation not permitted" means it lacks CAP_NET_RAW (common in unprivileged containers) - run with the capability or use -T/--tcp which can use connect() probes. Many cloud networks rate-limit or drop ICMP, so middle hops show "???" or 100% loss while the final hop is fine - that is normal, not necessarily a fault.