homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
Forum Library, Charter, Moderators: coopster & jatar k & phranque

Perl Server Side CGI Scripting Forum

Getting the users country from the ip address
how & are there any seo issues?

 11:58 am on Apr 2, 2002 (gmt 0)

The site I am working with at the minute get a large amount of international traffic. See below

45% UK
35% US
10% Canadian
4% Australian
4% South African
2% Other.

I have seen websites automatically redirect me to a local version of their site by using my IP address (e.g. Lycos). Does anyone know how this is done? Ideally, I am looking for either a tutorial or sample code. I presume it has something to do with the RIPE NNC database. Also, if I do manage to get this working, are there any search engine optimisation issues? Will the spiders penalise me for doing this? Is it counted as cloaking?

Your help is greatly appreciated.




 2:41 pm on Apr 2, 2002 (gmt 0)

I've found a service to do this but it is 50 a month to use SOAP. Anyone else come across a service or code to do this?


 4:05 pm on Apr 2, 2002 (gmt 0)

one could perform a nslookup, and for the .net allocated ips
an additional whois lookup getting the country...
but this is 1st very slow and 2nd might end up in your ip being banned from
the whois service because of exhausting use (although my isp's whole ip range
would have been banned then over the past two years hehe)
no really, there must be a more effective way
maybe an ip's first two octets also specify the allocated country?

if so, of course there is no standart but a database, probably the rir's
do have such dbs

(edited by: PsychoTekk at 4:15 pm (utc) on April 2, 2002)


 4:14 pm on Apr 2, 2002 (gmt 0)

I'm not aware of any pre-rolled service, but it would be fairly simple to knock up a script to compare the visitors IP address to a list of IP ranges / country (a couple of lists were mentioned in this thread [webmasterworld.com] ) and then either serve up an appropriate page (similar to cloaking) or a simple redirect to a completely different page.

The second method could be fairly dangerous SEO-wise - as with all redirects - but the first shouldn't cause too many problems IMO, as you wouldn't be serving up different content to users and spiders within the same region...


 10:16 pm on Apr 5, 2002 (gmt 0)

Try this


Thierry Zoller

 10:24 pm on Apr 5, 2002 (gmt 0)

The coordinates are witing the DNS answer (called DNS loc), Horizontal and Vertical in degrees, you have to map them to a country though (dll's are avaiable) note not all have dns loc data, if so fire off a trace take the hop prior to the last one, and extract the dns loc there.

Thierry Zoller

 10:29 pm on Apr 5, 2002 (gmt 0)

make it "latitude and logitude" ;)


 2:54 pm on May 20, 2002 (gmt 0)

I have located these urls for updated ip/countries databases.

[ftp.apnic.net...] (Asia)
ftp://ftp.arin.net/pub/stats/arin/ (America)
ftp://ftp.ripe.net/ripe/stats/ (Europe)

I have not anyone for Africa.

I think you would need some scripting for obtain valid data from this sources.


 3:02 pm on May 20, 2002 (gmt 0)
There's some interesting information here on Internet Geography:



 3:02 pm on May 20, 2002 (gmt 0)

I asked about this somewhere else (ah the shame...) and was told by a reliable source that it was dead tricky. In fact it's pretty much impossible to do it effectively with just an ip address.

I also hear there are some subcriber services that claim to be use...



 3:17 pm on May 20, 2002 (gmt 0)
I have found this free script that maybe useful, I have just found it. I must test it.



 4:10 pm on May 20, 2002 (gmt 0)

You could also try gnation in Sourceforge.
Has worked for me.


 9:56 pm on Aug 20, 2002 (gmt 0)
You may want to check these out. Highly accurate!


brotherhood of LAN

 10:18 pm on Aug 20, 2002 (gmt 0)

Would proxies mess the numbers up a little?

My ISP uses a proxy.


 8:26 am on Aug 21, 2002 (gmt 0)

Proxies, large corporate networks, people have ISPS in different countries, and the changing location of an IP address are downsides. Doing it is relatvly easy...


 9:48 am on Aug 23, 2002 (gmt 0)

PhyscoTek, why don't you read in the IP address country information and then cache it on your site for future reference?

I do currency conversion with my merchant account. The first time anyone visits any page where currency conversion is required, I load in the conversion figures and cache them in a file on my server. The first time is quite slow, but I use the same figures for 24 hours, thus I only call their server once per day (maximum).

Yours would be different, calling the server quite often, but if you cache each result (date each and everyone) for 4,6 or maybe even 8 weeks, the load will gradually drop.


 1:06 am on Oct 2, 2002 (gmt 0)

Try this www.location.com.my

Better and cheaper than other solutions.

[edited by: jatar_k at 1:37 am (utc) on Oct. 2, 2002]
[edit reason] unlinked url [/edit]


 1:32 am on Oct 2, 2002 (gmt 0)

netgeo.com is a nice place to start, or you can possible use the ARIN database. I was planning to make that into my next web service. ;)


 1:38 am on Oct 2, 2002 (gmt 0)

Welcome to WebmasterWorld [webmasterworld.com] tgotchi

Global Options:
 top home search open messages active posts  

Home / Forums Index / Code, Content, and Presentation / Perl Server Side CGI Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved