coredns/man/coredns-geoip.7
coredns[bot] 3f881c7202 auto remove trailing whitespaces
Signed-off-by: coredns[bot] <bot@bot.coredns.io>
2021-07-20 10:28:21 +00:00

118 lines
3.2 KiB
Groff

.\" Generated by Mmark Markdown Processer - mmark.miek.nl
.TH "COREDNS-GEOIP" 7 "July 2021" "CoreDNS" "CoreDNS Plugins"
.SH "NAME"
.PP
\fIgeoip\fP - Lookup maxmind geoip2 databases using the client IP, then add associated geoip data to the context request.
.SH "DESCRIPTION"
.PP
The \fIgeoip\fP plugin add geo location data associated with the client IP, it allows you to configure a geoIP2 maxmind database
\[la]https://dev.maxmind.com/geoip/docs/databases\[ra] to add the geo location data associated with the IP address.
.PP
The data is added leveraging the \fImetadata\fP plugin, values can then be retrieved using it as well, for example:
.PP
.RS
.nf
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.
}
// ...
.fi
.RE
.SH "DATABASES"
.PP
The supported databases use city schema such as \fB\fCCity\fR and \fB\fCEnterprise\fR. Other databases types with different schemas are not supported yet.
.PP
You can download a free and public City database
\[la]https://dev.maxmind.com/geoip/geolite2-free-geolocation-data\[ra].
.SH "SYNTAX"
.PP
.RS
.nf
geoip [DBFILE]
.fi
.RE
.IP \(bu 4
\fBDBFILE\fP the mmdb database file path.
.SH "EXAMPLES"
.PP
The following configuration configures the \fB\fCCity\fR database.
.PP
.RS
.nf
\&. {
geoip /opt/geoip2/db/GeoLite2\-City.mmdb
metadata # Note that metadata plugin must be enabled as well.
}
.fi
.RE
.SH "METADATADA LABELS"
.PP
A limited set of fields will be exported as labels, all values are stored using strings \fBregardless of their underlying value type\fP, and therefore you may have to convert it back to its original type, note that numeric values are always represented in base 10.
.RS
.TS
allbox;
l l l l
l l l l .
\fBLabel\fP\fB Type\fP\fB Example\fP\fB Description\fP
\fB\fCgeoip/city/name\fR \fB\fCstring\fR \fB\fCCambridge\fR Then city name in English language.
\fB\fCgeoip/country/code\fR \fB\fCstring\fR \fB\fCGB\fR Country ISO 3166-1
\[la]https://en.wikipedia.org/wiki/ISO_3166-1\[ra] code.
\fB\fCgeoip/country/name\fR \fB\fCstring\fR \fB\fCUnited Kingdom\fR The country name in English language.
\fB\fCgeoip/country/is_in_european_union\fR \fB\fCbool\fR \fB\fCfalse\fR Either \fB\fCtrue\fR or \fB\fCfalse\fR.
\fB\fCgeoip/continent/code\fR \fB\fCstring\fR \fB\fCEU\fR See Continent codes
\[la]#ContinentCodes\[ra].
\fB\fCgeoip/continent/name\fR \fB\fCstring\fR \fB\fCEurope\fR The continent name in English language.
\fB\fCgeoip/latitude\fR \fB\fCfloat64\fR \fB\fC52.2242\fR Base 10, max available precision.
\fB\fCgeoip/longitude\fR \fB\fCfloat64\fR \fB\fC0.1315\fR Base 10, max available precision.
\fB\fCgeoip/timezone\fR \fB\fCstring\fR \fB\fCEurope/London\fR The timezone.
\fB\fCgeoip/postalcode\fR \fB\fCstring\fR \fB\fCCB4\fR The postal code.
.TE
.RE
.SH "CONTINENT CODES"
.RS
.TS
allbox;
l l
l l .
\fBValue\fP\fB Continent (EN)\fP
AF Africa
AN Antarctica
AS Asia
EU Europe
NA North America
OC Oceania
SA South America
.TE
.RE