4

Searching for IP 54.73.154.147 using latest GeoLite2 IP database I get the following results:

Seattle, US, United States

But the IP address is actually from a AWS server spun up in Ireland. If I submit the same IP to the GeoIP Precision test page (https://www.maxmind.com/en/geoip-demo) I get the correct results:

Dublin, IE, Ireland

Can anyone think of a reason as to why Im getting such erroneous results?

beterthanlife
  • 1,668
  • 2
  • 18
  • 30

4 Answers4

4

The reason that you are getting two different results is because they simply are different versions of databases and the one you search on their web interface is apparently more accurate and more up-to-date. GeoLite2 is not very accurate and you need to update it every week to receive accurate information since IP addresses are changing every minute. For example I purchased a few IP addresses and I can use one today and shift to another one tomorrow as I please. Bigger companies do that more often and most of these IP addresses can go from one country to another.

And if you just want to stick with MaxMind product you can use this url to request the json:

https://www.maxmind.com/geoip/v2.1/city/{{ip.address}}?use-downloadable-db=1&demo=1

Note that only 25 requests are allow a day in theory (but easily hackable). Don't ask me how to hack it because it is against the rules of Stackoverflow.

Aero Wang
  • 8,382
  • 14
  • 63
  • 99
1

As @michael pointed out, you can't do anything if geolite's database is wrong. Here is antoher alternative: userinfo.io. It's actually a merge of several databases so it can be more accurate.

I tested it with your IP and it returns the right location.

{
  "ip_address": "54.73.154.147",
  "position": {
    "latitude": 53.3331,
    "longitude": -6.2489
  },
  "continent": {
    "name": "Europe",
    "code": "EU"
  },
  "country": {
    "name": "Ireland",
    "code": "IE"
  },
  "city": {
    "name": "Dublin"
  }
}

You can currently use the javascript wrapper or the java wrapper.

Vincent Durmont
  • 813
  • 8
  • 16
0

I had exactly the same problem. My EC2 server is in Ireland, but geoip shows US.

I switched to freegeoip.net, which seems accurate for this case.

An example of usage in PHP:

$json_data = file_get_contents("http://freegeoip.net/json/" . $hostname);
return json_decode($json_data, TRUE);
Aris
  • 4,643
  • 1
  • 41
  • 38
-1

This Script will solve your issue . i had tested it with your ip address and it is giving correct result

<?php
    /*Get user ip address*/
    //$ip_address=$_SERVER['REMOTE_ADDR'];
    $ip_address="54.73.154.147";
    /*Get user ip address details with geoplugin.net*/
    $geopluginURL='http://www.geoplugin.net/php.gp?ip='.$ip_address;
    $addrDetailsArr = unserialize(file_get_contents($geopluginURL)); 


    /*Get City name by return array*/ 
    $city = $addrDetailsArr['geoplugin_city']; 

    /*Get Country name by return array*/ 
    $country = $addrDetailsArr['geoplugin_countryName'];

    $latitude = $addrDetailsArr['geoplugin_latitude'];

    $logitude = $addrDetailsArr['geoplugin_longitude'];
    /*Comment out these line to see all the posible details*/
    /*echo '<pre>'; 
    print_r($addrDetailsArr);
    die();*/

    if(!$city){
        $city='Not Define'; 
    }if(!$country){
        $country='Not Define'; 
    }
    echo '<strong>IP Address</strong>:- '.$ip_address.'<br/>';
    echo '<strong>City</strong>:- '.$city.'<br/>';
    echo '<strong>Country</strong>:- '.$country.'<br/>';
    echo '<strong>Latitude</strong>:- '.$latitude.'<br/>';
    echo '<strong>Longitude</strong>:- '.$logitude.'<br/>';
?>  
Ricky
  • 284
  • 1
  • 3
  • 19