Geolocation Accurcy When Anonymizing IP

I’m setting up a new server for a website. I want to ensure that my users’ privacy is well protected (at least from my side). Initially I wanted to not track IP addresses at all. However, I need some rough estimation of the user’s location so that I know where in the world to place my servers to improve access speeds. The city and even region is not that important, I’m only concerned with the country.

Instead of not logging IPs at all, I decided to rather anonymize them. I want to anonymize as many octets of the IP as possible (increase anonymity), but still have a good pinpoint of the country (accuracy).

I found a few articles that discuss this, but they are only concerned with a single octet. According to those articles, about 1-5% of countries might be misclassified if one octet is anonymized.

Does anyone know (more or less) how this accuracy looks like when anonymizing 2 or 3 octets?


Instead of obfuscating parts of the IP address (198.51.100.xx, 198.51.xx.xx, 198.xx.xx.xx) do the GeoIP resolution against a local database and log only the country. This way you’ll have accurate statistics without storing any parts of the IP. The local database is crucial as you don’t want to send the IP addresses to a 3rd party.

Source : Link , Question Author : Robert Ruter , Answer Author : Esa Jokinen

Leave a Comment