Skip to content
A terminal application which use to get information about IP addresses based on Lite Database
Go Batchfile Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


A terminal application which use to get information about IP addresses based on Lite Database


This terminal application will use the IP2Location Lite Package to fetch the information about provided IP addresses. If the provided IPs are private addresses, you can provide a CSV file to fetch information from your local database.

You can find a how to guide in this article to Monitor your hosts using InfluxDB, Telegraf & Granfana.


  • It can output data as a CSV (-c csv) or TSV (-c tab)
  • If you want to store the information in InfluxDB, you can use -t option and define it as a [[input.exec]] in telegraf.conf. Read more about Telegraf [[input.exec]] here:
  • When you use -t option, It will ping the provided IP and let you know the result based on each host

Command line input parameters:

  -c string
        (Optional) Print it in CSV format. Accepted values are comma and tab. This option can NOT be used with -t option.
        Download the latest lite ip2location database and replace it with the current and exit
  -i string
        (Could be Mandatory) IP Address (v4 or v6). FQND or Domain Name is not supported yet... ;-)
  -list string
        (Could be Mandatory) List of IP Address (v4 or v6). FQND or Domain Name is not supported yet... ;-)
  -local string
        (Optional) Local CSV database for Private IPs. Only IPv4 is supported. It MUST be in this format: CountryShort,CountryLong,State,City,Timezone,Lat,Lon,StartIP,EndIP
  -m string
        (Optional) Measurement name for InfluxDB. Default value is ip2loc. Use it with -t option (default "ip2loc")
  -t string
        (Optional) Prepare it for InfluxDB Telegraf [[inputs.exec]]. It also will send 3 ICMP requets to the IP provided by the user to check the host availability. Accepted values are country_short, country_long, host or all  as a tag for InfluxDB. This option can NOT be used with -c option. Get more information about [[inputs.exec]] here:
  -timeout string
        (Optional) ICMP requet timeout in seconds. (default "10")
  -v    Print Version & exit.

How to build?

It's written in Go and I used package to extract Information from IP2Location Lite Package. So to build executable from this source code download the repo and run the further command:

go get
go get
go get
go build .\ip2location.go .\utils.go .\update.go

Download binaries

Currently compiled executables are:

  1. Windows:
  2. Linux:
  3. Mac:

NOTE for Linux Users

  1. After download the executable you need to let it to be executable by running chmod +x ip2location.
  2. One of the other thing is if you use -t option, ip2location will try to send 3 icmp request to provided IP address. So you need to run it as root.
          sudo sysctl -w net.ipv4.ping_group_range="0   2147483647"
          sudo setcap cap_net_raw=+ep /path/to/ip2location

How to Use?

You need to download the Compiled executables from the ** build ** folder or build it from the source. After that, You need to download the latest Lite Package using -dl option.

Get the latest Lite DB

Run the further command and it will download the latest Lite DB and place it in %ProgramFiles%\IP2Location\db\% (windows) or \etc\ip2location\db (Linux). You need to run it as root (linux) or system administrator (windows)

# ip2location -dl

*** Outout ***

Download Started
Downloading... 24 MB complete
Download Finished

Local Database Format

The local database file format must be like this: CountryShort,CountryLong,State,City,Timezone,Lat,Lon,StartIP,EndIP For now, IP2Location Local database is not supports IPv6.

A sample for local CSV database

IR,"Iran, Islamic Republic of",Tehran,Tehran,+03:30,35.6892,51.3890,,
IR,"Iran, Islamic Republic of",Markazi,Arak,+03:30,34.0954,49.7013,,
IR,"Iran, Islamic Republic of",Isfahan,Isfahan,+03:30,32.6539,51.6660,,


There are some few examples which you can use it

Example 1: Get Location Info in CSV format

ip2location -i -c comma

Output is:
"","US","United States","California","Mountain View","-07:00",37.405991,-122.078514

Example 2: Get Location Info in TSV format

ip2location -i -c tab

Output is:
""       "US"    "United States" "California"    "Mountain View" "-07:00"        37.405991       -122.078514

Example 3: Get Location Info and prepare it for Telefraf

After -t option you can use country_short, country_long, host or all as a tag for InfluxDB. In this example we will use host

ip2location -i -t host

*** Output ***
ip2loc,onlineTag=1,host= country_long="United States",country_short="US",city="Mountain View",state="California",timezone="-07:00",latitude=37.405991,longitude=-122.078514,packetSent=3,packetRecv=3,packetLost=0.000000,minRtt=82.852251,avgRtt=83.647769,maxRtt=84.680822,online=1

Example 4: Using LocalDB and List of IP addresses

The only hint about List of IP addresses is, the first field of CSV file must be IP Address & You can add as much as field you want in another fields. Here is the example:,"Google","Tehran HQ","Arak Office","Isfahana Office #1","Isfahana Office #2"

And Here is the example and It's Out put in CSV format:

"","US","United States","California","Mountain View","-07:00",37.405991,-122.078514
"","IR","Iran, Islamic Republic of","Tehran","Tehran","+03:30",35.689201,51.389000
Provided IP ( is not provided in the local database (local.csv)
Provided IP ( is not provided in the local database (local.csv)
"","IR","Iran, Islamic Republic of","Isfahan","Isfahan","+03:30",32.653900,51.666000

Grafana Dashboard

I've made a simple dashboard for using this tool to monitor your hosts. It might give you a chance to get the idea behind IP2Location Tool. You might want to make more effective dashboards and share it with others.

You can download this dashboard from Grafana website. Here is the link to the dashboard: Grafana IP2Location Dashbaord

After you import this dashbaord to your Grafana, You might see something like the further Screenshot:

IP2Location + IP Monitor Simple Dashboard IP2Location + IP Monitor Simple Dashboard

You can’t perform that action at this time.