If you have an Apache-PHP based server, you can install Mod_GeoIP and Geoip.
1. Mod_GeoIP Apache module that can be used to get the geographic location of the IP address of the visitor into the Apache webserver. This module allows you to determine the visitor’s country, organization, and location. It is especially useful for Geo Ad Serving, Target Content, Spam Fighting, Fraud Detection, Redirecting/Blocking visitors based on their country and much more.
2. GeoIP stands for geographic information of IP Addresses. It is a PHP extension used to find the geographic location of an IP Address (eg:- Country, state, latitude) and other information like ISP, connection type etc.