Mastering Traceroute: A Step-by-Step Guide for Windows Users
Traceroute is a network diagnostic tool that allows users to trace the route taken by network packets from their computer to a specified destination host or IP address on the internet. It displays the sequence of routers or “hops” that the packets traverse, along with the time it takes for each hop. This information can be used to troubleshoot network connectivity issues, identify network latency or congestion, and help to optimize network performance.
Windows comes with a default traceroute tool called “tracert” that simplifies the process of tracing network packets to their intended destination.. To run the tracert tool, open the command prompt window by typing “cmd” in the Windows search bar.
tracert <destination>
The tracert command shows the Round-Trip Time (RTT) for each hop and its associated IP address. Here’s an example:
However, if you want detailed information about the country name, region name, city name, ISP, domain name, etc., for each hop, you need to use a third-party tool that can provide this information.
In this article, I will provide a step-by-step guide on how to use IP2Trace, an alternative tool that not only provides traceroute hop results but also more granular information about each hop. This tool is written in Python and requires Python to be installed on your machine.
Step 1:
Download IP address database in BIN format that we are going to use in IP2Trace. This database will be used to provide you the geolocation information about each hop. You can sign up a free account and download the free IP geolocation database or purchase at IP2Location.com.
Step 2:
IP2Trace will also require the IP2Location Python library to be installed. The pip will install the dependencies for you, but if it doesn’t, you can always manually install it by using:
pip install IP2Location
Step 3:
To install the IP2Trace, use the following command in your command prompt:
pip install IP2Trace
You will see a success message if the installation is successful:
Step 4:
IP2Trace should have been installed by now. To test whether it is working correctly or not, run the following command to print the IP2Trace version information:
ip2tracepy -v
You will the version information is printed out as below:
Step 5:
After installing the ip2trace, you can now use the tool to trace the IP address with geolocation information. A basic usage of ip2trace will look like this:
ip2tracepy -p <destination_ip> -d <IP2Location_BIN_database_filepath> -a
You should substitute the <destination_ip> with the IP address that you want to traceroute on, and replace the <IP2Location_BIN_database_filepath> with the filepath of the downloaded IP2Location BIN database.
You will see the output generated like this:
Step 6:
You can also choose to customize the output fields of the geolocation information according to your needs. For example, if you want to see only the country name, region name and city name, you can run this command:
ip2tracepy <destination_ip> -d <IP2Location_BIN_database_filepath> -o country_name, region_name, city_name
The -o
here will set the fields to be output with.
The available columns are:
country_code, country_name, region_name, city_name, isp, latitude, longitude, domain, zip_code, time_zone, net_speed, idd_code, area_code, weather_station_code, weather_station_name, mcc, mnc, mobile_brand, elevation, usage_type, address_type, category, district, asn, as_name.
After running the command, you will see the output like this:
Step 7:
In addition, you can also traceroute a hostname directly without the need of translating it to the corresponding IP address beforehand. For example, to traceroute the bing.com, you can use this command to do so:
ip2tracepy -p bing.com -d <IP2Location_BIN_database_filepath> -o country_name, region_name, city_name
Here we replace the destination IP address with the destination hostname. The output for this example is shown below:
In conclusion, traceroute is a powerful network diagnostic tool that can help you troubleshoot network connectivity issues, identify network latency or congestion, and optimize network performance. By using IP2Trace, you can easily run traceroute in Windows and analyze the results to gain insights into your network, ensuring the reliability, performance, and security of your network infrastructure.