Domanda

I'm administering a web platform and want to get some statistical data, where my users come from. I can store the remote IP and I know that there are localization services that map an IP to a geolocation.

How is this mapping done? Are there fixed tables, which IP address was given to which region?

Must I request the mapping in the moment of the access or can I request it days/months/years later? In other words: Is the mapping from IP to location fixed or does it change over time?

È stato utile?

Soluzione

The mapping from IP to location change over time. I have read that the databases change 5% each month, even though its hard to know if they really change that much or if the database providers lie to sell their updates more often. But its a fact that these databases change. So you should obtain the location of an IP address asap, at least not later that a month after you captured the IP address.

Altri suggerimenti

You can use third party sites to gelocalize ip.

I usually use:

https://www.geo-ip.net/locate?query=stackoverflow.com&format=json

Ipregistry author there. Yes, IP allocations change over time. As an example, with Ipregistry, client libraries store lookup results for up to 24h but we recommend not to use a long period.

Indeed, RIR (Regional Internet Registry) data change, some ISP (Internet Service providers) make use of dynamic IP addresses and companies who have allocations (especially IPv4) rent or resell allocations, which results in frequent changes.

In case you are using a service like Ipregistry, which also returns threat data for a given IP address, it is even recommended to not cache the result for more than 1 hour since threat data change even more frequently!

In case you want to store the demographic data, you should save the country information retrieved instead of IP address, due to the nature it may changes from time to time.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top