IP-based geolocation and intelligence
Fastly is able to determine the approximate general physical location of the end user based on their IP address. This is useful for providing content suitable for the region the user lives in, or enforcing licensing restrictions on content distribution.
IMPORTANT: GeoIP information, including data streamed by our log streaming service, is intended to be used only in connection with your Fastly services. Use of GeoIP data for other purposes may require permission from Digital Element, our data supplier.
Geolocation data is exposed in VCL and all official Compute@Edge SDKs. The IP address used for the geolocation lookup is automatically populated from the connection in some languages, but you can also always fetch geolocation data for an arbitrary IP.
|Language||Client IP||Custom geo lookup||Automatic connection-based geo data|
|VCL||See Geolocation variables|
Here is an example of adding geo information to a request before forwarding it to a backend:
- Fastly VCL
WARNING: Avoid using location data to select a language. The ability to speak a language is a property of a person, not the location where they are currently located. If possible, use the
Accept-Language header to customize language preferences.
Data updates and accuracy
The data is updated periodically, as IP allocations change and various amendments are made. Fastly does not own or control the data or the update frequency, but we release the latest version of the database to our network twice a week. If you discover inaccurate IP geolocation data, please report it to firstname.lastname@example.org.
Location information for some IPs is much more accurate than for others. IPs belonging to businesses may identify a specific office building. The location of domestic internet users will usually be less accurate, but close enough to identify the correct city. Mobile devices connected to cellular networks may not be anywhere near the actual location of the user but will usually be in the same country.
Some variables may be absent at any given time. For STRING types, the special value
? is used to indicate absent data.
Reserved IP address blocks
The IPv4 and IPv6 address spaces have several blocks reserved for special uses; these include private use networks (e.g., 192.168.0.0/16), loopback (127.0.0.1/8), and address ranges reserved for documentation (e.g., 203.0.113.0/24 RFC 5737 TEST-NET-3).
Geographic data has no meaningful association for these ranges, and so the Geolocation VCL variables present special values for these ranges instead. These values are:
|Property||VCL Variable||Value for reserved blocks|
|Country code (2 char)|
|Country code (3 char)|
The third-party geolocation database that Fastly uses may return "AOL" for region and city properties, despite AOL not representing a region or city per the region code requirements stated in ISO 3166-2.
AOL, an internet service provider, assigns dial-up users an internet access point based on the country in which their AOL account is established. This means that the IP addresses associated with their access to the internet don't necessarily reflect the country from which they are connecting.