The traceroute is a utility tool on the Debian 12 machine that allows you to show the route of packets from source to host. It is used to debug networking problems by tracing the problems or errors behind the packets not reaching their destination. The basic concept of the traceroute command is to understand how the packets are delivered over the internet.

This guide will explain how to install and use the traceroute on a Debian 12 machine.

Installing Traceroute on Debian 12

To install the traceroute on Debian 12, simply update or upgrade the APT packages repository packages and then install the traceroute tool. The traceroute tool belongs to the net-tools package on Debian 12, so it can be installed by either installing the net-tools or the traceroute from the APT package. After that, use the traceroute command to check the route the packets take to reach the destination. 

Step 1: Update APT Package

Start the process by updating the APT packages to get the latest version of the traceroute tool from the repository:

sudo apt update

Step 2: Install Traceroute

After that, simply get the traceroute tool by installing the “net-tools” with the following command:

sudo apt install net-tools

Another Method: Install net-tools Utility

This is the alternative method of installing the traceroute tool on the Debian with the following command:

sudo apt install traceroute

Step 3: Success

After installing the traceroute tool on Windows, simply validate its success by executing the following command:

traceroute --version

Running the above command confirms that the traceroute tool is installed for Linux with version 2.1.2:

Also, check the path where the tool is installed on the system using the following command:

which traceroute

Now, that you have successfully installed the tool on your system, let’s get to its use with multiple options in the following section:

How to Use Traceroute on Debian

To use the traceroute tool on the Debian, simply use the following syntax with multiple options provided by the tool. The options are used to control the usage of the tool and extract the specific information using it from the arguments like IP address or hostname. The following code block is the syntax for using the traceroute command or tool on the Debian:

traceroute -options arguments

The traceroute tool is used to check the connectivity of the network using the argument destination server in the above command. There are about 34 different options offered by the tool to change the working of the command to extract the output differently.

To get the options with the description of the command, simply use the “–help” flag with the traceroute command:

traceroute --help

Running the above command returns the details of the options available in the traceroute tool. Now, get the options with their descriptions to get the required output according to the requirement:

Using Host Name

Now, trace the route of the packets sent to the specific hostname like google.com or micrsoft.com with the following command:

traceroute google.com

The following screenshot displays the route of packets with the routers it took to reach the destination. The “192.178.24.174” is the destination address of “google” server with 30 hops to reach the destination using the “192.168.109.2” router:

Using IP Address

You can also use the IP address of the destination to check the path sued by the packets to reach there with the following command:

traceroute 8.8.8.8

Specify the Number of Hops

You can also limit the number of hops as it returns 30 hops by default to check the route of the packet. Limiting the hops explains the process of understanding the path quickly but you can also lose some information as well:

traceroute -m 10 google.com

The following screenshot displays the details of the packet within the 10 hops as it only took one router to reach the destination:

Set Wait Time for Response

You can also set the wait time for each reply using the “-w” flag with the number of seconds to set the time using the following command:

traceroute -w 3 google.com

Getting IP Address Information

You can also use the -n flag with the traceroute command to get the address of the hop numerically:

traceroute -n google.com

Trace Packet Using Gateway

By default, the traceroute uses the default gateway of Debian, however, you can change the gateway of the route using the following command. The traceroute command does not work without the gateway configuration, so you can set the gateway as well using the “-g” flag:

traceroute -g 192.168.10.1 google.com

Using Network Interface

The Debian machine can be configured with multiple network interfaces that can be used to check the route of the packet. To get the network interface form the machine, simply use the following command:

ip a

The followings screenshot displays the network interfaces like “lo” and “ens33” with their IP addresses as displayed below:

Here, you can use the network interface extracted from the previous command with the “-i” flag to get the packet sent from the machine. The following command contains the network interface of the source file and the destination hostname:

sudo traceroute -i ens33 google.com

Here, we have used the traceroute tool using the command on the terminal with some of the options offered by the tool. You can use many other options with the destination address or hostname to extract the specific output related to packet tracing.

Bonus Tip: Uninstall the Traceroute

After using the traceroute tool in the Debian 12 machine, you can remove it from the system using the following command:

sudo apt remove traceroute

Executing the above command simply removes the tool from the system as displayed in the following screenshot:

Alternative Option: Using “autoremove” Command

Another command to remove the traceroute tool is using the “autoremove” from the machine as mentioned below. This command is used to remove the configuration files that are attached to the tool in the system:

sudo apt autoremove traceroute

That’s all about how to install and use the traceroute on a Debian 12 machine.

Conclusion

To install and use the traceroute on Debian, update the APT package and install the traceroute tool using the “install net-tools” command. You can also use the “install traceroute” command to install and then simply use the tool with more than 34 options available with the destination address. These options are there to manipulate the output of the command according to your requirements.