IP localization: mapping ip->location fixed over time?

倖福魔咒の 提交于 2019-12-07 16:36:23

问题


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?


回答1:


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.




回答2:


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.




回答3:


You can use third party sites to gelocalize ip.

I usually use:

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




回答4:


Ipregistry author there. Yes, IP allocations change over time. As an example, with my service, 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!



来源:https://stackoverflow.com/questions/12990196/ip-localization-mapping-ip-location-fixed-over-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!