Traceroute command and how to read a traceroute

Traceroute command and how to read a traceroute

On operating systems like Windows or Linux, there is an invaluable tool called the traceroute command (on Windows, the equivalent command is called tracert). This command-line tool enables system administrators or network engineers to troubleshoot common networking issues.

Administrators use traceroute to probe for bottlenecks whenever a user complains that connection to a website or server is slow. In addition, the traceroute command is used if a server is unreachable as it will show which particular part of the network route is problematic.

How does traceroute work?

The traceroute command works by sending out network packets to a destination host. Each host along the route will show their response times.

By analyzing the route, network engineers are able to determine if the routing is optimal. The response time provides vital clues to pinpoint which hops have latency issues.

System administrators appreciate the Python IP2Trace tool because they get the usual traceroute result along with geolocation results such as country, region, cities and much more. Below is a simple demo of the features that IP2Trace brings.

How does traceroute work

Installing the Python IP2Trace

Let’s get started with the demo. Firstly, you’ll need to install some prerequisites. NOTE: The installation steps below are for the Debian 11 Linux operating system as that’s our demo machine.

Secondly, to install Python and the IP2Trace, run the below commands:

sudo apt update
sudo apt install python3 python3-pip
sudo pip install IP2Trace

After that, download the IP2Location BIN database files.

For the paid databases, get your download from https://www.ip2location.com/database/ip2location.

For the free LITE database, you can download from https://lite.ip2location.com/ip2location-lite.

After downloading the zipped file containing the BIN, extract the BIN file out and store in our recommended folder /usr/share/ip2location. Just create the folder if it doesn’t exist.

IP2Location LITE database

A simple demo of the IP2Trace usage using DB25

It is pretty straightforward to use the IP2Trace command. Below we will query the basic geolocation data from our DB25.BIN file (default folder is the recommended folder above) for the IP address 8.8.8.8.

sudo ip2tracepy 8.8.8.8 -d DB25.BIN

Result below:

IP2Trace result

* By default, IP2Trace returns the country code, region and city when data is available.

Each line is a host or hop along the route to the final destination server. Pay close attention to the 3 numbers after the IP address. These are the response time for each of the 3 packets that were sent out.

As we’re using the DB25 database, let’s modify the command above to output more fields from the BIN file. We want to display the country code, country name, region name, city name, ISP name, the network speed and the usage type. Analyzing these data helps to provide further insights into the root cause of the issues.

sudo ip2tracepy 8.8.8.8 -d DB25.BIN -o country_code country_name region_name city_name isp net_speed usage_type

Result below:

IP2Trace result

As you can see, anyone can use the IP2Trace command. Discover what are the various options supported by the command in IP2Location Traceroute Application . You can use the command below too.

sudo ip2tracepy -h

Conclusion

Traceroute is a command-line tool commonly used by network and system administrators. For instance, system administrators use traceroute to monitor the internet connectivity. It helps to visualize the traffic path including packet loss and high latency.

PROS

  • IP2Trace improves on the existing traceroute command by adding the geolocation info.
  • Geolocation data can make troubleshooting network issues easier.
  • It is easier to install the Python IP2Trace compared to the C IP2Trace.

CONS

  • Require installation of Python to function.
  • Must have experience in running command in console.
  • Needs regular update of the BIN file to maintain accuracy of geolocation.

Was this article helpful?

Related Articles