DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Instant Integrations With API and Logic Automation
  • How to Move System Databases to Different Locations in SQL Server on Linux
  • Python Packages for Validating Database Migration Projects
  • Building RAG Apps With Apache Cassandra, Python, and Ollama

Trending

  • Automatic Code Transformation With OpenRewrite
  • Testing SingleStore's MCP Server
  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • Is Agile Right for Every Project? When To Use It and When To Avoid It
  1. DZone
  2. Data Engineering
  3. Databases
  4. Traceroute Command in Python and How to Read a Traceroute

Traceroute Command in Python and How to Read a Traceroute

Traceroute or tracert command traces the hops between the origin and destination. In this post, we'll learn traceroute and how it helps in network troubleshooting.

By 
camimi Morales user avatar
camimi Morales
·
Updated Sep. 05, 22 · Tutorial
Likes (3)
Comment
Save
Tweet
Share
7.2K Views

Join the DZone community and get the full member experience.

Join For Free

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 a traceroute to probe for bottlenecks whenever a user complains that the 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 also will show their response times.

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

To get the usual traceroute result along with geolocation results such as country, region, cities, and much more, the system administrator can use the Python IP2Trace tool. Below is a simple demo of the features that IP2Trace brings. 

Installing 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:

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


After that, download the IP2Location BIN database files. You can get the IP2Location LITE database and download it for free.

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

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.

Python
 
sudo ip2tracepy 8.8.8.8 -d DB25.BIN 


See the result below:

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

Each line is a host or hops 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, network speed, and usage type. Analyzing these data helps to provide further insights into the root cause of the issues.

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


See the result below:


Discover what are the various options supported by the command in IP2Location Traceroute Application. You can use the command below too. 

Python
 
sudo ip2tracepy -h 

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 commands in the console.
  • Needs regular updates of the BIN file to maintain the accuracy of geolocation.

Conclusion

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

Command (computing) Python (language) operating system Database

Opinions expressed by DZone contributors are their own.

Related

  • Instant Integrations With API and Logic Automation
  • How to Move System Databases to Different Locations in SQL Server on Linux
  • Python Packages for Validating Database Migration Projects
  • Building RAG Apps With Apache Cassandra, Python, and Ollama

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!