IP資料庫的自動更新

來源:互聯網
上載者:User

我們這裡介紹幾個免費IP資料庫的更新,對於國外IP資料,我們使用Maxmind的開源項目GeoIP,而國內IP資料我們使用純真的QQWry, 由於QQWry是rara格式的,我們首先在系統安裝unrar
wget http://www.rarlab.com/rar/unrar-3.7.7-centos.gz
gzip -d unrar-3.7.7-centos.gz
mv unrar-3.7.7-centos /usr/local/bin/

編寫以下指令碼用於自動同步IP資料到/usr/local/share目錄下
vi update_ipdata.sh
#!/bin/bash
if [ ! -d /usr/local/share/GeoIP ] ; then
mkdir /usr/local/share/GeoIP
fi
if [ ! -d /usr/local/share/qqIP ] ; then
mkdir /usr/local/share/qqIP
fi
wget -t 5 -O /tmp/GeoIP.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
wget -t 5 -O /tmp/GeoLiteCity.dat.gz http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
wget -t 5 -O /tmp/GeoIPASNum.dat.gz http://geolite.maxmind.com/download/geoip/database/asnum/GeoIPASNum.dat.gz
wget -t 5 -O /tmp/qqwry.rar http://update.cz88.net/soft/qqwry.rar

gzip -df /tmp/GeoIP.dat.gz
gzip -df /tmp/GeoLiteCity.dat.gz
gzip -df /tmp/GeoIPASNum.dat.gz
/usr/local/bin/unrar e -nQQWry.Dat -o+ /tmp/qqwry.rar /tmp/
mv -f /tmp/Geo*.dat /usr/local/share/GeoIP/
mv -f /tmp/QQWry.Dat /usr/local/share/qqIP/

我們在每周三早晨6點20更新一次ip資料庫:
20 6 * * 3 /usr/local/awstats/update-ipdata-cron.sh
最後我們需要確認一下目錄配置, 查看awstats.common.conf,修改以下三行:
LoadPlugin="geoip GEOIP_STANDARD /usr/local/share/GeoIP/GeoIP.dat"
LoadPlugin="geoip_city_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoLiteCity.dat"
LoadPlugin="geoip_org_maxmind GEOIP_STANDARD /usr/local/share/GeoIP/GeoIPASNum.dat"

在awstats/wwwroot/cgi-bin/plugins目錄下修改qqwry.pl,將
my $ipfile=”/QQWry.Dat”;
修改為:
my $ipfile=”/usr/local/share/qqIP/QQWry.Dat”;

以上GeoIP的安裝介紹參考了Antezenta的awstats部落格,純真資料庫格式說明參見LumaQQ的QQWry格式解析,PHP解析QQ格式可以考慮使用QQWry的PHP擴充(C代碼)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.