How IP Geolocation Works
Last updated: June 2026
When you visit a website, your IP address is visible to the server. With IP geolocation, that IP can be mapped to an approximate physical location — often to within a city. This article explains the technology behind it: how the mapping is built, how accurate it is, and where it breaks down.
The Building Blocks: Regional Internet Registries
Every IP address on the public internet is ultimately allocated by one of five Regional Internet Registries (RIRs):
| RIR | Region |
| ARIN | North America |
| RIPE NCC | Europe, Middle East, Central Asia |
| APNIC | Asia-Pacific |
| LACNIC | Latin America and Caribbean |
| AFRINIC | Africa |
RIRs allocate large blocks of IP addresses (called prefixes) to ISPs and organizations. Each allocation includes registration records that state which country and organization received the block. These records — publicly available through WHOIS — form the foundation of every geolocation database.
How Geolocation Databases Are Built
A raw RIR allocation record tells you "this block belongs to Comcast, a US company." But it doesn't tell you whether a specific Comcast IP is in Los Angeles or Chicago. To get city-level precision, geolocation providers layer additional data sources on top of the RIR records:
- BGP routing tables: The internet's routing protocol (BGP) announces which networks handle traffic for which IP prefixes. By analyzing where announcements originate geographically, providers can infer more granular location data.
- ISP cooperation: Many ISPs share their internal allocation data with geolocation companies, disclosing which IP ranges are assigned to which cities or regions within their network.
- Latency triangulation: By measuring network round-trip times from known reference points, geolocation providers can estimate how far an IP is from various cities. The physics of light-speed signal propagation puts a hard cap on how far apart two points can be given a measured latency.
- User-submitted corrections: Some providers crowdsource corrections from users who notice that their IP is mapped to the wrong city.
- Web crawls and DNS data: Analyzing which domains and services run on which IP addresses, then cross-referencing with known business locations, adds another signal.
Key point: No single data source is perfect. Commercial geolocation databases like IP2Location, MaxMind, and ipinfo.io combine all of the above, then continuously update and validate the results. The quality of the result depends on how much data exists for a given IP range.
What Gets Returned in a Lookup
A typical IP geolocation query returns several fields. Here is what each one means and where it comes from:
| Field | What It Means | Reliability |
| Country | The country where the IP block is registered | Very high (99%+) |
| Region / State | Sub-national administrative region | High (85–95%) |
| City | Nearest city to the IP's registered location | Moderate (60–80%) |
| ZIP / Postal Code | Estimated postal code — least reliable field | Low (40–60%) |
| ISP / AS Name | The network operator that owns the IP block | Very high |
| ASN | Autonomous System Number — unique ID for the network | Very high |
| Timezone | UTC offset for the registered city | High (follows city accuracy) |
| Latitude / Longitude | Approximate center of the registered city — not a precise location | Moderate |
| Is Proxy / VPN | Whether this IP is a known anonymization service | Moderate (depends on database coverage) |
Why Geolocation Is Sometimes Wrong
Several real-world networking patterns cause IP geolocation to produce incorrect or misleading results:
- Centralized ISP infrastructure: Many ISPs route all traffic through a regional hub. An IP assigned to a customer in a rural town may show as being in the state capital where the hub is located.
- Mobile networks: Cellular carriers use a small number of gateway IPs shared across a wide area. A phone in Denver on AT&T may show an IP registered to Dallas.
- VPNs and proxies: The IP resolves to the server's location, not the real user. This is the main reason people use VPNs — to appear to be in a different country.
- Cloud and data center IPs: AWS, Azure, and Google Cloud IPs resolve to the data center city, not the end user's location (which may be anywhere).
- Satellite internet: Starlink and similar services use IPs registered to ground station locations that may be hundreds of kilometers from the actual user.
- CGNAT: Carrier-Grade NAT has thousands of customers sharing a single public IP. The registered location is the carrier's equipment, not any individual subscriber.
Important: IP geolocation must never be used to determine someone's precise home or business address. It is a probabilistic, network-infrastructure-level estimate. Using it to make decisions about individual users' precise locations will produce errors and may raise legal concerns in some jurisdictions.
Legitimate Uses of IP Geolocation
Despite its limitations, IP geolocation is a valuable tool when used appropriately:
- Content localization: Serving the right language, currency, or regional content to website visitors automatically.
- Fraud and risk scoring: Flagging logins that originate from a country far from the user's usual location as a risk signal (not a definitive conclusion).
- Regulatory compliance: Blocking access to certain content in jurisdictions where it is legally restricted (e.g., GDPR-protected regions).
- Ad targeting: Delivering region-specific advertisements without requiring users to declare their location.
- Network diagnostics: Understanding where traffic is entering your network during an incident or DDoS attack.
- Analytics: Understanding the geographic distribution of your website's audience at country or regional level.