IP geolocation

On this page 7

IP geolocation is the practice of estimating the physical location of a device, network or user from the IP address it uses on the Internet. In internet addressing, an address identifies a network interface, not a place, so every geolocation result is an inference built from external evidence: registry allocations, routing announcements, network measurements and data volunteered by operators or users.

The output is typically a country, region, city, postal code, approximate coordinates and an accuracy radius, often enriched with the network operator, the autonomous system number and flags for hosting, VPN or proxy use. Accuracy is high at country level and much weaker at city level, which shapes how the data should be used.

How IP geolocation databases are built

IP geolocation works by combining several independent data sources into a database that maps address ranges, usually expressed as CIDR prefixes, to locations. No single source is reliable on its own, so commercial and open providers weigh the evidence and publish the most probable location for each prefix together with a confidence estimate.

The starting point is the registry record. Regional Internet Registries such as ARIN, RIPE NCC, APNIC, LACNIC and AFRINIC record which organization holds each block and in which country it is registered. This record identifies the holder of the address block, which may be headquartered far from the customers who actually use the addresses.

The following table summarizes the main inputs and what each contributes.

SourceWhat it providesMain weakness
Registry and WHOIS dataHolder and registered country of a blockReflects the holder, not the user
BGP routing dataWhich autonomous system announces a prefixLarge networks span many countries
Latency measurementsDistance bounds from known probe locationsSignal speed and routing add error
Reverse DNS hostnamesCity or airport codes in router namesNaming is inconsistent and outdated
Operator geofeedsLocation published by the network itselfOnly as accurate as the operator
User-consented signalsGPS or Wi-Fi location tied to an addressPrivacy limits and sample bias
Data sources used in IP geolocation

Operators can publish self-declared geofeeds in the CSV format defined by RFC 8805, and RFC 9632 describes how to reference such a feed from registry records. Providers increasingly trust these feeds because they come from the party that knows where the addresses are deployed.

Accuracy levels and what limits them

IP geolocation accuracy falls sharply with granularity: country attribution is correct for the large majority of fixed broadband addresses, while city-level results are right only part of the time and coordinates are rarely meaningful at street level. Published accuracy figures vary by provider, region and network type, so any single number should be treated with caution.

LevelTypical reliabilitySuitable uses
CountryHigh for most fixed networksLicensing, compliance, language defaults
Region or stateModerate to highTax estimates, regional content
CityModerate, often within 25 to 100 kmLocal suggestions, analytics
Postal codeLow and inconsistentRough segmentation only
CoordinatesCentroid with an accuracy radiusNever a precise address
Typical reliability by level of detail

Several mechanisms degrade results. Carrier-grade NAT (CGNAT) places thousands of mobile subscribers behind a small pool of public addresses that often exit at a regional gateway hundreds of kilometers away. Anycast announces the same prefix from many sites, so one address has no single location. Addresses are also reassigned and transferred, and databases lag behind those changes by days or weeks.

When a provider has little evidence, it often falls back to a country or regional centroid. Coordinates that land in the geographic center of a country or a lake are a sign of this default, not of a real device in that spot.

IP geolocation compared with other location methods

IP geolocation is passive and requires no user permission, which makes it convenient but coarse compared with methods that read the device itself. The comparison below places it among the alternatives.

MethodTypical precisionConsent neededSpoofing resistance
IP geolocationCountry to cityNoLow
Browser Geolocation APIMeters to hundreds of metersYesModerate
GNSS on the deviceA few meters outdoorsYesModerate
Wi-Fi positioningTens of meters in citiesYesModerate
Cell tower dataHundreds of meters to kilometersCarrier accessHigh
Location methods compared

Because it only needs the source address of a connection, IP geolocation is the default first signal for anonymous web traffic. Services that need precision ask for device location with explicit consent and treat the IP result as a plausibility check rather than the answer.

Practical uses and implementation choices

Organizations use IP geolocation for content localization, licensing enforcement, fraud scoring, analytics and traffic routing. Each use tolerates a different error rate, so the design question is always what happens when the lookup is wrong.

  • Localization: choose a default language or currency, but always let the user change it.
  • Geo-restriction: block or allow content by country, accepting that VPNs bypass the check.
  • Fraud prevention: compare the IP country with the billing country as one risk signal among many.
  • Security operations: flag logins from unusual countries or from known hosting ranges.
  • Traffic engineering: steer users to nearby servers, although DNS-based steering often relies on the resolver address instead.

Implementations either query a hosted lookup API or load a local database file into the application. Local databases avoid network latency and keep user addresses in-house, but they must be updated at least weekly to follow address reassignments. Both IPv4 and IPv6 ranges need coverage, and IPv6 data is generally thinner because the address space is vast and allocations change more often.

Limitations, privacy and common mistakes

The most serious error is treating IP geolocation as evidence of a person’s exact location. Default coordinates have led to real cases where households near a national centroid received complaints intended for unknown internet users, which shows why results must never be presented as an address.

In many jurisdictions an IP address combined with location data is personal data, for example under the GDPR, so collection, retention and purpose need a legal basis. The table lists frequent implementation mistakes.

MistakeConsequenceBetter practice
Hard blocking on city dataLegitimate users locked outRestrict only at country level
Ignoring VPN and proxy flagsRestrictions are trivially bypassedCombine with anonymizer detection
Stale database filesReassigned ranges misplacedAutomate frequent updates
Treating coordinates as exactFalse accusations, wrong addressesShow the accuracy radius
Using the proxy addressEvery user appears at the CDNRead the trusted client header
Common mistakes and how to avoid them

Applications behind a reverse proxy or content delivery network must take the client address from a trusted forwarding header and validate it, otherwise every lookup returns the location of the proxy.

In everyday language

Every device online uses an IP address, which works like a return address on an envelope. IP geolocation is an educated guess about where that envelope came from, made by looking up which company owns the address and where that company usually uses it.

The guess is usually right about the country and often close for the city, but it cannot find a house or a person. A phone network, a VPN or a large company network can make someone appear far from where they really are. Think of it as a postmark showing the sorting office, not the sender’s front door.

Seen in the real world

A European online retailer uses IP geolocation on its storefront. When a visitor arrives from an address registered to a French broadband provider, the site preselects French and euro prices, while a banner lets the visitor switch both. The lookup runs against a local database refreshed every three days, so it adds no noticeable delay to page loads.

At checkout, the fraud team uses the same lookup as one risk signal. An order with a billing address in Lyon, an IP address in a data center range in another continent and a newly created account receives extra verification, while an order with a matching country passes normally. Over a quarter, the team finds that IP mismatch alone produced too many false alarms, mainly from travelers and corporate VPN users, so it now triggers review only when combined with other indicators.