Encontrei algumas respostas na WikiPedia:
There are a number of free and paid subscription geolocation databases, ranging from country level to state or city—including ZIP/post code level—each with varying claims of accuracy (generally higher at the country level). These databases typically contain IP address data which may be used in firewalls, ad servers, routing, mail systems, web sites, and other automated systems where geolocation may be useful. An alternative to hosting and querying a database is to obtain the country code for a given IP address through a DNSBL-style lookup from a remote server.
Some commercial databases have augmented geolocation software with demographic data to enable demographic-type targeting using IP address data.
The primary source for IP address data is the regional Internet registries which allocate and distribute IP addresses amongst organizations located in their respective service regions:
- African Network Information Centre (AfriNIC)
- American Registry for Internet Numbers (ARIN)
- Asia-Pacific Network Information Centre (APNIC)
- Latin American and Caribbean Internet Address Registry (LACNIC)
- RIPE Network Coordination Centre (RIPE NCC)
Secondary sources include:
- Data mining or user-submitted geographic location data. For example, a weather web site might ask visitors for a city name to find their local forecast. Another example would be to pair a user's IP address with the address information in his/her account profile.
- Data contributed by internet service providers.
- Merging databases from different suppliers.
- Guesstimates from adjacent Class C range and/or gleaned from network hops.
Accuracy is improved by:
- Data scrubbing to filter out or identify anomalies.
- Statistical analysis of user submitted data.
- Utilizing third-party tests conducted by reputable organizations.
Source: https://en.wikipedia.org/wiki/Geolocation_software#Data_sources