Geolocation VCL features

Fastly exposes a number of geographic variables for you to take advantage of inside VCL for both IPv4 and IPv6 client IPs.


All geographic data presented through these variables is associated with a particular IP address. This address is automatically populated from client.ip by default, but may be overridden explicitly by setting client.geo.ip_override.

Geographic variables representing names are available in several encodings. Note in particular the *.ascii variables are lossy. These variables have diacritics removed and are normalized to lowercase spellings. These *.ascii variables can be used as a symbolic string in code (for example, to perform some different action depending on the city name). Due to their simplified content, however, they are generally inappropriate for presenting to users.

Using geographic variables with shielding

If you have shielding enabled, you should set the following variable before using geographic variables:

set client.geo.ip_override = req.http.Fastly-Client-IP;

Absent data

For STRING types, the special value ? is used to indicate absent data. These may be normalized to VCL empty strings using the if() ternary operator:

log if ( == "?",, "");

In general strings in VCL may be not set (see the VCL documentation for types). This never occurs for the geolocation variables.

Reserved IP address blocks

The IPv4 and IPv6 address spaces have several blocks reserved for special uses. These include private use networks (e.g.,, loopback (, and address ranges reserved for documentation (e.g., RFC 5737 TEST-NET-3).

Geographic data has no meaningful association for these ranges. The geolocation VCL variables present special values for these ranges instead. These values are:

Variable Value for reserved blocks 0 ?
client.geo.latitude 0.000
client.geo.longitude 0.000
client.geo.conn_speed broadband
client.geo.metro_code -1
client.geo.gmt_offset 9999
client.geo.area_code 0
client.geo.postal_code 0
client.geo.continent_code **
client.geo.country_code **
client.geo.country_code3 ***
client.geo.country_name reserved/private reserved
client.geo.region ***

Additional resources: