Terminal Friday: geographical location of an IP

Good people, for this Terminal Friday (hahaha, 28 minutes after being Friday, moment of the creation of the post) it occurred to me to leave a post about how to find the geographic address of an IP.


By means of Curl

There may be many ways to do this. The first and easiest is to use the ipinfo.io which displays the information in JSON format. Of course, it is necessary to have an Internet connection since it is done through curl, and obviously it is necessary to have installed curl.

curl ipinfo.io/74.125.244.83

Cute, right? 🙂


GEOIP

Now, the second method is to use the application provided by the company MaxMind, which has a section Open Source -something for which you would need to read the license, since many of its downloads are paid, but anyway-; in Arch Linux, your packages are in extra, therefore only one:

# pacman -S geoip geoip-database

Its use is:

$geoiplookup74.125.224.83

The information displayed is not as complete as that of ipinfo.ip, but you can download dictionaries from the page and add them to / usr / share / GeoIP.

Here are some databases:

#Download the DB $ wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz $ wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat .gz $ wget http://download.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz #Uncompress them $ gunzip * .dat.gz #Move them to GeoIP $ sudo cp * .dat / etc / share / GeoIP

Whois

It is also possible to view information about an IP with the command whois. Can be installed with Pacman:

# pacman -S whois

And its use:

$ whois 74.125.224.83

For this Friday is everything. 🙂 We read the following Terminal Friday.

By the way, whose IP was that? It's from Google ...

$ping -c 1 www.google.com

7 comments, leave yours

Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   eliotime3000 said

    I stop using more WHOIS than the other tools mentioned above. : v

  2.   Daniel said

    TambiГ © n:

    curl ipinfo.io/$(curl ifconfig.me)

    It tells you more or less where you are.

  3.   Dw said

    Regards. very good I have ... one day it will help me something hehehe ...

  4.   desikoder said

    $curl ipinfo.io/74.125.244.83
    {
    «Ip»: «74.125.244.83»,
    "Hostname": "No Hostname",
    «City»: «Mountain View»,
    "Region": "California",
    «Country»: «US»,
    «Loc»: «37.4192, -122.0574»,
    «Org»: «AS26910 Postini, Inc.»,
    «Postal»: «94043»
    }

    Is it apple ip?

  5.   johnfgs said

    But it doesn't have the grace to create a graphical interface with visual basic ...

    https://www.youtube.com/watch?v=-AAZmfd0rtE

    1.    kuk said

      hahaha good that 😀

  6.   oscar meza said

    I stick with curl and whois, they are already installed in any distro.

    Regards…