Cyberithub

17 traceroute command examples to Identify Network Problems in Linux/Unix

In this article, I will take you through 17 traceroute command examples to Identify Network Problems in Linux/Unix. traceroute command is a network diagnostic tool used in Linux based Systems to check and identify the network connectivity problems from source to destination. By default it will send the 60 byte packets for max 30 hops after that it will drop the packets.

Using this tool, you will be able to see the number of hops it takes for a packets to reach the destination and also the av.time it takes on each hops. So this is a very useful tool to understand and use if you are planning to perform some network troubleshooting. You can check How to Install traceroute command on RHEL/CentOS 7/8 Using 5 Easy Steps to know more about the traceroute tool installation.

SYNOPSIS

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]

How does traceroute command works

traceroute tracks the route packets taken from an IP network on their way to a given host. It utilizes the IP protocol’s time to live (TTL) field and attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to the host. More can be checked on traceroute command Man Page.

17 traceroute command examples to Identify Network Problems in Linux/Unix 1

traceroute command examples in Linux/Unix 

Also Read: Best Steps to Install Perl on RHEL/CentOS 8

Example 1: How to Check traceroute command version on Linux

If you want to check traceroute command version then you need to use traceroute --version command as shown below. As shown from below output, current traceroute command version is 2.0.22.

[root@localhost ~]# traceroute --version
Modern traceroute for Linux, version 2.0.22
Copyright (c) 2008 Dmitry Butskoy, License: GPL v2 or any later

NOTE:

Please note that here I am using root user to run all the below commands.You can use any user with sudo access to run all these commands. For more information Please check Step by Step: How to Add User to Sudoers to provide sudo access to the User.

Example 2: How to trace google.com using traceroute command on Linux

If you want to trace the path to a URL or Server then you need to use below traceroute command. In this example, we are trying to trace the path of google.com URL using traceroute google.com command as shown below.

[root@localhost ~]# traceroute google.com
traceroute to google.com (172.217.163.46), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 2.930 ms 4.297 ms 4.274 ms
2 10.234.0.1 (10.234.0.1) 4.699 ms 5.515 ms 5.187 ms
3 vod.corp.us (202.10.11.43) 4.991 ms 4.842 ms 4.790 ms
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 7.530 ms 7.098 ms 6.899 ms
5 172.31.167.58 (172.31.167.58) 17.318 ms 16.652 ms 16.489 ms
6 14.140.100.6.static-vsnl.net.us (14.140.100.6) 16.250 ms 11.662 ms 9.417 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 12.219 ms 9.518 ms 11.715 ms
8 121.240.1.50 (121.240.1.50) 14.792 ms 10.419 ms 12.549 ms
9 74.125.242.145 (74.125.242.145) 12.190 ms 74.125.242.129 (74.125.242.129) 13.462 ms 74.125.242.145 (74.125.242.145) 11.730 ms
10 216.239.42.215 (216.239.42.215) 10.338 ms 9.545 ms 9.834 ms
11 maa05s01-in-f14.1e100.net (172.217.163.46) 9.484 ms 12.134 ms 11.207 ms

Example 3: How to Use ICMP Echo for Probes

If you want to use ICMP Echo for probing the remote address then you need to use -I option with traceroute command as shown below. In this example, we are tracing the path of google.com address using ICMP Echo by running traceroute -I google.com command.

[root@localhost ~]# traceroute -I google.com
traceroute to google.com (172.217.163.174), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 7.029 ms 6.884 ms 6.854 ms
2 10.234.0.1 (10.234.0.1) 11.485 ms 11.406 ms 8.360 ms
3 vod.corp.us (202.83.20.43) 11.379 ms 10.513 ms 10.342 ms
4 24.11.145.5.static-vegas.nl.net.us (14.141.145.5) 7.172 ms 7.182 ms 7.157 ms
5 172.31.167.58 (172.31.167.58) 12.972 ms 12.981 ms 12.583 ms
6 14.140.100.6.static-vegas.net.us (14.140.100.6) 11.297 ms 12.001 ms 10.234 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 12.171 ms 11.763 ms 11.488 ms
8 121.240.1.50 (121.240.1.50) 11.124 ms 10.666 ms 10.316 ms
9 74.125.242.129 (74.125.242.129) 11.428 ms 10.382 ms 12.757 ms
10 209.85.248.181 (209.85.248.181) 11.167 ms 11.024 ms 10.086 ms
11 maa05s05-in-f14.1e100.net (172.217.163.174) 11.686 ms 8.811 ms 8.600 ms

