Forum Moderators: mack

Message Too Old, No Replies

IP range for just one country

Possible?

         

Hester

12:32 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I would like to use code that checks if a visitor to our website is coming from my country or not. I am in the UK. Is this possible? I have read (via Google) that IP ranges aren't allocated to specific countries, so they could be located anywhere.

I found a list reputing to cover IP ranges in the UK. (Other countries were also available.) Would it be reliable to use this?

The list offers these ranges (eg: 25 = 25.0.0.0 upwards):

25
51
62
80-86
135-138
158
192-196
199
204
212-213
217

I checked the IP range of my machine and it started with 143 - yet this is not in the list. Do I assume (since I'm on a network) that it's a NAT range that is converted by the main hub to a general one? (I know routers can do this to cope with the demand for IP ranges by making virtual ones.)

My code so far checks for forwarded, proxy and remote IP ranges.

Note: I do not intend blocking content based on IP range. I am just trying to clarify country usage.

andye

12:57 pm on Feb 18, 2005 (gmt 0)

10+ Year Member



You can buy a database matching IP ranges against countries quite cheaply. Try a search for 'geolocation' or 'geotargeting' and you'll see some of the vendors. I think there's also a Perl library for this - try searching cpan.

hth, andy.

Hester

1:12 pm on Feb 18, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Heh, I wasn't after buying anything. For what I want the code for, it's not worth it.

mack

5:34 pm on Feb 20, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I had a similar project a while back.. What I did was download the world ip database and then extrace the country codes I needed. It took close to 25 hours of work to get the db to a useable state. I wish I had just paid for it. :)

It depends on the size of the country you want to use the data for.

Mack.