*geoip* - Lookup maxmind geoip2 databases using the client IP, then add associated geoip data to the context request.
## Description
The *geoip* plugin add geo location data associated with the client IP, it allows you to configure a [geoIP2 maxmind database](https://dev.maxmind.com/geoip/docs/databases) to add the geo location data associated with the IP address.
The data is added leveraging the *metadata* plugin, values can then be retrieved using it as well, for example:
```go
import (
"strconv"
"github.com/coredns/coredns/plugin/metadata"
)
// ...
if getLongitude := metadata.ValueFunc(ctx, "geoip/longitude"); getLongitude != nil {
if longitude, err := strconv.ParseFloat(getLongitude(), 64); err == nil {
// Do something useful with longitude.
}
} else {
// The metadata label geoip/longitude for some reason, was not set.
You can download a [free and public City database](https://dev.maxmind.com/geoip/geolite2-free-geolocation-data).
## Syntax
```txt
geoip [DBFILE]
```
* **DBFILE** the mmdb database file path.
## Examples
The following configuration configures the `City` database.
```txt
. {
geoip /opt/geoip2/db/GeoLite2-City.mmdb
metadata # Note that metadata plugin must be enabled as well.
}
```
## Metadatada Labels
A limited set of fields will be exported as labels, all values are stored using strings **regardless of their underlying value type**, and therefore you may have to convert it back to its original type, note that numeric values are always represented in base 10.