-I : Use ICMP ECHO for probes. More on traceroute command Man Page.

Example 4: How to Use TCP SYN for Probes

If you want to use TCP SYN for probing the remote address then you need to use -T option with traceroute command as shown below.

[root@localhost ~]# traceroute -T google.com
traceroute to google.com (172.217.31.206), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 2.050 ms 3.041 ms 2.819 ms
2 10.234.0.1 (10.234.0.1) 3.771 ms 3.749 ms 3.716 ms
3 * * *
4 * * *
5 * * *
6 14.140.100.6.static-vegas.net.us (14.140.100.6) 12.234 ms 13.070 ms 12.644 ms
7 * * *
8 * * *
9 108.170.253.97 (108.170.253.97) 11.451 ms 108.170.253.113 (108.170.253.113) 13.403 ms 108.170.253.97 (108.170.253.97) 13.886 ms
10 74.125.253.13 (74.125.253.13) 9.523 ms 11.963 ms 11.388 ms
11 maa03s28-in-f14.1e100.net (172.217.31.206) 10.477 ms 10.222 ms 8.391 ms

-T : Use TCP SYN for probes. More on traceroute command Man Page.

Example 5: How to Specify with what TTL to start

If you want to specify the TTL value from where traceroute should start instead of showing from default TTL value 1 then you need to specify it with -f option as shown below. In this example we are trying to start from TTL 8 using traceroute -f 8 google.com command.

[root@localhost ~]# traceroute -f 8 google.com
traceroute to google.com (172.217.163.78), 30 hops max, 60 byte packets
8 121.240.1.50 (121.240.1.50) 8.097 ms 9.868 ms 9.756 ms
9 74.125.242.129 (74.125.242.129) 9.691 ms 11.090 ms 74.125.242.145 (74.125.242.145) 9.414 ms
10 216.239.42.237 (216.239.42.237) 9.272 ms 216.239.42.243 (216.239.42.243) 9.173 ms 216.239.42.237 (216.239.42.237) 9.122 ms
11 maa05s02-in-f14.1e100.net (172.217.163.78) 9.082 ms 10.683 ms 17.172 ms

-f : Specifies with what TTL to start. Defaults to 1. More on traceroute command Man Page.

Example 6: How to Specify the maximum number of hops

If you want to specify the maximum number of hops then you need to specify it with -m option as shown below. In this example, we are trying to assign maximum hop as 5 using traceroute -m 5 google.com command.

[root@localhost ~]# traceroute -m 5 google.com
traceroute to google.com (172.217.163.206), 5 hops max, 60 byte packets
1 gateway (192.168.0.1) 3.386 ms 2.099 ms 7.492 ms
2 10.234.0.1 (10.234.0.1) 7.293 ms 4.822 ms 5.269 ms
3 vod.corp.us (202.10.11.43) 4.768 ms 4.551 ms 4.351 ms
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 9.237 ms 8.814 ms 8.413 ms
5 172.31.167.58 (172.31.167.58) 13.218 ms 12.602 ms 11.367 ms

-m : Specify maximum number of hops. More on traceroute command Man Page.

Example 7: How to Specify the Interface through which traceroute should send packets

If you want to specify the interface through which traceroute should send packets instead of using the default then you need to mention it using -i option as shown below. In this example we want to use interface enp0s3 through which traceroute should send packets to google.com using traceroute -i enp0s3 google.com command as shown below.

[root@localhost ~]# traceroute -i enp0s3 google.com
traceroute to google.com (172.217.163.206), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 6.145 ms 7.116 ms 7.086 ms
2 10.234.0.1 (10.234.0.1) 8.537 ms 8.600 ms 8.452 ms
3 vod.corp.us (202.10.11.43) 8.341 ms 8.320 ms 8.296 ms
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 8.359 ms 8.375 ms 8.353 ms
5 172.31.167.58 (172.31.167.58) 15.238 ms 18.928 ms 18.867 ms
6 14.140.100.6.static-nl.net.us (14.140.100.6) 18.675 ms 11.777 ms 12.137 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 9.379 ms 10.284 ms 9.399 ms
8 121.240.1.50 (121.240.1.50) 9.020 ms 8.608 ms 8.749 ms
9 74.125.242.145 (74.125.242.145) 10.394 ms 74.125.242.129 (74.125.242.129) 10.141 ms 74.125.242.145 (74.125.242.145) 8.833 ms
10 209.85.248.219 (209.85.248.219) 10.040 ms 209.85.248.211 (209.85.248.211) 10.864 ms 209.85.248.219 (209.85.248.219) 11.850 ms
11 maa05s06-in-f14.1e100.net (172.217.163.206) 11.711 ms 9.415 ms 11.410 ms

