IP geolocation is the process of determining a device's geographic location from its IP address. The technology is used for security, analytics, content personalization, and fraud prevention. This article explains how it works and how it is used in practice.
You can check information for any IP through IP Info on rechecker.ru.
How IP geolocation works
IP address allocation
IP addresses are allocated by regional internet registries (RIRs), including ARIN, RIPE NCC, APNIC, and others. Each provider is assigned address blocks associated with a region.
IP: 95.165.xxx.xxx
RIR: RIPE NCC (Европа)
Провайдер: Ростелеком
Регион: МоскваData sources
| Source | Accuracy | Updates | Use |
|---|---|---|---|
| RIR/WHOIS | Country, region | Infrequent | Basic geolocation |
| BGP tables | ASN, provider | Frequent | Routing |
| Geolocation databases (MaxMind, IP2Location) | City, coordinates | Weekly | Commercial use |
| CDNs/providers | Location by PoP | Real time | Content delivery |
Accuracy levels
| Level | Accuracy | Example |
|---|---|---|
| Country | 95–99% | Russia |
| Region/oblast | 85–95% | Moscow Oblast |
| City | 70–90% | Moscow |
| Coordinates | 50–80% | Latitude, longitude |
| Street/building | Unreliable | Not recommended |
Applications
Security
- Geo-blocking — restrict access from specific countries
- Anomaly detection — sign-ins from unusual locations
- Bot protection — check whether the IP matches the claimed location
- Rate limiting — apply different limits by region
Analytics
- Visitor geography — reports by country and city
- Regional A/B tests — different content for different markets
- CDN optimization — select the nearest PoP
Personalization
- Localization — language, currency, units of measurement
- Region-specific content — local news and offers
- Regulatory compliance — GDPR and local restrictions
Types of IP addresses
Public vs. private
| Type | Range | Geolocation |
|---|---|---|
| Public | Global routing | Yes |
| Private (10.x, 192.168.x, 172.16–31.x) | Local network | No |
| localhost (127.0.0.1) | Local host | No |
Static vs. dynamic
- Static — do not change and are assigned to an organization
- Dynamic — change when reconnecting (home internet, mobile)
VPNs and proxies
When using a VPN or proxy, geolocation points to the exit node, not the user's actual location.
GeoIP API response format
A typical response structure:
{
"ip": "95.165.123.45",
"country": "RU",
"country_name": "Russia",
"region": "MOW",
"region_name": "Moscow",
"city": "Moscow",
"latitude": 55.7558,
"longitude": 37.6173,
"timezone": "Europe/Moscow",
"isp": "Rostelecom",
"asn": "AS12389",
"asn_org": "Rostelecom"
}Limitations and inaccuracies
Causes of inaccuracies
- Mobile networks — the IP may point to a switching center rather than the device
- Corporate networks — centralized internet access
- VPNs and proxies — masking of the actual location
- Satellite internet — location associated with a ground station
- Outdated databases — delays in updating data
Legal considerations
- IP geolocation is indirect data and is not personal data under GDPR (in most cases)
- Consent may be required for personalization and advertising
- Geo-blocking must comply with local laws
Practical checks
Using a service
IP Info on rechecker.ru returns the country, region, city, provider, ASN, and coordinates for any IP. It is useful for checking your own IP, visitor IPs, and debugging location-dependent logic.
Using an API
# Пример запроса к сервису геолокации
curl "https://api.example.com/ip/95.165.123.45"Local databases (MaxMind GeoLite2)
import geoip2.database
reader = geoip2.database.Reader('/path/to/GeoLite2-City.mmdb')
response = reader.city('95.165.123.45')
print(response.country.iso_code, response.city.name)Types of GeoIP databases
| Database | Size | Accuracy | License |
|---|---|---|---|
| MaxMind GeoLite2 | ~70 MB | City | Free, CC BY-SA |
| MaxMind GeoIP2 | ~90 MB | Higher | Paid |
| IP2Location | Various | High | Paid |
| DB-IP | ~50 MB | Medium | Free Lite |
X-Forwarded-For header
When using a proxy, the client's real IP may be passed in headers:
X-Forwarded-For: client, proxy1, proxy2
X-Real-IP: clientUse the first IP in X-Forwarded-For (or X-Real-IP) if you trust the proxy. Otherwise, the IP can be spoofed.
Application integration
Node.js (maxmind)
const maxmind = require('maxmind');
const lookup = await maxmind.open('/path/to/GeoLite2-City.mmdb');
const result = lookup.get('95.165.123.45');
console.log(result?.country?.iso_code, result?.city?.names?.ru);PHP (geoip2)
<?php
require_once 'vendor/autoload.php';
$reader = new GeoIp2\Database\Reader('/path/to/GeoLite2-City.mmdb');
$record = $reader->city('95.165.123.45');
echo $record->country->isoCode . ' ' . $record->city->name;Recommendations
- Do not rely on the city for critical decisions — accuracy is limited
- Use the country and region — reliable enough for most tasks
- Account for VPNs — some traffic will come from unexpected locations
- Update databases — GeoIP data becomes outdated
- Cache results — reduce load on APIs and databases
- Check X-Forwarded-For — when operating behind a proxy, use a trusted source for the IP
- Do not use for authentication — IPs are easy to spoof and should only be a supplementary signal
- Account for IPv6 — more traffic is using IPv6, and databases are less accurate for it
- Test with real IPs — check several addresses from target regions before launching location-dependent logic
- Document the data source — when making location-based decisions, record which database was used
IP Info is a quick way to check the geolocation of any IP without installing databases or using API keys.