Skip to content

Commit 95e93fa

Browse files
committed
docs(notes): add traceroute options documentation for 2025-03-20
1 parent 41fb9a0 commit 95e93fa

File tree

1 file changed

+123
-0
lines changed

1 file changed

+123
-0
lines changed
+123
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
---
2+
title: "Traceroute Options"
3+
lang: en
4+
layout: post
5+
audio: false
6+
translated: false
7+
generated: true
8+
---
9+
10+
Traceroute is a powerful tool for diagnosing network paths, and while its basic use is straightforward, it offers advanced options to customize its behavior. Below, I’ll outline common options and explain how to use traceroute in advanced ways, focusing on practical examples. The exact options depend on your operating system (e.g., Windows uses `tracert`, while Linux/macOS use `traceroute`), but I’ll cover the most widely applicable ones.
11+
12+
### Basic Usage
13+
- **Linux/macOS**: `traceroute [destination]`
14+
- Example: `traceroute google.com`
15+
- **Windows**: `tracert [destination]`
16+
- Example: `tracert google.com`
17+
18+
This shows the hops (routers) between you and the target, along with round-trip times (RTT) for each.
19+
20+
---
21+
22+
### Common Traceroute Options
23+
Here’s a rundown of key options, primarily for the `traceroute` command on Unix-like systems (Linux/macOS). Windows `tracert` has fewer options but shares some concepts.
24+
25+
1. **`-n` (No DNS Lookup)**
26+
- Skips resolving IP addresses to hostnames, speeding up the process and showing raw IPs.
27+
- Use: `traceroute -n google.com`
28+
- Why: Useful when DNS resolution is slow or you only care about IPs.
29+
30+
2. **`-m [max_hops]` (Set Maximum Hops)**
31+
- Limits how many hops traceroute checks before giving up (default is often 30).
32+
- Use: `traceroute -m 15 google.com`
33+
- Why: Prevents endless runs if the target is unreachable or far away.
34+
35+
3. **`-q [nqueries]` (Number of Queries per Hop)**
36+
- Sets how many packets are sent per hop (default is 3). Each query shows a latency value.
37+
- Use: `traceroute -q 1 google.com`
38+
- Why: Reduces output clutter or speeds up the trace; increase it for more reliable latency data.
39+
40+
4. **`-w [waittime]` (Wait Time per Hop)**
41+
- Sets how long (in seconds) to wait for a response before marking a hop as timed out.
42+
- Use: `traceroute -w 2 google.com`
43+
- Why: Adjusts for slow networks or reduces delays on fast ones.
44+
45+
5. **`-p [port]` (Specify Port, UDP Mode)**
46+
- Sets the destination port for UDP-based traceroute (default is often 33434+).
47+
- Use: `traceroute -p 53 google.com`
48+
- Why: Targets specific services (e.g., DNS on port 53) or bypasses filters blocking ICMP.
49+
50+
6. **`-I` (Use ICMP Instead of UDP)**
51+
- Switches from UDP (default on many systems) to ICMP Echo Request packets.
52+
- Use: `traceroute -I google.com`
53+
- Why: Some networks block UDP but allow ICMP, improving visibility.
54+
55+
7. **`-T` (TCP Mode)**
56+
- Uses TCP packets instead of UDP or ICMP, often with SYN packets.
57+
- Use: `traceroute -T -p 80 google.com`
58+
- Why: Bypasses firewalls that block ICMP/UDP; great for tracing to web servers (port 80 = HTTP).
59+
60+
8. **`-f [first_ttl]` (Start at Specific TTL)**
61+
- Sets the initial TTL value, skipping earlier hops.
62+
- Use: `traceroute -f 5 google.com`
63+
- Why: Focuses on a specific part of the path, e.g., beyond your local network.
64+
65+
9. **`-g [gateway]` (Loose Source Routing)**
66+
- Forces packets through a specified gateway (if supported by the network).
67+
- Use: `traceroute -g 192.168.1.1 google.com`
68+
- Why: Tests specific routes or bypasses default routing.
69+
70+
10. **`-4` or `-6` (Force IPv4 or IPv6)**
71+
- Restricts traceroute to IPv4 or IPv6.
72+
- Use: `traceroute -6 google.com`
73+
- Why: Ensures you’re testing a specific protocol, useful for dual-stack networks.
74+
75+
---
76+
77+
### Windows `tracert` Options
78+
Windows has fewer options, but here are the main ones:
79+
- **`-d`**: No DNS lookups (like `-n`).
80+
- **`-h [max_hops]`**: Max hops (like `-m`).
81+
- **`-w [timeout]`**: Wait time in milliseconds (like `-w`).
82+
- Example: `tracert -d -h 20 google.com`
83+
84+
---
85+
86+
### Advanced Usage Examples
87+
Here’s how to combine options for specific purposes:
88+
89+
1. **Diagnose a Slow Connection**
90+
- Goal: Pinpoint where latency spikes.
91+
- Command: `traceroute -I -q 5 -w 1 google.com`
92+
- Why: ICMP for reliability, 5 queries for better latency stats, 1-second timeout to move quickly.
93+
94+
2. **Bypass Firewall Restrictions**
95+
- Goal: Trace to a web server blocked by ICMP filters.
96+
- Command: `traceroute -T -p 443 google.com`
97+
- Why: TCP on port 443 (HTTPS) mimics legitimate traffic, often allowed through firewalls.
98+
99+
3. **Test Beyond Your ISP**
100+
- Goal: Skip local hops to focus on external routing.
101+
- Command: `traceroute -f 3 -m 10 google.com`
102+
- Why: Starts at hop 3 (past your router/ISP), limits to 10 hops total.
103+
104+
4. **Compare IPv4 vs. IPv6 Paths**
105+
- Goal: See if protocol choice affects routing.
106+
- Commands:
107+
- `traceroute -4 google.com`
108+
- `traceroute -6 google.com`
109+
- Why: Identifies differences in network paths or performance.
110+
111+
5. **Silent, Fast Trace for Scripting**
112+
- Goal: Quick output for automation.
113+
- Command: `traceroute -n -q 1 -w 1 google.com > output.txt`
114+
- Why: No DNS, one query, short timeout, redirected to a file.
115+
116+
---
117+
118+
### Tips for Advanced Use
119+
- **Combine with Other Tools**: Pair traceroute with `ping` (for latency) or `mtr` (real-time traceroute) for deeper insights.
120+
- **Understand Network Context**: Firewalls, NAT, or VPNs can obscure hops (showing asterisks `*`)—adjust protocols (ICMP/TCP) to adapt.
121+
- **Root Privileges**: On Unix systems, some options (e.g., TCP mode) may require `sudo` for raw socket access: `sudo traceroute -T google.com`.
122+
123+
Traceroute’s power lies in its flexibility. By tweaking options, you can tailor it to troubleshoot specific network issues, bypass restrictions, or analyze routing behavior in detail. Let me know if you want to dive deeper into a particular scenario!

0 commit comments

Comments
 (0)