← 返回命令列表

Linux command

traceroute 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Trace route to a host

traceroute [host]

Use ICMP echo

traceroute -I [host]

Use TCP SYN

sudo traceroute -T [host]

Set maximum hops

traceroute -m [20] [host]

Set number of probes

traceroute -q [1] [host]

Use a specific port

traceroute -p [80] [host]

Force IPv4 or IPv6

traceroute -4 [host]

Don't resolve hostnames

traceroute -n [host]

说明

traceroute displays the route packets take to reach a network host. It sends probe packets with incrementing TTL (Time To Live) values, causing each router along the path to respond with an ICMP "time exceeded" message, revealing its address. Each line shows a hop number, router hostname/IP, and round-trip times for each probe (default: 3). Asterisks (*) indicate no response within the timeout period—this may be due to firewalls, rate limiting, or packet loss. Different probe methods work better in different networks: ICMP (-I) may be blocked by firewalls, TCP (-T) can reach hosts that block other probes, and UDP (default) works for unprivileged users but may be filtered.

参数

-4, -6
Force IPv4 or IPv6
-I
Use ICMP ECHO for probes
-T
Use TCP SYN for probes (requires root)
-U
Use UDP datagrams (default)
-m _MAX_
Maximum number of hops (default: 30)
-q _NQUERIES_
Number of probes per hop (default: 3)
-w _WAIT_
Wait time for response in seconds (default: 5.0)
-p _PORT_
Destination port (UDP base or TCP destination)
-n
Do not resolve IP addresses to hostnames
-N _NUM_
Number of simultaneous probes (default: 16)
-f _FIRST_
Start from specified TTL (default: 1)
-F
Set "Don't Fragment" bit
-i _INTERFACE_
Specify network interface
-s _SOURCE_
Use specified source address
-z _PAUSE_
Pause between probes (seconds or milliseconds if >10)
-A
Perform AS path lookups
--mtu
Discover MTU along the path
-V
Show version

FAQ

What is the traceroute command used for?

traceroute displays the route packets take to reach a network host. It sends probe packets with incrementing TTL (Time To Live) values, causing each router along the path to respond with an ICMP "time exceeded" message, revealing its address. Each line shows a hop number, router hostname/IP, and round-trip times for each probe (default: 3). Asterisks (*) indicate no response within the timeout period—this may be due to firewalls, rate limiting, or packet loss. Different probe methods work better in different networks: ICMP (-I) may be blocked by firewalls, TCP (-T) can reach hosts that block other probes, and UDP (default) works for unprivileged users but may be filtered.

How do I run a basic traceroute example?

Run `traceroute [host]` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -4, -6 do in traceroute?

Force IPv4 or IPv6