Learn R Programming

rgeolocate (version 0.5.0)

maxmind: Geolocate IP Addresses through MaxMind Databases

Description

MaxMind does a set of proprietary geolocation databases - they're pretty accurate! maxmind provides a connector to MaxMind services.

Usage

maxmind(ips, file, fields = c("continent_name", "country_name",
  "country_code"))

Arguments

ips
a character vector of IP addresses (IPv4 and IPv6 both work)
file
the full path to the .mmdb file you want to query.
fields
the fields you want to retrieve - options are:
  • continent_name
{: the English-language name of the continent. Requires a country or city database.} country_name{: the English-language name of the country Requires a country or

Details

geolookup uses the http://dev.maxmind.com/geoip/geoip2/downloadable/{MaxMind GeoIP2 databases} to geolocate IP addresses, retrieving any of the data listed in fields. Different fields are appropriate for different provided files; the connection type databases, for example, contain connection types and nothing else, while the city- and country-level files don't contain connection types at all.

In the event that the file provided does not have the field you have requested (or the IP address does not have an entry for that field), the string "Unknown" (or NA for a numeric field such as latitude or longitude) will be returned instead. In the event that the IP address doesn't have an entry in the file at all, "Unknown"/NA will be returned for every field.

Examples

Run this code
file <- system.file("extdata","GeoLite2-Country.mmdb", package = "rgeolocate")
results <- maxmind("196.200.60.51", file, "country_code")

Run the code above in your browser using DataLab