Ubuntu 12.04 下制作 OpenWRT iptables geoip 数据库文件
- 去Xtables-addons下载
xtables-addons-x.x.tar.xz,解压并进入 - 依次执行
./configure
make
make install
- 再进入
xtables-addons-x.x/geoip,执行
./xt_geoip_dl
./xt_geoip_build GeoIPCountryWhois.csv
我这里出现了Can't locate Text/CSV_XS.pm in @INC错误,需要
/usr/bin/perl -MCPAN -e'install Text::CSV_XS'解决
- 最终产物在 LE/BE 目录下,把你需要的放到 OpenWRT 的
/usr/share/xt_geoip/BE(LE)/目录下,如/usr/share/xt_geoip/LE/CN.iv4 - 使用时
iptables -A PREROUTING -t nat -m geoip -p tcp -s 192.168.8.216 ! --destination-country CN -j REDIRECT --to-ports 9999