Git Product home page Git Product logo

ip2trace-python's Introduction

IP2Trace Python

IP2Trace Python is a Python tool allowing user to get IP address information such as country, region, city, latitude, longitude, zip code, time zone, ISP, domain name, connection type, area code, weather, mobile network, elevation, usage type, address type, IAB category, district, autonomous system number (ASN) and autonomous system (AS) from traceroute probes IP address.

Note: This tool requires Python 2.7, or Python 3.5 or later.

Installation

You can install this tool by using pip in Windows or Linux. To install this tool in Windows and Linux, just type pip install IP2Trace in your console and IP2Trace will be installed in your machine.

Note: This tool require IP2Location library to work with. If pip did not install the dependency for you, you can manually install it by using pip install IP2Location.

Usage

Usage: ip2tracepy -p [IP ADDRESS/HOSTNAME] -d [IP2LOCATION BIN DATA PATH] [OPTIONS]
   or: ip2tracepy [IP ADDRESS/HOSTNAME] -d [IP2LOCATION BIN DATA PATH] [OPTIONS]

  -p, --ip
  Specify an IP address or hostname.
  The -p/--ip can be omitted if the IP address or hostname is defined in the first parameter.

  -d, --database
  Specify the path of IP2Location BIN database file. You can download the latest free IP2Location BIN database from https://lite.ip2location.com.
  If the database filename is specified but without the path, ip2tracepy will search the database file in /usr/local/share/ip2location/ for Linux or C:\Users\(your_Windows_username)\Documents\ for Windows.

  -t, --ttl
  Set the max number of hops. (Default: 30)

  -o, --output
  Set the desired IP2Location BIN database columns to output with.
  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.
  
  -a, --all
  Print all the column(s) available based on the BIN file used.

  -h, -?, --help
  Display this guide.

  -v, --version
  Print the version of the IP2Location version.

Example

Traceroute an IP address.

ip2tracepy 8.8.8.8 -d /usr/local/share/ip2location/DB3.BIN -a

Example output:

IP2Location Geolocation Traceroute (ip2trace) Version 3.2.0
Copyright (c) 2021 - 2024 IP2Location.com [MIT License]
https://www.ip2location.com/free/traceroute-application

Traceroute to dns.google ( 8.8.8.8 )

 1  37.123.114.1  0.3853ms ["GB","United Kingdom of Great Britain and Northern Ireland","England","London"]
 2  10.10.32.132  0.4084ms ["-","-","-","-"]
 3  10.10.32.17  0.2673ms ["-","-","-","-"]
 4  212.78.92.2  0.5546ms ["GB","United Kingdom of Great Britain and Northern Ireland","England","London"]
 5  98.158.181.98  1.8706ms ["US","United States of America","New York","New York City"]
 6  195.66.236.125  0.5715ms ["GB","United Kingdom of Great Britain and Northern Ireland","England","London"]
 7  108.170.246.129  0.5193ms ["US","United States of America","California","Mountain View"]
 8  108.170.232.97  0.4749ms ["US","United States of America","California","Mountain View"]
 9  8.8.8.8  0.5693ms ["US","United States of America","California","Mountain View"]

Traceroute by hostname

ip2tracepy google.com -d /usr/local/share/ip2location/DB3.BIN -a

Example output:

IP2Location Geolocation Traceroute (ip2trace) Version 3.2.0
Copyright (c) 2021 - 2024 IP2Location.com [MIT License]
https://www.ip2location.com/free/traceroute-application

Traceroute to dns.google ( 8.8.8.8 )

 1  37.123.114.1  0.3529ms ["GB","United Kingdom of Great Britain and Northern Ireland","England","London"]
 2  10.10.32.131  0.3686ms ["-","-","-","-"]
 3  10.10.32.17  0.2663ms ["-","-","-","-"]
 4  212.78.92.2  19.7358ms ["GB","United Kingdom of Great Britain and Northern Ireland","England","London"]
 5  98.158.181.98  9.2373ms ["US","United States of America","New York","New York City"]
 6  195.66.236.125  0.5388ms ["GB","United Kingdom of Great Britain and Northern Ireland","England","London"]
 7  108.170.246.161  1.6131ms ["US","United States of America","California","Mountain View"]
 8  172.253.65.211  1.2376ms ["US","United States of America","California","Mountain View"]
 9  216.58.213.14  0.5167ms ["US","United States of America","California","Mountain View"]

Download IP2Location Databases

One you have obtained your download token, you can download the the database using wget as below:

wget "https://www.ip2location.com/download?token={DOWNLOAD_TOKEN}&file={DATABASE_CODE}"

Support

Email: [email protected] URL: https://www.ip2location.com

ip2trace-python's People

Contributors

chrislim2888 avatar ip2location avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ip2trace-python's Issues

Invalid sintax

I receive:

$ python ip2trace.py 
  File "ip2trace.py", line 140
    print(" {}  ".format(self.ttl), end="")
                                       ^
SyntaxError: invalid syntax

Thank you,
Riccardo

socket.herror: [Errno 1] Unknown host

[root@localhost ]# ip2trace -p 116.122.36.54 -d IP-COUNTRY-REGION-CITY-ISP.BIN -t 30                               
Traceback (most recent call last):
  File "/usr/local/bin/ip2trace", line 11, in <module>
    load_entry_point('IP2Trace==2.1.7', 'console_scripts', 'ip2trace')()
  File "/usr/local/lib/python3.6/site-packages/ip2trace.py", line 482, in main
    traceroute(destination_server, database, max_hops, output, all)
  File "/usr/local/lib/python3.6/site-packages/ip2trace.py", line 148, in traceroute
    t = Traceroute(destination_server, database, ttl, output, all)
  File "/usr/local/lib/python3.6/site-packages/ip2trace.py", line 174, in __init__
    self.destination_domain_name = ip_to_domain_name(destination_server)
  File "/usr/local/lib/python3.6/site-packages/ip2trace.py", line 97, in ip_to_domain_name
    return socket.gethostbyaddr(hostname)
socket.herror: [Errno 1] Unknown host
[root@localhost ]# 

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.