What is Geofeed

Geofeed, a.k.a. geolocation feed, is a data format laid out in the RFC 8805 specification. It is used by network operators to provide geolocation information for their IP prefixes.

Importance of geolocation

Many online services rely on geolocation to optimize the user experience. Among the functionalities that geolocation provides is the ability to redirect users to the nearest server, thereby providing a fast response to the end user. Geolocation can also help in targeted advertisement to ensure that only users from certain regions are served ads from their localities. Websites like news portals also can benefit by showing localized news to attract more eyeballs.

Why do we need Geofeed

The main reason for the existence of the Geofeed is to provide an efficient and faster update process for any geolocation data provider. If an ISP changes the location where their IP prefix is deployed, anyone interested in geolocation can just parse the Geofeed file and update their data.

Without a Geofeed, geolocation data providers will have to perform various tasks like running a traceroute, just to find the approximate geolocation. This is highly inefficient when you are dealing with millions of IP prefixes. Any inaccuracies in the geolocation data collected can affect sales, advertising, security, etc. for online businesses depending on said data.

How to setup a Geofeed

The Geofeed is just a simple Comma-Separated-Values (CSV) file with a few columns of data to map an IP prefix to its location. However, any lines starting with a “#” character are considered comments and should be ignored by any geolocation parser. Feeds must use the UTF-8 encoding and also use CRLF as the EOL.

As for the columns, they should be laid out in the order specified below:
ip_prefix,alpha2code,region,city,postal_code

Meaning of each field

ip_prefix

Each IP prefix field MUST be either a single IP address or an IP prefix in CIDR notation.

E.g.

“192.0.2.1” or “192.0.2.0/24” for IPv4

“2001:db8::1” or “2001:db8::/32” for IPv6

alpha2code

The 2-letter ISO country code conforming to ISO 3166-1 alpha 2.

Parsers SHOULD treat this field case-insensitively.

E.g.

“US” for the United States, “JP” for Japan, and “PL” for Poland

region

An ISO region code conforming to ISO 3166-2.

Parsers SHOULD treat this field case-insensitively.

E.g.

“ID-RI” for the Riau province of Indonesia and “NG-RI” for the Rivers province in Nigeria.

city

Should be free UTF-8 text, excluding the comma (‘,’) character. IP2Location only accepts unaccented names so São Paulo should be written as Sao Paulo like below.

E.g.

“Dublin”, “New York”, and “Sao Paulo”.

postal_code (DEPRECATED)

Should be free UTF-8 text, excluding the comma (‘,’) character.

New feeds SHOULD NOT include this field.

Examples

According to the RFC 8805, only the ip_prefix field is mandatory. So the below is considered a valid Geofeed.

193.0.24.0/21,,,,
2001:67c:64::/48,,,,
199.91.192.0/21,,,
2620:f:8000::/48,,,

But, for IP2Location to accept any Geofeed files, we require data for the ip_prefix, alpha2code, region and city. The postal_code field can be blank.

E.g.

193.0.24.0/21,NL,NL-ZH,Rotterdam,
2001:67c:64::/48,NL,NL-ZH,Rotterdam,
199.91.192.0/21,MA,MA-07,Marrakech,
2620:f:8000::/48,MA,MA-07,Marrakech,

Submission to IP2Location

Once you have a Geofeed file, you can host it on your own websites. Then send the URL to the email address below for inclusion in our monthly geolocation data processing.

Note that the Geofeed must be hosted on your own domain as part of the source validation. We will not accept any Geofeed file sent to us by email.

E.g.

https://example.com/ip2location.csv

The inclusion of every Geofeed file in IP2Location is subject to review and approval. Low quality Geofeed file or abuses will result in the Geofeed file exclusion automatically without notification by algorithm.

Do note that IP2Location is capable of locating your Geofeed file if you publish the link to the file inside your network subnet WHOIS data. You can refer to our article Finding and Using Geofeed File (RFC 9632). So this method is an alternative to emailing the Geofeed to IP2Location.

Was this article helpful?

Related Articles