Found some solutions on WikiPedia:
There are a variety of free and compensated subscription geolocation databases, varying from country level to condition or city—including ZIP/publish code level—each with different claims of precision (generally greater in the country level). These databases typically contain Ip data which can be utilized in firewalls, ad servers, routing, mail systems, internet sites, along with other automated systems where geolocation might be helpful. An alternative choice to hosting and querying a database is to get the country code for any given Ip via a DNSBL-style lookup from the remote server.
Some commercial databases have augmented geolocation software with demographic data to allow demographic-type targeting using Ip data.
The main source for Ip information is the neighborhood Internet registries which allocate and distribute IP addresses among organizations situated in their particular service regions:
- African Network Information Center (AfriNIC)
- American Registry for Internet Figures (ARIN)
- Asia-Off-shore Network Information Center (APNIC)
- Latin American and Caribbean Internet Address Registry (LACNIC)
- RIPE Network Coordination Center (RIPE NCC)
Secondary sources include:
- Data mining or user-posted geographic location data. For instance, a weather site might ask visitors for any city name to locate their local forecast. Another example is always to pair a user’s Ip using the address information in theOrher account profile.
- Data contributed by isps.
- Merging databases from various suppliers.
- Guesstimates from adjacent Class C range and/or gleaned from network hops.
Precision is improved upon by:
- Data scrubbing to remove or identify anomalies.
- Record analysis of user posted data.
- Utilizing third-party tests conducted by trustworthy organizations.