Master Linux Traceroute: 12 Powerful Commands to Diagnose Network Paths
Learn how to install and leverage the Linux traceroute utility with 12 practical examples, covering basic usage, timeout adjustments, packet count, hop limits, TTL settings, disabling hostname resolution, custom ports, packet size, IPv4/IPv6 tracing, ICMP mode, and output saving for effective network diagnostics.
Introduction
Network engineers and operations staff frequently use the traceroute command to diagnose connectivity, as it reveals the path packets take from a source to a destination. While many only know the basic usage, this guide provides twelve practical examples to fully master traceroute.
Prerequisite Knowledge
Before diving into commands, review the network topology diagram below, which shows two possible routes from a computer to a server:
The paths are Computer->R1->R2->R4->Server and Computer->R1->R3->R4->Server. Traceroute can reveal which route is actually taken.
Installing traceroute on Linux
First identify the Linux distribution:
root@ecs-adf0-0003:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 20.04.4 LTS
Release: 20.04
Codename: focalOn Ubuntu, install with: apt install traceroute If using CentOS or Fedora, use yum install traceroute instead.
Using traceroute
4.1 Basic Usage
traceroute hostThe command lists each router the packets traverse. Example tracing the site www.wljslmz.cn shows 20 hops:
4.2 Change Wait Time
The default per‑hop timeout is 3 seconds. Adjust it with -w:
traceroute -w 1 www.wljslmz.cn4.3 Change Number of Probes per Hop
Default is 3 probes. Use -q to set a different count, e.g., 5:
traceroute -q 5 www.wljslmz.cn4.4 Change Maximum Hop Count
The default max‑hops is 30 (extendable to 255). Use -m to limit it, e.g., to 10:
traceroute -m 10 www.wljslmz.cn4.5 Change Starting TTL
TTL (Time‑To‑Live) limits how many hops a packet can travel. Adjust the initial TTL with -f:
traceroute -f 8 www.wljslmz.cn4.6 Disable Hostname Resolution
Suppress domain names in the output with -n:
traceroute -n www.wljslmz.cn4.7 Trace a Different Destination Port
By default traceroute targets port 80. Change it with -p:
traceroute -p 2222 www.wljslmz.cn4.8 Change Maximum Packet Size
The default packet size is 60 bytes. Increase it by appending a size argument:
traceroute www.wljslmz.cn 200Setting a size smaller than the minimum (28 bytes) has no effect, as shown when using 1 as the size argument.
4.9 IPv4 Tracing
traceroute -4 www.wljslmz.cn4.10 IPv6 Tracing
traceroute -6 www.wljslmz.cnThe target site does not support IPv6.
4.11 Use ICMP ECHO Instead of UDP
Switch to ICMP mode with -I:
traceroute -I www.wljslmz.cn4.12 Save Traceroute Output to a File
Redirect the output for offline analysis:
traceroute www.wljslmz.cn > wljslmz.txtView the saved file with more wljslmz.txt as shown in the screenshot.
Conclusion
The traceroute command is a simple yet powerful network diagnostic tool. This article presented twelve practical examples, enabling readers to customize timeouts, probe counts, hop limits, TTL values, hostname resolution, destination ports, packet sizes, IPv4/IPv6 modes, ICMP usage, and output persistence for effective troubleshooting.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Liangxu Linux
Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
