IP Lookup

Hi Guys!

I have a database of over 135000 IP addresses. What I want to do is determine which country the user is from by using the IP pattern from the database. Does anyone know how I can create a script to do this? Maybe using preg_match I guess?

Here’s an example of the information I have in the database:

16777216 1.0.0.0/13
17367040 1.9.0.0/16
17435136 1.10.10.0/24

What does this mean and how can I match it with the user’s IP?

try using:
http://ip2country.sourceforge.net/

IP to Country (IP2C) a free open-source service to deliver a IP to Country feed for use in your software. Feed style queries return information about the client, such as:Internet Address (IP),Hostname,Country Code,Country Name

eg:
http://ip2country.sourceforge.net/ip2c.php?ip=201.83.41.20&format=JSON
Outputs

{ip: "201.83.41.20",hostname: "c9532914.virtua.com.br",country_code: "BR",country_name: "Brazil"}   

I think you might find useful coding information here:
http://ip2country.sourceforge.net/code-examples.php

! I have just found this on Google ‘opensource IP locator’, I don’t know if it has limitations…