Do you know of any service which given an ip address it开发者_JAVA技巧 returns a location/country? I found a few lists we can add to our database but do I need to update them often? Is there any rule (like telephone numbers) to know the country of origin?
Sorry, I know this might sound a stupid question but for what we're doing it can't fail.
EDIT: I forgot to mention this has to be accessible programmatically (PHP)
Thanks :) Diogo
Check this out: http://www.farhad.ca/2011/06/15/rbl-based-ip-to-location/
Assume IP address of question is 10.11.12.13, then here is a sample:
<?php
$ip_address = gethostbyname('13.12.11.10.rbloc.dayanadns.com');
list($d1,$d2,$d3,$d4) = explode('.',$ip_address);
$country_code = chr($d3).chr($d4);
print "Result address: ".$ip_address."\n";
print "Country code: ".$country_code."\n";
?>
Maxmind also has a service. We use the free csv download from this service so that the lookup is on our local system. Find full information on how to use it in this SQL Server Central article.
GeoIP lookups are generally done using a commercial service. IP address ranges do change, so there is no canonical database.
There are also lots of strange outliers - IP ranges assigned to airlines, for instance, or those assigned to the US military, who may be anywhere in the world.
In the Entertainment indsutry, where rights holders (movie studios, record labels) own regional rights to content, the use of one of a number of approved commercial services is often a contractual obligation. I know from experience that MaxMind have a great service. Google "geoip lookup" and you'll get enough options.
Geo IP Tool is doing what you ask.
I use http://www.hostip.info/ in my site, which provides a web service lookup to resolve the IP to an address.
Implementation is very easy (in .NET and likely PHP, JAVA). Unfortunately, it only resolves about 1/2 the time...so the rest of the time I have to use another service to resolve it.
BUT IT IS FREE.
For paid services, MelissaData offers a good quality service...but you have to pay if you do processing in volume.
I personally wish Google offered a service to do this.
This is a service I found with an API. Everything explained here: http://ipinfodb.com/ip_location_api.php
精彩评论