in

LinuxLinux

Traceroute Command For Linux: Syntax & Examples

Article about Traceroute command for Linux includes syntax and examples!

Traceroute Command For Linux

T

raceroute command for Linux: Traceroute is mainly used to find the network path packets between the computer and destination server. Traceroute exploits the TTL of any server which is connected to the network. All the network packets have certain hops or bounces that they can make between the computers and servers before they dropped automatically. This feature eliminates the lost packets from being passed around the network.

When the packets bounced from one computer to another it loses one of its packets. The computer will pass the bouncing packets to the next system until it drops to zero. Once it became zero, the computer will send the message to the sender that it dropped the packet because the TTL is expired.
Traceroute will use the “expired” message to test the route between the source and the destination server. It will send one packet with live TTL and the first destination will drop it and send the expired message with its IP Address. Now, traceroute will send another two packet with live TTL to the second destination server. The second destination server will drop one packet and send to another destination server with live TTL. This process will continue until traceroute find or reach out to the target.

Jump To:

Installing Traceroute in Linux:

Traceroute is not a default utility in Linux. You need to install on your pc. Below we provided the list of installation command of traceroute for different Linux distros.

Ubuntu or Debian:

$sudo apt install traceroute

Fedora:

$sudo dnf install traceroute

Arch Linux:

$sudo pacman -S traceroute

Open Suse:

$sudo zypper in traceroute

Traceroute Command-List Table:

To find the options that are availble in Traceroute, open the terminal and enter the command: “traceroute” and hit enter button. The output of the command is,

Output:
Usage:
  traceroute [ -46dFITnreAUDV ] [ -f first_ttl ] [ -g gate,... ] [ -i device ] [ -m max_ttl ] [ -N squeries ] [ -p port ] [ -t tos ] [ -l flow_label ] [ -w MAX,HERE,NEAR ] [ -q nqueries ] [ -s src_addr ] [ -z sendwait ] [ --fwmark=num ] host [ packetlen ]

