How can I find out where in the world an IP (Websession.RemoteAddress) is located?
There’s no 100% accurate way to do it however you can start with a free API here: http://freegeoip.net
Ok, I see. So I have to query an online geolocation database, by using their api.
I wonder where do they get their data from? Google?
Has anybody evaluated the various geolocation providers (free and others) and what where the findings? Is anybody willing to share pro’s and cons?
Here’s a listing of some providers http://whatismyipaddress.com/geolocation-providers
It’s essentially a manual process of collecting data from forms, browsers, ISP host names, etc. A lot of work go into these services with very wildly different accuracies and pricing schemes. Google often gets it wrong as well and their data is cached for long periods of time making it often unreliable.
Keep in mind that these are often listed by the location of the company which “owns” the IP address. You’ll likely be able to get the right country, but the city could be very wrong if they have national headquarters.
IP addresses are assigned by the local IP assignment authorities, like ICANN in the States and RIPE in Europe. They store them in a database, from which the Internet DNS servers getting their data. You get your IP address (fix or variable) from your Telco supplier, and they get their numbering scheme from their IP address authority.
You can lookup IP addresses yourself, and the human readable output is for example like this:
inetnum: 184.108.40.206 - 220.127.116.11
descr: Host Europe GmbH
Once you have an IP address you wish to lookup you navigate to (e.g.) ripe.net (https://apps.db.ripe.net/search/) and type in the IP address of interest. You then receive an output like the above.
The output also contains the address (City, Street) of the registered person (here: Host Europe).
If you wish to get the data programatically, this is obviously possible because RIPE also offers the output in JSON format. But I don’t know what you need to do to get there (am new to xojo and have not yet touched JSON, REST and all this web service stuff).
And, Greg is of course right: you get the IP address of the IP connection point, which is in 99.99% of all cases not the user’s location. If a user dials into the Internet by DSL, then the IP address will point to the telco/DSL provider. Only some companies have direct RIPE addresses, all others are proxied. However, unless your user is one of a really large corporation, at least the country is correctly represented. Only few companies, e.g. IBM. HP, and the like, may route all their European traffic through one or two locations, usually Frankfurt and London Harbor, an in these cases even the Spanish user may come to your site with a German/British IP address.
Hope this helps.
I will look into this : https://www.ripe.net/data-tools/developer-documentation
Maybe there is a way to log country and provider for each user of a Webapp?
Currently, I am using ipinfodb.com, like this:
[code]Sub LogIP(AppName As String)
Dim ipadr As String = Session.RemoteAddress
Dim d As New Date
// log ip and date to database
Pref.Value(AppName) = ipadr + " ; " + d.SQLDateTime
Dim geoURL As String = “http://api.ipinfodb.com/v3/ip-city/?key=” + ourKey + “&ip=” + ipadr
If WebPage1.DataSocket <> Nil Then