The “traceroute” command in Linux is used to trace the route that packets take from your local system to a destination IP address or domain. It shows you the IP addresses of the routers in the path and the round-trip time for the packets to reach each router. Here’s how you can use “traceroute” effectively:
Prerequisites:
1. Ensure traceroute package is installed on your system by running below command:
traceroute
or
yum list installed | grep -I traceroute
If you are getting “command not found” message, install the traceroute package using below command.
sudo yum install traceroute
Once, the “traceroute” installed, verify using the below command.
traceroute --version
Here are the different ways which you can use “traceroute” command effectively.
1. Basic Usage:
traceroute example.com
Replace “example.com” with the domain or IP address you want to trace the route to. By default, “traceroute” sends packets with varying TTL (Time to Live) values to map the route to the destination.
2. Specifying Maximum Hops:
traceroute -m 10 example.com
This limits the number of hops to 30. Adjust the number according to your requirements to prevent “traceroute” from running indefinitely.
3. Specifying Packet Count:
traceroute -q 1 example.com
This sends only 1 packet per hop. Adjust the number to control the number of packets sent to each router.
4. Displaying Hop Addresses Numerically:
traceroute -n example.com
This prevents “traceroute” from attempting to resolve IP addresses to hostnames, providing numerical addresses only. This can speed up the “traceroute” process.
5. Using UDP Packets:
traceroute -U example.com
By default, “traceroute” uses ICMP packets. Using UDP packets might be useful if ICMP packets are blocked.
6. Specifying Source Address:
traceroute -s your_source_ip example.com
Specify a source IP address for the “traceroute” request. This is useful when you have multiple network interfaces.
7. Specifying a Specific Interface:
traceroute -i eth0 example.com
Specify the network interface to be used for the “traceroute” request.
8. Setting a Timeout for Each Probe:
traceroute -w 2 example.com
This sets the timeout for each probe to 2 seconds. Adjust the timeout according to your needs.
9. Bypassing Firewalls and Packet Filtering:
traceroute -T example.com
Use TCP SYN packets instead of ICMP or UDP. This can be useful if ICMP or UDP packets are blocked by firewalls.
10. Displaying AS (Autonomous System) Information:
traceroute -A example.com
Display AS information for each hop. This shows the AS number associated with each router in the path.
11. Displaying Timestamps:
traceroute -F example.com
Display timestamps for each hop. This shows the time taken by each hop to respond.
12. Running “traceroute” Continuously:
watch -n 1 traceroute example.com
This runs “traceroute” every second, providing a continuous update. Adjust the interval (“1” in this case) as needed.
Understanding these options allows you to use “traceroute” more efficiently for diagnosing network issues and understanding the path your packets take to reach a destination.
How do you feel about this post? Drop your comments below..