geoip
IP-based geolocation query
geoip : IP-based geolocation query
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 1560 | geoip | geoip | 0.3.0 |
GIS | BSD-2-Clause | SQL |
| Attribute | Has Binary | Has Library | Need Load | Has DDL | Relocatable | Trusted |
|---|---|---|---|---|---|---|
| --s-d-- | No | Yes | No | Yes | no | no |
| Relationships | |
|---|---|
| Schemas | geoip |
| Requires | ip4r |
| See Also | postgis_tiger_geocoder tzf nominatim_fdw pg_geohash |
no pg17 on el9, no legacy branch on el8
Packages
| Type | Repo | Version | PG Major Compatibility | Package Pattern | Dependencies |
|---|---|---|---|---|---|
| EXT | MIXED | 0.3.0 |
18 17 16 15 14 | geoip |
ip4r |
| RPM | PIGSTY | 0.3.0 |
18 17 16 15 14 | geoip_$v |
- |
| DEB | PIGSTY | 0.3.0 |
18 17 16 15 14 | postgresql-$v-geoip |
- |
| Linux / PG | PG18 | PG17 | PG16 | PG15 | PG14 |
|---|---|---|---|---|---|
| el8.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| el8.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| el9.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| el9.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| el10.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| el10.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| d12.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| d12.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| d13.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| d13.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| u22.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| u22.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| u24.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| u24.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| u26.x86_64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
| u26.aarch64 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 | PIGSTY 0.3.0 |
Source
github.com/tvondra/geoip
geoip-0.3.0.tar.gz
Install
Make sure PGDG and PIGSTY repo available:
Install this extension with pig:
Create this extension with:
Usage
This extension provides IP-based geolocation — you provide an IPv4 or IPv6 address and the extension looks up country, city, GPS coordinates, ASN and more. It requires the ip4r extension and GeoLite2 data from MaxMind.
Functions
| Function | Description |
|---|---|
geoip_country_code(ip4|ip6) |
Returns country code (2 chars) |
geoip_country(ip4|ip6) |
Returns all country info (code, name, network) |
geoip_city_location(ip4|ip6) |
Returns just the location ID (INT) |
geoip_city(ip4|ip6) |
Returns all city info (GPS, ZIP code, etc.) |
geoip_asn(ip4|ip6) |
Returns ASN name and IP range |
Examples
Loading Data
The extension requires GeoLite2 CSV data from MaxMind. Download the City, Country, and ASN datasets in CSV format from MaxMind GeoLite2, then load:
The “locations” files have multiple language variants — pick the one that works for you.