-i : Specifies the interface through which traceroute should send packets. More on traceroute command Man Page.

Example 8: How to choose an alternative Source Address

If you want to choose an alternative source address instead of using the default one to perform traceroute operation then you need to specify the address using -s option as shown below. In this example, we are trying to choose source address 192.168.0.103 using traceroute -s 192.168.0.103 google.com command.

[root@localhost ~]# traceroute -s 192.168.0.103 google.com
traceroute to google.com (172.217.26.174), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 6.093 ms 5.931 ms 5.869 ms
2 10.234.0.1 (10.234.0.1) 5.674 ms 3.217 ms 3.164 ms
3 * * *
4 24.11.145.5.static-vod.nl.net.us (24.11.145.5) 3.092 ms 4.060 ms 3.930 ms
5 172.31.167.58 (172.31.167.58) 10.823 ms 12.604 ms 11.476 ms
6 14.140.100.6.static-nl.net.us (14.140.100.6) 11.935 ms 10.335 ms 11.712 ms
7 * * *
8 121.240.1.50 (121.240.1.50) 9.339 ms 11.052 ms 9.659 ms
9 108.170.253.113 (108.170.253.113) 8.946 ms 108.170.253.97 (108.170.253.97) 9.556 ms 9.531 ms
10 74.125.253.65 (74.125.253.65) 9.986 ms 209.85.243.49 (209.85.243.49) 10.664 ms 9.769 ms
11 maa03s22-in-f174.1e100.net (172.217.26.174) 8.459 ms 8.917 ms 8.605 ms

-s : Chooses an alternative source address. More on traceroute command Man Page.

Example 9: How to Disable IP Address and Host Name Mapping

If you want to disable IP Address and Host name mapping while performing traceroute then you need to use -n option as shown below.

[root@localhost ~]# traceroute google.com -n
traceroute to google.com (172.217.163.206), 30 hops max, 60 byte packets
1 192.168.0.1 2.968 ms 3.576 ms 3.295 ms
2 10.234.0.1 4.139 ms 5.028 ms 4.983 ms
3 * * *
4 24.11.145.5 4.501 ms 4.270 ms 4.151 ms
5 172.31.167.58 12.066 ms 14.818 ms 14.586 ms
6 14.140.100.6 12.639 ms 14.495 ms 14.117 ms
7 115.112.71.65 13.940 ms 11.260 ms 11.569 ms
8 121.240.1.50 9.739 ms 11.625 ms 10.988 ms
9 74.125.242.129 12.802 ms 12.952 ms 74.125.242.145 11.690 ms
10 209.85.248.219 14.091 ms 209.85.248.211 14.460 ms 15.379 ms
11 172.217.163.206 13.337 ms 13.663 ms 12.237 ms

-n : Do not try to map IP addresses to host names when displaying them. More on traceroute command Man Page.

Example 10: How to Configure Response Wait Time

If you want to configure response wait time then you need to configure it using -w option as shown below. In this example, we are trying to configure response wait time to 3 seconds using traceroute google.com -w 3 command.

[root@localhost ~]# traceroute google.com -w 3
traceroute to google.com (216.58.197.78), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 1.802 ms 2.981 ms 2.932 ms
2 10.234.0.1 (10.234.0.1) 4.216 ms 4.204 ms 4.182 ms
3 * * *
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 7.851 ms 7.841 ms 7.805 ms
5 172.31.167.58 (172.31.167.58) 11.782 ms 12.274 ms 10.969 ms
6 14.140.100.6.static-nl.net.us (14.140.100.6) 10.872 ms 11.043 ms 13.291 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 17.182 ms 17.099 ms 16.902 ms
8 121.240.1.50 (121.240.1.50) 16.783 ms 16.231 ms 16.681 ms
9 108.170.253.97 (108.170.253.97) 16.445 ms 108.170.253.113 (108.170.253.113) 15.490 ms 108.170.253.97 (108.170.253.97) 16.205 ms
10 108.170.236.197 (108.170.236.197) 15.325 ms 15.240 ms 108.170.237.95 (108.170.237.95) 15.124 ms
11 maa03s21-in-f78.1e100.net (216.58.197.78) 14.695 ms 11.134 ms 10.688 ms

