How IP geolocation works
An IP address carries no geographic information. When a website shows your country and city, it looks your address up in a database. That database is built from registry records, operator-published data and latency measurements. The country is usually more reliable than the city, and both can be wrong, because the address follows the network's location rather than yours.
Address location versus device location
There are two separate methods. The first is an estimate from the IP address, which the server makes without asking you, since the address arrives with every request. The second is the device's own location, which a site requests from the browser.
The W3C Geolocation specification covers the second method. The site needs your express permission, so the browser asks you first. The device works out its position from GPS, Wi-Fi networks and cell towers, and returns an accuracy radius in metres.
This article is about the first method: what a server can infer from the address alone.
Where the data comes from
There is no single official database of address locations. Specialist companies build their own from several sources and weigh each source differently:
- Registry records. Every address block is registered with a regional registry, and its record has a country field and the registrant's address. That points to the organisation's headquarters, not to where the addresses are used.
- Operator-published files. A network operator knows where it uses each block and can publish this in a file called a geofeed, described below.
- Latency measurements. A signal in optical fibre can only cover so much distance per millisecond. Measuring round-trip time from known points puts an upper bound on how far the address is from each one.
- Router names. Many operators put a city code in the reverse DNS names of their routers, so a traceroute reveals the cities the packets pass through.
- Usage data. Some providers match addresses with locations reported by apps or users, and with corrections sent in by network owners.
Geofeeds: what operators publish themselves
RFC 8805 defines a simple format for this file: one line per prefix, with the country code, region code and city. The fifth field, postal code, is deprecated and the RFC advises leaving it empty:
# ip_prefix,alpha2code,region,city,postal_code
203.0.113.0/24,SY,SY-DI,Damascus,
2001:db8:100::/48,SY,SY-HL,Aleppo,
RFC 9632 then explains how others find the file. The operator adds a line pointing to its URL in the block's record in the regional registry's database:
inetnum: 203.0.113.0 - 203.0.113.255
geofeed: https://example.net/geofeed.csv
The file can be signed with an RPKI certificate to prove it comes from the address holder, but signing is optional. RFC 8805 makes no promise of accuracy and leaves databases free to treat the data as a hint.
Why the estimate goes wrong
| Cause | What happens |
|---|---|
| Carrier address translation | Subscribers in distant cities leave through one gateway and are all placed at its location |
| Mobile network design | Data usually reaches the internet through a few central gateways, not near the tower serving you |
| Address transfers | Blocks move between cities, operators and countries, and databases lag behind |
| Registration country | The block is registered to the company's headquarters and used in another country |
| Intermediaries | With a VPN, a proxy or a satellite link, the server's or ground station's location shows |
| Disagreeing sources | Each database weighs its sources differently, so two sites give two answers for one address |
The effect of address translation is documented in RFC 6269: a subscriber behind a translator geolocates to wherever the translator's prefix appears to be. That is why mobile addresses usually show the gateway's city, wherever the phone is. The translation itself is explained in What is CGNAT.
IPv6 and location
With IPv6, each home or subscription usually gets a whole prefix of its own rather than an address shared with others. An IPv6 estimate can therefore be more precise, because the prefix does not pass through a translator that merges subscribers from different cities.
The temporary addresses operating systems generate only change the second half of the address. The prefix that identifies your network stays the same, and that is what the estimate is based on. If your device uses both versions, sites may place it in two different locations.
One address, many places
Some addresses have no single location at all. With anycast routing, a network announces the same prefix from many sites around the world. Each user reaches the nearest copy of the server at the same address.
The DNS root servers work this way, as do many public resolvers and content delivery networks. Any database that places such an address in one city is bound to be wrong for most of its users.
The reverse also happens: one block used by an operator in several cities. The estimate is then right for part of the addresses and wrong for the rest, until the operator publishes finer detail.
How websites use the estimate
- Language and currency. The site picks your country's version automatically, which you can usually change.
- Content rights. Streaming and media services block what they are not licensed to show in your country. See Geo-blocking.
- Risk scoring. Fraud systems compare the address's country with the card's country, the time zone and the browser language. A large mismatch is one signal among many, as described in How websites detect VPNs and proxies.
- Legal compliance. Some services are required to restrict access from certain countries.
How to check the location tied to your address
- Open What is my IP to see the country, city and network assigned to your current address.
- Look up the same address in more than one database. A different city is normal; a different country deserves attention.
- To see the cities your packets pass through, run a traceroute without the option that hides names. Use
tracerton Windows ortracerouteon Linux and macOS, and read the router names. - If a site asks for location permission, it wants the device's location, not the address's. Declining does not change the estimate from the address.
How to correct or control it
- If you run a network: publish a geofeed, reference it in the block's registry record, and ask the major database providers to read it. It is the most reliable source you control.
- If you are a user: most database providers accept correction requests. The provider that gives you the address may not be able to change what other databases show.
- If you use an intermediary: the country shown is that of the exit address. Keep the other signals consistent with it, such as time zone and browser language, and decline location permission when you do not need it.
syriaproxy addresses
The addresses your traffic leaves from with syriaproxy are mobile addresses from Syriatel's 4G network inside Syria, so databases place them in Syria. The city depends on what each database records for Syriatel's gateways and can differ from one tool to the next.
FAQ
Why does my address show a city I do not live in?
Because the estimate follows the network. Your provider may route subscribers from several cities through one gateway, or the database has not caught up with a block transfer.
Can a website find my home address from my IP?
No. At best the estimate reaches the level of a city or region. Identifying the subscriber requires the provider's records.
Why do two websites give different results?
Each one uses a different database, with different sources and a different update date.
Is changing the address enough to change the country a site sees?
It changes the country the site estimates from the address. Sites may also look at browser language and time zone, the device's location if you allow it, and the country of your payment method.
Look up any IP to see the country, city and network assigned to it.