IP数据库的自动更新

我们这里介绍几个免费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代码)


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值