How to use the command 'tracert' (with examples)
- Windows
- December 25, 2023
The ’tracert’ command is a network diagnostic tool that is used to trace the route taken by packets from your PC to a target IP address. It shows the number of hops between your PC and the target, along with details such as IP addresses and response times for each hop. This information can be helpful in troubleshooting network connectivity issues and identifying network latency.
Use case 1: Trace a route
Code:
tracert IP
Motivation: Tracing a route can provide valuable information about the path taken by packets between your PC and the target IP address. This can help identify any network issues or bottlenecks that may be affecting connectivity or performance.
Explanation: Replace “IP” with the IP address or hostname of the target. The ’tracert’ command will send a series of packets with increasing time-to-live (TTL) values to the target and it will display the route taken by the packets.
Example output:
Tracing route to example.com [93.184.216.34]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 10 ms 10 ms 11 ms 10.10.100.1
3 10 ms 9 ms 9 ms 203.0.113.1
4 12 ms 11 ms 11 ms 203.0.113.254
5 25 ms 24 ms 24 ms 203.0.112.201
6 25 ms 24 ms 24 ms 203.0.112.202
7 26 ms 25 ms 25 ms 203.0.112.203
...
Use case 2: Prevent ’tracert’ from resolving IP addresses to hostnames
Code:
tracert /d IP
Motivation: By default, ’tracert’ tries to resolve IP addresses to hostnames, which requires making DNS requests. If you want to speed up the output of ’tracert’ or avoid potential delays due to DNS resolution issues, you can use this command to prevent ’tracert’ from resolving IP addresses.
Explanation: Replace “IP” with the IP address or hostname of the target. The ‘/d’ flag instructs ’tracert’ not to perform DNS hostname resolution on IP addresses.
Example output:
Tracing route to 93.184.216.34 [93.184.216.34]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 10 ms 10 ms 11 ms 10.10.100.1
3 10 ms 9 ms 9 ms 203.0.113.1
4 12 ms 11 ms 11 ms 203.0.113.254
5 25 ms 24 ms 24 ms 203.0.112.201
6 25 ms 24 ms 24 ms 203.0.112.202
7 26 ms 25 ms 25 ms 203.0.112.203
...
Use case 3: Force ’tracert’ to use IPv4 only
Code:
tracert /4 IP
Motivation: By default, ’tracert’ uses both IPv4 and IPv6 protocols. If you want to limit ’tracert’ to use only IPv4, you can use this command.
Explanation: Replace “IP” with the IP address or hostname of the target. The ‘/4’ flag instructs ’tracert’ to use IPv4 protocol only.
Example output:
Tracing route to example.com [93.184.216.34]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 10 ms 10 ms 11 ms 10.10.100.1
3 10 ms 9 ms 9 ms 203.0.113.1
4 12 ms 11 ms 11 ms 203.0.113.254
5 25 ms 24 ms 24 ms 203.0.112.201
6 25 ms 24 ms 24 ms 203.0.112.202
7 26 ms 25 ms 25 ms 203.0.112.203
...
Use case 4: Force ’tracert’ to use IPv6 only
Code:
tracert /6 IP
Motivation: By default, ’tracert’ uses both IPv4 and IPv6 protocols. If you want to limit ’tracert’ to use only IPv6, you can use this command.
Explanation: Replace “IP” with the IP address or hostname of the target. The ‘/6’ flag instructs ’tracert’ to use IPv6 protocol only.
Example output:
Tracing route to example.com [2606:2800:220:1:248:1893:25e2:1946]
over a maximum of 30 hops:
1 <1 ms <1 ms <1 ms 2001:db8:0:1::1
2 9 ms 10 ms 10 ms 2001:db8:0:2::1
3 9 ms 9 ms 9 ms 2001:db8:0:3::1
4 11 ms 10 ms 10 ms 2001:db8:0:4::1
5 24 ms 24 ms 25 ms 2001:db8:0:5::1
6 30 ms 29 ms 29 ms 2001:db8:0:6::1
7 30 ms 30 ms 30 ms 2001:db8:0:7::1
...
Use case 5: Specify the maximum number of hops in the search for the target
Code:
tracert /h max_hops IP
Motivation: By default, ’tracert’ stops after 30 hops. If you want to limit the number of hops ’tracert’ explores, you can use this command.
Explanation: Replace “max_hops” with the maximum number of hops to search for the target. Replace “IP” with the IP address or hostname of the target. The ‘/h’ flag followed by the maximum number of hops limits the search to the specified number of hops.
Example output:
Tracing route to example.com [93.184.216.34]
over a maximum of 10 hops:
1 <1 ms <1 ms <1 ms 192.168.1.1
2 10 ms 10 ms 11 ms 10.10.100.1
3 10 ms 9 ms 9 ms 203.0.113.1
4 12 ms 11 ms 11 ms 203.0.113.254
5 25 ms 24 ms 24 ms 203.0.112.201
6 25 ms 24 ms 24 ms 203.0.112.202
Use case 6: Display help
Code:
tracert /?
Motivation: If you need a quick reminder of the available command-line arguments and options of the ’tracert’ command, you can use this command to display the help information.
Explanation: The ‘/?’ flag displays the help information for the ’tracert’ command.
Example output:
Usage: tracert [-d] [-h maximum_hops] [-4] [-6] target_name
Options:
-d Do not resolve addresses to hostnames.
-h maximum_hops Maximum number of hops to search for target.
-4 Force using IPv4.
-6 Force using IPv6.
Conclusion:
The ’tracert’ command is a useful network diagnostic tool for tracing the route between your PC and a target IP address. It provides valuable information about network connectivity, latency, and potential issues along the path. By understanding the different use cases of the ’tracert’ command and the available command-line arguments, you can effectively troubleshoot network problems and optimize network performance.