Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save wen-long/b4d5622c09e9be542660 to your computer and use it in GitHub Desktop.
Save wen-long/b4d5622c09e9be542660 to your computer and use it in GitHub Desktop.

Ubuntu 12.04 下制作 OpenWRT iptables geoip 数据库文件

  1. Xtables-addons下载xtables-addons-x.x.tar.xz,解压并进入
  2. 依次执行
./configure
make
make install
  1. 再进入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'解决

  1. 最终产物在 LE/BE 目录下,把你需要的放到 OpenWRT 的/usr/share/xt_geoip/BE(LE)/目录下,如/usr/share/xt_geoip/LE/CN.iv4
  2. 使用时

iptables -A PREROUTING -t nat -m geoip -p tcp -s 192.168.8.216 ! --destination-country CN -j REDIRECT --to-ports 9999

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment