The traceroute
command attempts to trace the route of IP
packets to a particular Internet
host by initiating probing packets with a small time-to-live (ttl
) and listening for ICMP
timeout replies from gateways. It starts with a ttl
of 1
and increments it until it either receives an ICMP port unreachable
or TCP reset
, which indicates that the host has been reached or the maximum number of hops (default of 30
hops) has been reached. It sends three probes (by default) at each ttl
and prints a line showing the ttl
, gateway address, and round-trip time for each probe. Additional information can be provided after the address in the request. If responses come from different gateways, it prints the address of each responding system. If there is no response within 5.0
seconds (default value), it prints a *
for that probe.
traceroute [-46dFITUnreAV] [-f first_ttl] [-g gate,...] [-i device]
[-m max_ttl] [-p port] [-s src_addr] [-q nqueries]
[-N squeries] [-t tos] [-l flow_label] [-w waittime]
[-z sendwait] [-UL] [-D] [-P proto] [--sport=port] [-M method]
[-O mod_options] [--mtu] [--back] host [packet_len]
-4, -6
: Explicitly forceIPv4
orIPv6
traceroute, by default, the program will attempt to resolve the given name and automatically select the appropriate protocol, if resolving the hostname returns bothIPv4
andIPv6
addresses,traceroute
will useIPv4
.-I, --icmp
: UseICMP ECHO
for probing.-T, --tcp
: UseTCP SYN
for probing.-d, --debug
: Enable socket-level debugging, if supported by the kernel.-F, --dont-fragment
: Do not fragment the probing packets, forIPv4
it also sets theDF
bit, which instructs intermediate routers not to perform remote fragmentation. Change the size of the probing packets via thepacket_len
command parameter to manually obtain information about theMTU
of individual network hops. Starting fromLinux
kernel2.6.22
, the non-fragmentation feature (e.g.,-F
or--mtu
) can function properly. Before this version,IPv6
was always fragmented andIPv4
could only use the finalmtu
discovered once (from the route cache), which may be smaller than the actualmtu
of the device.-f first_ttl, --first=first_ttl
: Specify the startingTTL
, defaults to1
.-g gate,..., --gateway=gate,...
: Instructtraceroute
to add theIP
source route option to outgoing packets, which tells the network to route packets through the specified gateway (for security reasons, most routers have disabled source routing), multiple gateways (comma-separated list) are usually allowed. ForIPv6
, it is possible to use the formnum
,addr
,addr
,...
, wherenum
is the route header type (default is type2
), note that according torfc 5095
, the use of route type0
is now deprecated.-i device, --interface=device
: Specify the interface through whichtraceroute
should send its packets, by default, the interface is chosen based on the routing table.-m max_ttl, --max-hops=max_ttl
: Specify the maximum number of hopstraceroute
should probe (maximum time to live value), default is30
.-N squeries, --sim-queries=squeries
: Specify the number of probe messages to be sent simultaneously, sending multiple probes can greatly speed up route tracing, the default value is16
, note that some routers and hosts may employICMP
rate limiting, in which case specifying a large number may result in some responses being lost.-n
: Do not attempt to map the IP addresses to host names when displaying them.-p port, --port=port
: ForUDP
tracing, specify the destination port numbertraceroute
will use, the target port number will increment with each probe, forICMP
tracing, specify the initialICMP
sequence value (also incremented per probe), forTCP
and other protocols, only specify the (constant) target port to connect to, when using thetcptraceroute
wrapper program, the-p
specifies the source port.-t tos, --tos=tos
: ForIPv4
, set the type of serviceTOS
and priority value, useful values are16
for low delay and8
for high throughput, to use certainTOS
priority values, superuser permission is required, forIPv6
, set the traffic class value.-l flow_label, --flowlabel=flow_label
: Use the specifiedflow_label
forIPv6
packets.-w MAX,HERE,NEAR, --wait=MAX,HERE,NEAR
: Set the time to wait for probe responses, in seconds, default is5.0
.-q nqueries, --queries=nqueries
: Set the number of probe packets per hop, default is3
.-r
: Bypass the regular routing table and send directly to a host on the connected network, return an error if the host is not on the directly connected network, this option can be used to perform aping
operation on the local host through an interface without a route.-s src_addr, --source=src_addr
: Select an alternate source address, note that an address of an interface must be selected, by default, the address of the outgoing interface is used.-z sendwait, --sendwait=sendwait
: Minimum time interval between probes, default is0
, if the value is greater than10
, specify a number in milliseconds, otherwise it is in seconds, floating-point values are also allowed, very useful when some routers employ rate limiting forICMP
messages.-e, --extensions
: DisplayICMP
extension names, the universal format isCLASS / TYPE
followed by a hexadecimal dump, indicatedMPLS
multi-protocol label switching data is parsed, in the formatMPLS:L=label,E=exp_use,S=stack_bottom,T=TTL (with any further objects separated by a slash ("/"))
.-A, --as-path-lookups
: PerformAS
path lookups in the routing registry and print the result directly after the corresponding address.-M name --module=name
: Use the specified module (built-in or external) fortraceroute
operations, most methods have their shortcuts, for example,-I
represents-M icmp
, etc.-O OPTS,..., --options=OPTS,...
: Use specific module optionsOPTS
for thetraceroute
module, allow severalOPTS
, separated by commas, for example, ifOPTS
ishelp
, print the help information.--sport=num
: Use the source port number for outgoing packets, indicated as-N 1
.--fwmark=num
: Set the firewall mark for outgoing packets.-U --udp
: UseUDP
for routing to a specific port, instead of increasing the port for each probe, the default port is53
.-UL
: UseUDP LITE
for routing, default target port is53
.-D --dccp
: UseDCCP
requests for routing, default port is33434
.-P prot --protocol=prot
: Use protocol-protected raw packets for routing.--mtu
: DiscoverMTU
along the traced path, indicated as-F-N 1
.--back
: Infer hops on the backward path, print if different.-V
: Output version information.--help
: Output help information.
Use traceroute
to view routing information.
traceroute www.google.com
Specify IPv4
to view routing information.
traceroute -4 www.google.com
Specify the TTL
to start with, default is 1
.
traceroute -f 3 www.google.com
Do not resolve IP
addresses to their domain names.
traceroute -n www.google.com
Set the number of probes per hop, default is 3
.
traceroute -q 1 www.google.com
Specify the complete packet length, default is a 60
byte packet.
traceroute www.google.com 100
Set the target port to be used, default is 33434
.
traceroute -p 20292 www.google.com
https://github.com/WindrunnerMax/EveryDay
https://www.computerhope.com/unix/utracero.htm
https://www.runoob.com/linux/linux-comm-traceroute.html
https://www.geeksforgeeks.org/traceroute-command-in-linux-with-examples/