The traceroute
command is used in Linux and Unix-like operating systems to trace the route that packets take from the local system to a destination IP address or hostname. It helps identify the network path and measure the response time (latency) between each hop.
The basic syntax of the traceroute
command is as follows:
traceroute [options] [destination]
Here, [options]
represents the various flags and parameters you can use with the command, and [destination]
refers to the IP address or hostname you want to trace the route to.
Some commonly used options with traceroute
include:
-I
: Uses ICMP Echo Request packets for probing (default if not privileged).-U
: Uses UDP packets instead of ICMP for probing.-p
: Specifies the destination port number for UDP probing.-T
: Uses TCP SYN packets for probing.-q
: Sets the number of probes per hop.-w
: Sets the maximum wait time for a response.-n
: Prevents DNS resolution of IP addresses to hostnames.-m
: Sets the maximum number of hops to trace.
To use the traceroute
command, open a terminal and enter the command followed by the desired options and the destination IP address or hostname. Here are a few examples:
- Trace the route to a destination using ICMP Echo Request packets:
traceroute example.com
- Trace the route to a destination using UDP packets:
traceroute -U example.com
- Specify the destination port number for UDP probing:
traceroute -U -p 12345 example.com
- Trace the route to a destination with a maximum of 15 hops:
traceroute -m 15 example.com
These are just a few examples, and there are many more options and variations you can use with the traceroute
command. To explore additional options and information, you can refer to the traceroute
command’s manual page by typing man traceroute
in the terminal.