Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Client machine's physical location on internet?

Status
Not open for further replies.

akgta

Programmer
Jul 18, 2007
42
CA
How can we determine the physical location of a client machine connected on the internet, ourselves in control on the server side obviously?

By physical location I mean Country, State/Province and City.

Thanks in advance.
 
You would first need to be able to determine the machine's IP address.

Then you would need to look it up in a database of IP ranges and who owns them etc.

Such databases are certainly available for purchase - or at least you can purchase a lookup service and interrogate that.

As far as I know, there is no way to programmatically determine location based on some forumla applied to the IP.

Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
Akgta,

I have a similar requirement. The tool I'm considering is "IP to Country Lookup" from WebNet77 (see This is an example of the type of database that Foamcow referred to.

Note that I don't have any direct experience of this product. It's just one that I found in my searches.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
In short: you probably can't. Not in a reliable fashion that is.

A lot of IP addresses are "known" in the mentioned tables as belonging to ISPs. The client's machine may very well be located far from his ISP. If the client uses any proxy (like tor), you'll only get the exit point.

It would even be illegal if the ISPs would hand your exact location to everybody listening. That is personal data.

So if you really need the exact client's location, kindly ask him. If you need it coarsely (say, as a default for a language selector), you can use geoip tables.


+++ Despite being wrong in every important aspect, that is a very good analogy +++
Hex (in Darwin's Watch)
 
It would even be illegal if the ISPs would hand your exact location to everybody listening. That is personal data.

I'm not sure it's either illegal or personal since it's not identifying WHO you are simply where an IP is located.

However, I tend to agree that the services aren't 100% reliable. At best they will give the location of where your particular node of a network terminates.

For instance, using the service give in the earlier example it thinks I'm in Edinburgh. Couldn't really be further away from where I actually am.

My office, about 1 mile from home, appears to be in Bletchley which is still about 75 miles out. In the UK that's quite a distance.

Tek-Tips Forums is Member Supported. Click Here to donate

<honk>*:O)</honk>

Tyres: Mine's a pint of the black stuff.
Mike: You can't drink a pint of Bovril.
 
For instance, using the service give in the earlier example it thinks I'm in Edinburgh.

Ah, they obviously think that you're me. Considering how little I know about PHP, you should feel suitably insulted.

Seriously though ... In my case, I only need to know if the visitor is in GB or Ireland, so that I can feed different adverts to them. But I take your point. I notice that in my own web stats, some visitors are flagged simply as EU, without any indication of the country.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top