Доморощенный установлен: geoiplookup не показывает выход - как установить GeoIP-данные?

> geoipupdate; geoiplookup 8.8.4.4
> echo $?
0

Он не печатает никакого вывода. Согласно этому сообщению должны быть GeoIP-данные. Как использовать это на macOS?

> brew search geoip
geoip                                                                                                                                geoipupdate
homebrew/nginx/geoip2-nginx-module    homebrew/php/php53-geoip              homebrew/php/php54-geoip              homebrew/php/php55-geoip              homebrew/php/php56-geoip              homebrew/php/php70-geoip              homebrew/php/php71-geoip

Нет такого пакета. Как использовать geoiplookup на macOS/Homebrew?

> brew info geoip
geoip: stable 1.6.9 (bottled), HEAD
This library is for the GeoIP Legacy format (dat)
https://github.com/maxmind/geoip-api-c
/usr/local/Cellar/geoip/1.6.9 (17 files, 548.9K) *
  Poured from bottle on 2017-01-21 at 19:22:56
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/geoip.rb
==> Dependencies
Optional: geoipupdate ✔
==> Options
--universal
        Build a universal binary
--with-geoipupdate
        Build with geoipupdate support
--HEAD
        Install HEAD version
> brew info geoipupdate
geoipupdate: stable 2.3.1 (bottled), HEAD
Automatic updates of GeoIP2 and GeoIP Legacy databases
https://github.com/maxmind/geoipupdate
/usr/local/Cellar/geoipupdate/2.3.1 (13 files, 83.7K) *
  Poured from bottle on 2017-01-21 at 19:25:04
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/geoipupdate.rb
==> Options
--universal
        Build a universal binary
--HEAD
        Install HEAD version

Я хочу использовать локальные геоданные, а не запрашивать внешний веб-интерфейс API.

Ответы (3)

После установки geoipupdate и geoip с поддержкой geoipupdate перейдите к файлу /usr/local/Cellar/geoipupdate/2.3.1/etc/GeoIP.confи откройте его.

Заменять:

# Please see http://dev.maxmind.com/geoip/geoipupdate/ for instructions
# on setting up geoipupdate, including information on how to download a
# pre-filled GeoIP.conf file.

# Enter your user ID and license key below. These are available from
# https://www.maxmind.com/en/my_license_key. If you are only using free
# GeoLite databases, you make leave the 0 values.
UserId 0
LicenseKey 000000000000

# Enter the product IDs of the databases you would like to update.
# Multiple product IDs are separated by spaces.
ProductIds GeoLite2-Country GeoLite2-City
...

с:

# The following UserId and LicenseKey are required placeholders:
UserId 999999
LicenseKey 000000000000

# Include one or more of the following ProductIds:
# * GeoLite2-City - GeoLite 2 City
# * GeoLite2-Country - GeoLite2 Country
# * GeoLite-Legacy-IPv6-City - GeoLite Legacy IPv6 City
# * GeoLite-Legacy-IPv6-Country - GeoLite Legacy IPv6 Country
# * 506 - GeoLite Legacy Country
# * 517 - GeoLite Legacy ASN
# * 533 - GeoLite Legacy City
ProductIds GeoLite2-City GeoLite2-Country GeoLite-Legacy-IPv6-City GeoLite-Legacy-IPv6-Country 506 517 533
...

и обновить базу данных с помощью geoipupdate.

Ввод geoiplookup 8.8.4.4сейчас даст:

GeoIP Country Edition: US, United States
GeoIP City Edition, Rev 1: US, N/A, N/A, N/A, N/A, 37.750999, -97.821999, 0, 0

Обновлять:

Согласно комментарию adejones, файл GeoIP.conf переместился /usr/local/etc/GeoIP.confв более новые версии geoipupdate с «установленным пивом» .

У меня работало на macOS 10.13.3 с использованием brew 1.5.3, geoipupdate 2.5.0, однако файл конфигурации geoipupdate находится здесь:/usr/local/etc/GeoIP.conf
@adejones Спасибо за обновление. Я добавил дополнение...
Раскомментировал и соответственно установил первый номер, не работает. ``` 8 AccountID 999999 9 LicenseKey 000000000000 ``` ``` ~ ls /usr/local/Cellar/geoipupdate/ 3.1.1/ ~ brew --version Homebrew 1.8.3 ~ информация о варке geoip geoip: стабильная 1.6.12 ( в бутылках), HEAD... /usr/local/Cellar/geoip/1.6.12 (18 файлов, 548,9 КБ) * Залито из бутылки 25.11.2018 в 11:57:28 Из: github.com/Homebrew/ homebrew-core/blob/master/Formula/geoip.rb ... ```

Я до сих пор не могу понять, как я сделал эту работу, и почему это так неинтуитивно,

Вот что я сделал:

  brew install geoipupdate
  brew install libmaxminddb

затем

mmdblookup -i xx.xx.xx.xx -f /usr/local/var/GeoIP/GeoLite2-City.mmdb
откуда вы берете файлы БД?Can't open /usr/local/var/GeoIP/GeoLite2-City.mmdb - Error opening the specified MaxMind DB file

Используйте https://github.com/maxmind/mmdbinspect с базами данных с https://github.com/wp-statistics/GeoLite2-City :

mmdbinspect -db "$database_file" "$ip"

Вы можете использовать jqдля дальнейшей обработки вывода.