GeoIPをインストール

    パケットインストール
[root@falcon21 ~]# yum install mod_geoip GeoIP GeoIP-devel GeoIP-data zlib-devel
インストール:
  GeoIP-data.noarch 0:1.5.0-13.el7       GeoIP-devel.x86_64 0:1.5.0-13.el7       mod_geoip.x86_64 0:1.2.10-1.el7

完了しました!


   データベース取得 
[root@falcon21 ~]# cd /usr/share/GeoIP/
[root@falcon21 GeoIP]# curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 27.6M  100 27.6M    0     0   9.7M      0  0:00:02  0:00:02 --:--:--  9.7M

[root@falcon21 GeoIP]# curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-Country.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1823k  100 1823k    0     0  3633k      0 --:--:-- --:--:-- --:--:-- 3632k

[root@falcon21 GeoIP]# curl -O http://geolite.maxmind.com/download/geoip/database/GeoLite2-ASN.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3442k  100 3442k    0     0  8216k      0 --:--:-- --:--:-- --:--:-- 8216k

GeoIP-initial.dat # 初期導入時に作成されるモジュール
GeoLiteCity.dat # (更新対象)都市別
GeoLiteCountry.dat # (更新対象)国別

データを最新化 [root@falcon21 ~]# geoipupdate -v
Opened License file /etc/GeoIP.conf
Read in license key 000000000000
number of product ids 2
Connecting to MaxMind GeoIP server
via Host or Proxy Server: updates.maxmind.com:80
sending request GET /app/update_getfilename?product_id=506 HTTP/1.0
Host: updates.maxmind.com

database product id 506 database file name /usr/share/GeoIP/GeoLiteCountry.dat
/usr/share/GeoIP/GeoLiteCountry.dat can't be opened, proceeding to download database
MD5 sum of database /usr/share/GeoIP/GeoLiteCountry.dat is 0000000000000000000000000000000
Connecting to MaxMind GeoIP Update server
sending request GET /app/update_getipaddr HTTP/1.0
Host: updates.maxmind.com
client ip address: 203.181.3.94
md5sum of ip address and license key is ad1e53d2fd245283077e39cb344292b5
sending request GET /app/update_secure?db_md5=0000000000000000000000000000000&challenge_md5=ad1e53d2fd245283077e39cb344292b5&user_id=999999&edition_id=506 HTTP/1.0
Host: updates.maxmind.com

Downloading gzipped GeoIP Database...
Done
Updating /usr/share/GeoIP/GeoLiteCountry.dat
Saving gzip file to /usr/share/GeoIP/GeoLiteCountry.dat.gz ... download data to a gz file named /usr/share/GeoIP/GeoLiteCountry.dat.gz
Done
Uncompressing gzip file ... Done
Performing sanity checks ... Database type is 1
database_info  FAIL null
Received Error -21 (Sanity check database_info string failed) when attempting to update GeoIP Database
Connecting to MaxMind GeoIP server
via Host or Proxy Server: updates.maxmind.com:80
sending request GET /app/update_getfilename?product_id=533 HTTP/1.0
Host: updates.maxmind.com

database product id 533 database file name /usr/share/GeoIP/GeoLiteCity.dat
/usr/share/GeoIP/GeoLiteCity.dat can't be opened, proceeding to download database
MD5 sum of database /usr/share/GeoIP/GeoLiteCity.dat is 0000000000000000000000000000000
md5sum of ip address and license key is ad1e53d2fd245283077e39cb344292b5
sending request GET /app/update_secure?db_md5=0000000000000000000000000000000&challenge_md5=ad1e53d2fd245283077e39cb344292b5&user_id=999999&edition_id=533 HTTP/1.0
Host: updates.maxmind.com

Downloading gzipped GeoIP Database...
Done
Updating /usr/share/GeoIP/GeoLiteCity.dat
Saving gzip file to /usr/share/GeoIP/GeoLiteCity.dat.gz ... download data to a gz file named /usr/share/GeoIP/GeoLiteCity.dat.gz
Done
Uncompressing gzip file ... Done
Performing sanity checks ... Database type is 1
database_info  FAIL null
Received Error -21 (Sanity check database_info string failed) when attempting to update GeoIP Database


 インストール: GeoIP-update 
[root@falcon21 ~]# yum -y install GeoIP-update
インストール:
  GeoIP-update.noarch 0:1.5.0-13.el7
 
完了しました!
 
Apacheモジュール設定 [root@falcon21 ~]# vi /etc/httpd/conf.d/geoip.conf
<IfModule mod_geoip.c>
  GeoIPEnable On
  GeoIPScanProxyHeaders On
  GeoIPDBFile /usr/share/GeoIP/GeoIP.dat
  GeoIPDBFile /usr/share/GeoIP/GeoIP.dat MemoryCache
  GeoIPDBFile /usr/share/GeoIP/GeoIP.dat CheckCache
</IfModule>
LogFormat "%a [%h] %u %t %D \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"   GeoIP_Address=\"%{GEOIP_ADDR}e\" Country_Code=\"%{GEOIP_COUNTRY_CODE}e\" Country_Name=\"%{GEOIP_COUNTRY_NAME}e\"" combined
~
国別制限設定 #日本のみのアクセス許可 [root@falcon21 ~]# vi /etc/httpd/conf.d/vhost.conf <Location "/"> Order Deny,Allow SetEnvIf GEOIP_COUNTRY_CODE JP BlockCountry Allow from env=BlockCountry </Location>
投票数:0 平均点:0.00

 
Back to Top