-w : Set the time (in seconds) to wait for a response to a probe (default 5.0 sec). More on traceroute command Man Page.

Example 11: How to Configure Number of Queries for a Hop

If you want to configure the number of queries for a hop then you need to specify it with -q option as shown below. In this example, we are trying to configure the number of queries to 4 for a hop using traceroute google.com -q 4 command.

[root@localhost ~]# traceroute google.com -q 4
traceroute to google.com (172.217.160.142), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 1.714 ms 2.356 ms 2.309 ms 2.269 ms
2 10.234.0.1 (10.234.0.1) 4.051 ms 3.930 ms 3.957 ms 3.872 ms
3 vod.corp.us (202.13.10.43) 3.822 ms * * *
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 4.814 ms 4.807 ms 4.781 ms 4.722 ms
5 172.31.167.58 (172.31.167.58) 11.064 ms 13.523 ms 14.209 ms 14.097 ms
6 14.140.100.6.static-vegas.net.us (14.140.100.6) 14.033 ms 12.937 ms 13.954 ms 13.629 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 12.610 ms 16.961 ms 16.800 ms 16.610 ms
8 121.240.1.50 (121.240.1.50) 12.842 ms 12.647 ms 12.606 ms 11.076 ms
9 108.170.253.113 (108.170.253.113) 10.570 ms 9.752 ms 108.170.253.97 (108.170.253.97) 15.658 ms 108.170.253.113 (108.170.253.113) 9.625 ms
10 216.239.59.171 (216.239.59.171) 11.420 ms 216.239.59.231 (216.239.59.231) 11.389 ms 11.072 ms 216.239.59.171 (216.239.59.171) 10.879 ms
11 maa03s29-in-f14.1e100.net (172.217.160.142) 12.330 ms 12.162 ms 12.107 ms 9.174 ms

-q : Sets the number of probe packets per hop. The default is 3. More on traceroute command Man Page.

Example 12: How to not allow the Probe Packet Fragmentation

If you do not want to allow the Probe Packet Fragmentation then you need to use -F option as shown below.

[root@localhost ~]# traceroute -F google.com
traceroute to google.com (142.250.67.78), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 2.144 ms 2.303 ms 2.240 ms
2 10.234.0.1 (10.234.0.1) 10.255 ms 9.832 ms 9.583 ms
3 vod.corp.us (202.83.20.43) 21.257 ms 21.095 ms 20.362 ms
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 7.923 ms 7.545 ms 7.378 ms
5 172.31.167.58 (172.31.167.58) 14.817 ms 14.504 ms 17.878 ms
6 14.140.100.6.static-vsnl.net.in (14.140.100.6) 17.395 ms 11.969 ms 11.609 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 18.764 ms 21.123 ms 20.740 ms
8 121.240.1.50 (121.240.1.50) 20.268 ms 16.730 ms 19.768 ms
9 74.125.242.145 (74.125.242.145) 16.066 ms 11.168 ms 10.567 ms
10 142.250.228.223 (142.250.228.223) 11.340 ms 12.655 ms 12.486 ms
11 maa05s13-in-f14.1e100.net (142.250.67.78) 12.072 ms 10.342 ms 12.207 ms

-F : Do not fragment probe packets. More on traceroute command Man Page.

Example 13: How to route the packet through gateway

If you want to route the packet through a specific gateway then you need to specify the gateway using -g option as shown below. In this example, we are trying to route the packets to google.com through gateway 192.168.0.1 using traceroute -g 192.168.0.1 google.com command.

[root@localhost ~]# traceroute -g 192.168.0.1 google.com
traceroute to google.com (172.217.163.206), 30 hops max, 72 byte packets
1 * * *
2 * * *
3 * * *
4 * * *
5 * * *
6 * * *
7 * * *
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *
16 * * *
17 * * *

-g : Tells traceroute to add an IP source routing option to the outgoing packet that tells the network to route the packet through the specified gateway. More on traceroute command Man Page.

Example 14: How to set the full packet length

If you want to specify the full packet length instead of using default 60 bytes then you specify with traceroute command as shown below. In this example we are setting the full packet length to 90 using traceroute google.com 90 command.

