geoipupdateが動かなくなったのでいろいろ変更した件
cronで実行してたgeoipupdateが失敗するようになってた。そして、こんな感じのメールが届くようになった。
Received an unexpected HTTP status code of 401 from https://updates.maxmind.com/app/update_secure?db_md5=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&challenge_md5=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx&user_id=xxxxxx&edition_id=xxx
このページに理由書いてた
GeoLite2 Free Downloadable Databases « MaxMind Developer Site
「古いのやめます。無償ユーザーはGeoLite2へ移行してね。」(超意訳)
geoipupdateで使うGeoIP.confの変更の仕方はここに書いてた
Automatic Updates for GeoIP2 and GeoIP Legacy Databases « MaxMind Developer Site
手元のCentOS6はgeoipupdateが2.5じゃなくepelで入れた古いものだったので、下記のような感じで設定変更
UserID 0 LicenseKey 000000000000 ProductIds GeoLite2-City GeoLite2-Country GeoLite2-ASN
これでgeoipupdateが通るようになるが、
# ls /usr/share/GeoIP/GeoLite2* /usr/share/GeoIP/GeoLite2-ASN.mmdb /usr/share/GeoIP/GeoLite2-City.mmdb /usr/share/GeoIP/GeoLite2-Country.mmdb
こんな感じで、拡張子がmmdbっていう見たことない形式になってる…
※以前は拡張子dat
割愛するけど要するに独自形式ということで、
geoiplookupコマンドからは読めなくなってる
今はpythonかperlかphpくらいでやらないといけなくて、
誰か偉い人がgeoiplookupコマンドをmmdbに対応してくれるのを待つか考えよう。
一応手元では、pythonでやってみて、一応動いてるっぽい。
あとgeoipupdateのcron実行に関して
毎月第一火曜 GeoLite2-City GeoLite2-Country 毎週火曜 GeoLite2-ASN
にそれぞれ更新されるので、
更新された後に、実行されるようにスケジュール設定しよう。
こんな風に設定した。
# cat /etc/cron.d/geoipupdate 34 23 1-7 * * root [ "$(date '+\%w')" -eq 2 ] && geoipupdate -f /etc/GeoIP-City.conf 23 23 * * 2 root geoipupdate -f /etc/GeoIP-ASN.conf
参考
crontabで第?曜日にタスクを実行する方法 - Webサービスで起業を目指すプログラマーblog
GeoIP-City.confは ProductIDs を GeoLite2-City だけにして、
GeoIP-ASN.confは ProductIDs を GeoLite2-ASN だけにしてる。
GeoLite2-Countryは多分使わない。