先日、下記の記事を書きました。
そこで利用しているGeoIPのDatabaseの更新はどうするのか?
GeoLite2 Free Downloadable Databases
https://dev.maxmind.com/geoip/geoip2/geolite2/
Automatic Updates for GeoIP2 and GeoIP Legacy Databases
https://dev.maxmind.com/geoip/geoipupdate/
geoipupdateコマンドをcronで定期的に更新する方法が記載されていました。
geoipupdateコマンドが無い場合は下記のコマンドでインストールして下さい。
1 2 3 |
[root@centos7 ~]# yum -y install geoipupdate [root@centos7 ~]# which geoipupdate /bin/geoipupdate |
試しにdatabaseを更新してみます。
設定ファイルは/etc/GeoIP.confですが、無償ライセンスの場合はそのままで大丈夫でした。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
[root@centos7 ~]# geoipupdate -V geoipupdate 2.5.0 [root@centos7 ~]# geoipupdate -v geoipupdate 2.5.0 Opened License file /etc/GeoIP.conf AccountID 0 LicenseKey 000000000000 Insert edition_id GeoLite2-Country Insert edition_id GeoLite2-City Read in license key /etc/GeoIP.conf Number of edition IDs 2 url: https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-Country md5hex_digest: 00000000000000000000000000000000 url: https://updates.maxmind.com/app/update_getipaddr Client IP address: xxx.xxx.xxx.xxx md5hex_digest2 (challenge): ff9e41ea4167f7285dcdf16a134cf49c url: https://updates.maxmind.com/app/update_secure?db_md5=00000000000000000000000000000000&challenge_md5=ff9e41ea4167f7285dcdf16a134cf49c&user_id=0&edition_id=GeoLite2-Country Uncompress file /usr/share/GeoIP/GeoLite2-Country.mmdb.gz to /usr/share/GeoIP/GeoLite2-Country.mmdb.test Rename /usr/share/GeoIP/GeoLite2-Country.mmdb.test to /usr/share/GeoIP/GeoLite2-Country.mmdb url: https://updates.maxmind.com/app/update_getfilename?product_id=GeoLite2-City md5hex_digest: 00000000000000000000000000000000 url: https://updates.maxmind.com/app/update_getipaddr Client IP address: xxx.xxx.xxx.xxx md5hex_digest2 (challenge): ff9e41ea4167f7285dcdf16a134cf49c url: https://updates.maxmind.com/app/update_secure?db_md5=00000000000000000000000000000000&challenge_md5=ff9e41ea4167f7285dcdf16a134cf49c&user_id=0&edition_id=GeoLite2-City Uncompress file /usr/share/GeoIP/GeoLite2-City.mmdb.gz to /usr/share/GeoIP/GeoLite2-City.mmdb.test Rename /usr/share/GeoIP/GeoLite2-City.mmdb.test to /usr/share/GeoIP/GeoLite2-City.mmdb |
CentOSの場合は/usr/share/GeoIP/が標準のDatabase保存場所になります。
1 2 3 4 5 6 7 |
[root@centos7 ~]# ls -l /usr/share/GeoIP/ -rw-r--r-- 1 root root 1242574 Aug 8 21:04 GeoIP-initial.dat lrwxrwxrwx 1 root root 17 Sep 23 09:38 GeoIP.dat -> GeoIP-initial.dat -rw-r--r-- 1 root root 2322773 Aug 8 21:04 GeoIPv6-initial.dat lrwxrwxrwx 1 root root 19 Sep 23 09:38 GeoIPv6.dat -> GeoIPv6-initial.dat -rw-r--r-- 1 root root 62561769 Oct 2 20:20 GeoLite2-City.mmdb -rw-r--r-- 1 root root 3936777 Oct 2 20:20 GeoLite2-Country.mmdb |
さて、geoipupdateをcrondでスケジュール実行させるのですが、Databaseの更新が毎週火曜日との記載があったので念のために木曜日に実行するように設定しました。
https://dev.maxmind.com/geoip/geoip2/geolite2/
The GeoLite2 Country, City, and ASN databases are updated weekly, every Tuesday.
1 2 3 4 5 6 7 |
[root@centos7 ~]# crontab -e [root@centos7 ~]# crontab -l # GeoIP Update 0 12 * * 4 /bin/geoipupdate [root@centos7 ~]# systemctl restart crond |
これで毎週更新されたDatabaseが利用できます。
最後に一定期間に何度も更新を掛けると制限されるようです。
Download Limits
MaxMind reserves the right to limit the number of downloads made within a limited period of time.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
GEOIPUPDATE(1) General Commands Manual GEOIPUPDATE(1) NAME geoipupdate - GeoIP2 and GeoIP Legacy Update Program SYNOPSIS geoipupdate [-Vvh] [-f license_file] [-d target_directory] DESCRIPTION geoipupdate automatically updates GeoIP2 and GeoIP Legacy databases for MaxMind customers. The pro- gram connects to the MaxMind GeoIP Update server to check for new databases. If a new database is available, the program will download and install it. If you are using a firewall, you must have the DNS and HTTP(S) ports open. OPTIONS -V Display version information. -v Enable verbose mode. Prints out the steps that geoipupdate takes. -d Install databases to a custom directory. By default geoipupdate installs to /usr/share/GeoIP. -f Use an alternate configuration file. Defaults to /etc/GeoIP.conf. USAGE Typically you should run geoipupdate weekly. One way to achieve this is to use cron. Below is a sam- ple crontab file that runs geoipupdate on each Wednesday at noon: # top of crontab MAILTO=your@email.com 0 12 * * 3 BIN_DIR/geoipupdate # end of crontab To use with a proxy server, update your GeoIP.conf file as specified in the GeoIP.conf man page or set the http_proxy environment variable. RETURN CODES geoipupdate returns 0 on success and 1 on error. FILES /etc/GeoIP.conf Configuration file for GeoIP Update. See the GeoIP.conf(5) man page for more information. AUTHOR Written by T.J. Mather and Boris Zentner. REPORTING BUGS Report bugs to <support@maxmind.com>. COPYRIGHT Copyright (C) 2013 MaxMind, Inc. This is free software; see the LICENSE file for copying conditions. There is NO WARRANTY, express or implied, including, but not limited to, NO IMPLIED WARRANTY of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MORE INFORMATION Visit <https://www.maxmind.com/en/geolocation_landing> to learn more about the GeoIP2 and GeoIP Legacy databases or to sign up for a subscription. SEE ALSO GeoIP.conf(5), crontab(5) 4th Berkeley Distribution 25 Sep 2013 GEOIPUPDATE(1) |