[root@localhost ~]# traceroute google.com 90
traceroute to google.com (172.217.163.206), 30 hops max, 90 byte packets
1 gateway (192.168.0.1) 9.928 ms 9.704 ms 9.213 ms
2 10.234.0.1 (10.234.0.1) 11.088 ms 10.872 ms 10.429 ms
3 * * *
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 9.334 ms 9.115 ms 9.331 ms
5 172.31.167.58 (172.31.167.58) 15.852 ms 16.318 ms 16.301 ms
6 14.140.100.6.static-nl.net.us (14.140.100.6) 14.539 ms 18.649 ms 18.500 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 19.599 ms 11.883 ms 11.775 ms
8 121.240.1.50 (121.240.1.50) 27.126 ms 22.405 ms 26.937 ms
9 74.125.242.145 (74.125.242.145) 22.228 ms 74.125.242.129 (74.125.242.129) 25.483 ms 25.388 ms
10 209.85.248.211 (209.85.248.211) 26.415 ms 209.85.248.219 (209.85.248.219) 26.224 ms 25.838 ms
11 maa05s06-in-f14.1e100.net (172.217.163.206) 24.290 ms 24.106 ms 21.089 ms

Example 15: How to Change the Destination Port

If you want to change the destination port then you need to specify using -p option as shown below. In this example, we are changing the destination port to 30287 using traceroute -p 30287 google.com command.

[root@localhost ~]# traceroute -p 30287 google.com
traceroute to google.com (172.217.163.110), 30 hops max, 60 byte packets
1 gateway (192.168.0.1) 5.234 ms 11.245 ms 11.100 ms
2 10.234.0.1 (10.234.0.1) 10.939 ms 10.789 ms 10.657 ms
3 vod.actcorp.in (202.10.11.43) 10.550 ms 10.333 ms 10.202 ms
4 24.11.145.5.static-vegas.nl.net.us (24.11.145.5) 12.354 ms 12.411 ms 12.269 ms
5 172.31.167.58 (172.31.167.58) 20.658 ms 20.598 ms 16.813 ms
6 14.140.100.6.static-nl.net.in (14.140.100.6) 11.400 ms 12.133 ms 18.693 ms
7 115.112.71.65.STDILL-vegas.nl.net.us (115.112.71.65) 22.677 ms 22.338 ms 22.252 ms
8 * * *
9 * * *
10 * * *
11 * * *
12 * * *
13 * * *
14 * * *
15 * * *

-p : For UDP tracing, specifies the destination port base traceroute will use. For TCP and others specifies just the (constant) destination port to connect. More on traceroute command Man Page.

Example 16: How to Check all the traceroute available Options

If you want to check all the options available with traceroute command then you need to use traceroute --help command as shown below.

[root@localhost ~]# traceroute --help
Usage:
traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w waittime ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ]
Options:
-4 Use IPv4
-6 Use IPv6
-d --debug Enable socket level debugging
-F --dont-fragment Do not fragment packets
-f first_ttl --first=first_ttl
Start from the first_ttl hop (instead from 1)
-g gate,... --gateway=gate,...
Route packets through the specified gateway
(maximum 8 for IPv4 and 127 for IPv6)
-I --icmp Use ICMP ECHO for tracerouting
-T --tcp Use TCP SYN for tracerouting (default port is 80)
-i device --interface=device
Specify a network interface to operate with
-m max_ttl --max-hops=max_ttl
Set the max number of hops (max TTL to be
reached). Default is 30

Example 17: How to Check Man Page of traceroute command

If you want to check the Man Page of traceroute command then you need to use man traceroute command as shown below.

[root@localhost ~]# man traceroute
TRACEROUTE(8) Traceroute For Linux TRACEROUTE(8)

NAME
traceroute - print the route packets trace to network host

SYNOPSIS
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]
traceroute6 [options]

DESCRIPTION
traceroute tracks the route packets taken from an IP network on their way to a given host. It utilizes the IP protocol's time to live (TTL) field and
attempts to elicit an ICMP TIME_EXCEEDED response from each gateway along the path to the host.

traceroute6 is equivalent to traceroute -6

 

 

 

 

 

 

Recommended Posts:-

15 Practical Bash For Loop Examples in Linux/Unix for Professionals

8 Easy Ways to check Ubuntu Version using Bash Command Line

5 Easy Steps to Install Openssh-Server on Ubuntu 20.04 to Enable SSH 

How to Install Rust Programming Language in Linux Using 6 Best Steps

10 Useful iproute2 tools examples to Manage Network Connections in Linux

How to Limit CPU Limit of a Process Using CPULimit in Linux (RHEL/CentOS 7/8)

6 Popular Methods to List All Running Services Under Systemd in Linux

Unix/Linux Find Files and Directories Owned By a Particular User(5 Useful Examples)

33 Practical Examples of ulimit command in Linux/Unix for Professionals

Leave a Comment