Traceroute Introduction

bow.sh 2026-01-28 1 views

Traceroute Introduction

traceroute is a default routing trace utility provided by Linux, used to track the route of IP packets to a specific host. It leverages TTL (Time To Live), sending a series of probe packets to the destination address and listening for timeout responses from gateways. The first request has a TTL of 1, incrementing sequentially up to the 30th (default maximum of 30 hops), until an ICMP port unreachable or TCP reset is received. By default, 3 probe packets are sent per hop, and a line is printed showing the TTL/gateway address/round-trip time for each probe. If probe results come from different gateways, the address of each responding system is printed. If there's no response within 5 seconds, an asterisk * is printed.

Traceroute Parameter List

-4: Force IPv4 traceroute (by default, the appropriate protocol is automatically selected; if hostname resolution returns both IPv4 and IPv6 addresses, traceroute prioritizes IPv4)
-6: Force IPv6 traceroute
-T, --tcp: Use TCP SYN for probing (equivalent to `tcptraceroute`)
-I, --icmp: Use ICMP ECHO for probing
-d, --debug: Enable socket-level debugging, if supported by the kernel
-F, --dont-fragment: Do not fragment probe packets
-f first_ttl, --first=first_ttl: Specify initial TTL, default is 1
-g gate,..., --gateway=gate,...: Route packets through specified gateways (maximum 8 for IPv4, 127 for IPv6)
-i device, --interface=device: Specify network interface to send packets (default is selected based on routing table)
-m max_ttl, --max-hops=max_ttl: Specify maximum number of hops (maximum TTL value) for traceroute probes, default is 30
-N squeries, --sim-queries=squeries: Specify number of simultaneously sent probe packets, default is 16
-n: Display IP addresses without attempting to resolve hostnames
-p port, --port=port: Set destination port; TCP remains unchanged, UDP and ICMP port numbers increment with each probe
-t tos, --tos=tos: Set IPv4 Type of Service (16 for low delay, 8 for high throughput), or IPv6 traffic control value
-l flow_label, --flowlabel=flow_label: Add flow_label to IPv6 packets for special handling by routers
-w MAX,HERE,NEAR, --wait=MAX,HERE,NEAR: Set timeout values; HERE for wait count on same route (default 3), NEAR for wait count on next hop (default 10), MAX for timeout duration (default 5 seconds)
-q nqueries, --queries=nqueries: Set number of packets sent per hop, default is 3
-r: Bypass normal routing table and send packets directly to remote host
-s src_addr, --source=src_addr: Specify IP address as source address for outgoing probe packets
-z sendwait, --sendwait=sendwait: Set probe packet interval, default is 0; values ≤10 are in milliseconds, >10 are in seconds
-e, --extensions: Display ICMP extensions, including MPLS (Multiprotocol Label Switching)
-A, --as-path-lookups: Print AS numbers
-M name, --module=name: Use specified module (built-in or external) for traceroute; most methods have shortcuts (e.g., `-I` for `-M icmp`)
-O OPTS,..., --options=OPTS,...: Use module-specific options OPTS for traceroute module, multiple options separated by commas
--sport=num: Specify source port, implies `-N 1`
--fwmark=num: Set firewall mark for outgoing packets
-U, --udp: Use UDP to a specific port for routing instead of incrementing port per probe, default port is 53
-UL: Use UDP LITE for routing, default destination port is 53
-D, --dccp: Use DCCP requests for routing, default port is 33434
-P prot, --protocol=prot: Use raw packets with protocol protection for routing
--mtu: Discover MTU along the traced path, implies `-F -N 1`
--back: Infer number of hops in backward path, print if different
-V: Print version information
--help: Print help information

Examples

# View route using traceroute
traceroute google.com

# Use TCP traceroute with AS numbers, specify IPv4
traceroute -TA4 google.com

# Send 1 packet per hop
traceroute -q1 google.com

# Specify packet length of 30 bytes
traceroute google.com 30
Tags: Traceroute