DEV Community

Heddi Nabbisen
Heddi Nabbisen

Posted on

GeoIP: How To Get Country/City/ASN From IP Address

Introduction

I found my servers were given several requests by unknown hosts.
I tried to find out who they were.
Their locations were one of the good information, which were got in the way written in this post.
GeoIP by MaxMind did a great job.

Preparation: Manjaro/Arch Linux

Install 3 packages via Pamac, the Manjaro package manager:

  • geoip
  • geoip-database
    • About Country
  • geoip-database-extra

AUR is also available.

Besides, installation for other distros is here.

How To Get It

It is a very simple task.
Just use geoiplookup:

$ geoiplookup %ip-or-fqdn%
GeoIP Country Edition: %Country Code%, %Country Name%
GeoIP City Edition, Rev 1: %Country Code%, ..., ..., ..., ..., %Latitude%, %Longitude%, ..., ...
GeoIP ASNum Edition: ...
Enter fullscreen mode Exit fullscreen mode

Happy computing :)

Discussion (4)

Collapse
lpellegr profile image
Laurent Pellegrino

Another solution that works quite great is Ipregistry:

ipregistry.co

Collapse
nabbisen profile image
Heddi Nabbisen Author

Laurent, thank you for your sharing knowledge. I didn't know of it. The Ipregistry website looks nice 😉
Well, I found the Geobytes page in wikipedia has "Competitor information".

Collapse
iamvp7 profile image
Viswaprasath

I have tried another solution to maxmind, its IP2Location. Try this also.

Collapse
nabbisen profile image
Heddi Nabbisen Author

Thank you, Viswaprasath😄
I'll try it.