The traceroute options are:

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
  -N squeries  --sim-queries=squeries
                              Set the number of probes to be tried
                              simultaneously (default is 16)
  -n                          Do not resolve IP addresses to their domain names
  -p port  --port=port        Set the destination port to use. It is either
                              initial udp port value for "default" method
                              (incremented by each probe, default is 33434), or
                              initial seq for "icmp" (incremented as well,
                              default from 1), or some constant destination
                              port for other methods (with default of 80 for
                              "tcp", 53 for "udp", etc.)
  -t tos  --tos=tos           Set the TOS (IPv4 type of service) or TC (IPv6
                              traffic class) value for outgoing packets
  -l flow_label  --flowlabel=flow_label
                              Use specified flow_label for IPv6 packets
  -w MAX,HERE,NEAR  --wait=MAX,HERE,NEAR
                              Wait for a probe no more than HERE (default 3)
                              times longer than a response from the same hop,
                              or no more than NEAR (default 10) times than some
                              next hop, or MAX (default 5.0) seconds (float
                              point values allowed too)
  -q nqueries  --queries=nqueries
                              Set the number of probes per each hop. Default is
                              3
  -r                          Bypass the normal routing and send directly to a
                              host on an attached network
  -s src_addr  --source=src_addr
                              Use source src_addr for outgoing packets
  -z sendwait  --sendwait=sendwait
                              Minimal time interval between probes (default 0).
                              If the value is more than 10, then it specifies a
                              number in milliseconds, else it is a number of
                              seconds (float point values allowed too)
  -e  --extensions            Show ICMP extensions (if present), including MPLS
  -A  --as-path-lookups       Perform AS path lookups in routing registries and
                              print results directly after the corresponding
                              addresses
  -M name  --module=name      Use specified module (either builtin or external)
                              for traceroute operations. Most methods have
                              their shortcuts (`-I' means `-M icmp' etc.)
  -O OPTS,...  --options=OPTS,...
                              Use module-specific option OPTS for the
                              traceroute module. Several OPTS allowed,
                              separated by comma. If OPTS is "help", print info
                              about available options
  --sport=num                 Use source port num for outgoing packets. Implies
                              `-N 1'
  --fwmark=num                Set firewall mark for outgoing packets
  -U  --udp                   Use UDP to particular port for tracerouting
                              (instead of increasing the port per each probe),
                              default port is 53
  -UL                         Use UDPLITE for tracerouting (default dest port
                              is 53)
  -D  --dccp                  Use DCCP Request for tracerouting (default port
                              is 33434)
  -P prot  --protocol=prot    Use raw packet of protocol prot for tracerouting
  --mtu                       Discover MTU along the path being traced. Implies
                              `-F -N 1'
  --back                      Guess the number of hops in the backward path and
                              print if it differs
  -V  --version               Print version info and exit
  --help                      Read this help and exit

Arguments:
+     host          The host to traceroute to
      packetlen     The full packet length (default is the length of an IP
                    header plus 40). Can be ignored or increased to a minimal
                    allowed value

Basic Usage of Traceroute Command:

Here, we will share you the basic usage of traceroute command with examples

$traceroute tecrobust.com

The output of the above command is,

Check this too  GZip Command in Linux: Essential GZip Command Syntax & Examples
[email protected]:~$ traceroute tecrobust.com
traceroute to tecrobust.com (104.31.66.44), 30 hops max, 60 byte packets
 1  _gateway (192.168.1.1)  6.026 ms  5.900 ms  6.040 ms
 2  * * *
 3  10.72.173.130 (10.72.173.130)  40.863 ms 10.72.173.194 (10.72.173.194)  44.518 ms  49.878 ms
 4  172.25.106.116 (172.25.106.116)  50.408 ms 172.25.106.120 (172.25.106.120)  50.728 ms  50.971 ms
 5  172.25.106.119 (172.25.106.119)  50.068 ms  50.445 ms 172.25.106.123 (172.25.106.123)  50.893 ms
 6  172.25.8.10 (172.25.8.10)  49.488 ms  39.637 ms  49.358 ms
 7  * * *
 8  * * *
 9  * * *
10  103.198.140.62 (103.198.140.62)  52.145 ms 103.198.140.182 (103.198.140.182)  52.628 ms 103.198.140.62 (103.198.140.62)  40.290 ms
11  49.45.4.82 (49.45.4.82)  79.721 ms  82.910 ms 103.198.140.17 (103.198.140.17)  87.076 ms
12  103.198.140.17 (103.198.140.17)  76.053 ms 49.45.4.82 (49.45.4.82)  70.809 ms 103.198.140.17 (103.198.140.17)  83.790 ms
13  162.158.160.241 (162.158.160.241)  91.806 ms  87.222 ms  78.612 ms
14  104.31.66.44 (104.31.66.44)  71.376 ms  84.064 ms  82.351 ms

Essential Flag options:

You can use the traceroute option along with IPv4 or IPv6 flag, use the following command:

$traceroute -6 tecrobust.com

The output of the command is,

[email protected]:~$ traceroute -6 tecrobust.com
traceroute to tecrobust.com (2606:4700:30::681f:422c), 30 hops max, 80 byte packets
 1  2409:4072:916:f651:bb:a3ff:fe89:2863 (2409:4072:916:f651:bb:a3ff:fe89:2863)  6.215 ms  6.066 ms  5.998 ms
 2  * * *
 3  2405:200:363:a161:4::ff02 (2405:200:363:a161:4::ff02)  44.239 ms  44.215 ms 2405:200:363:a161:4::ff03 (2405:200:363:a161:4::ff03)  44.176 ms
 4  2405:200:801:900::d46 (2405:200:801:900::d46)  44.150 ms 2405:200:801:900::d42 (2405:200:801:900::d42)  44.120 ms 2405:200:801:900::d46 (2405:200:801:900::d46)  44.094 ms
 5  * * *
 6  * * *
 7  * * *
 8  * * *
 9  2400:cb00:35:3::a29e:a0de (2400:cb00:35:3::a29e:a0de)  101.750 ms 2400:cb00:35:3::a29e:a0f1 (2400:cb00:35:3::a29e:a0f1)  66.855 ms  77.735 ms
10  2400:cb00:35:1024::a29e:a10d (2400:cb00:35:1024::a29e:a10d)  67.454 ms  72.832 ms 2400:cb00:35:1024::a29e:a136 (2400:cb00:35:1024::a29e:a136)  75.463 ms

You can test a specific port with traceroute, use the below command:

$traceroute -p 22 tecrobust.com

The output of the above command is,

[email protected]:~$ traceroute -p 22 tecrobust.com
traceroute to tecrobust.com (104.31.67.44), 30 hops max, 60 byte packets
 1  _gateway (192.168.1.1)  6.495 ms  6.391 ms  6.257 ms
 2  * * *
 3  10.72.173.194 (10.72.173.194)  55.130 ms 10.72.173.131 (10.72.173.131)  55.061 ms 10.72.173.130 (10.72.173.130)  55.168 ms
 4  172.25.106.118 (172.25.106.118)  55.144 ms  69.477 ms 172.25.106.116 (172.25.106.116)  55.105 ms
 5  172.25.106.123 (172.25.106.123)  54.944 ms 172.25.106.119 (172.25.106.119)  54.922 ms  55.025 ms
 6  172.25.8.10 (172.25.8.10)  54.869 ms  54.643 ms  65.730 ms
 7  * * *
 8  * * *
 9  * * *
10  103.198.140.182 (103.198.140.182)  65.519 ms 103.198.140.62 (103.198.140.62)  51.563 ms 103.198.140.184 (103.198.140.184)  52.095 ms
11  103.198.140.17 (103.198.140.17)  73.427 ms 103.198.140.15 (103.198.140.15)  81.981 ms 49.45.4.82 (49.45.4.82)  73.861 ms
12  103.198.140.15 (103.198.140.15)  82.596 ms 103.198.140.89 (103.198.140.89)  75.897 ms 103.198.140.15 (103.198.140.15)  69.430 ms
13  * * *
14  * * *
15  * * *
16  * * *
17  * * *
18  * * *
19  * * *
20  * * *
21  * * *
22  * * *
23  * * *
24  * * *
25  * * *
26  * * *
27  * * *
28  * * *
29  * * *
30  * * *
[email protected]:~$ 

You can control the traceroute initializtion and finalization manually, use the following command:

$traceroute -f 2 -m 8 tecrobust.com
The output of the above command is,

[email protected]:~$ traceroute -f 2 -m 8 tecrobust.com
traceroute to tecrobust.com (104.31.66.44), 8 hops max, 60 byte packets
 2  * * *
 3  10.72.173.195 (10.72.173.195)  53.732 ms  53.709 ms 10.72.173.131 (10.72.173.131)  53.681 ms
 4  172.25.106.118 (172.25.106.118)  53.649 ms 172.25.106.116 (172.25.106.116)  53.631 ms 172.25.106.120 (172.25.106.120)  53.588 ms
 5  172.25.106.117 (172.25.106.117)  53.550 ms  53.526 ms 172.25.106.123 (172.25.106.123)  53.498 ms
 6  172.25.8.10 (172.25.8.10)  51.966 ms  51.949 ms  51.912 ms
 7  * * *
 8  * * *
[email protected]:~$ 

Verdict:

That’s it. We reached the end of this tutorial. We shared the list of option can be used with traceroute with some essential examples. Traceroute commands plays the vital role in networking. If you have any query related to this topic and then feel free to comment us below.

Check this too  DF Command in Linux: DF Command to Check Disk Space in Linux
Article Review
  • Content Explanation
  • Commands Provided
  • Options Listed
  • Examples Provided
4.8

Summary

For more articles, Kindly visit our Homepage

Leave a Reply

Your email address will not be published. Required fields are marked *

Written by Julian

Hello Folks! I'm Julian, Promoted to the Content writer for the category of Commands & Web Apps in Tec Robust. Enjoy my content & Learn more Linux Commands!

Contact me:
tecrobust [@] gmail.com
Sub: Message to Julian

VI Command List in Linux

25+ VI Command in Linux: Essential VI Editor Command Tutorials

Find IP Address in Linux

How to Find IP Address in Linux?