커널에 ipt_iprange 모듈이 있어야 함
#!/bin/csh
if ($#argv < 1) then
echo "usage : ./ip CN or China";
exit
endif
wget -O IP.zip http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
unzip IP.zip
cat GeoIPCountryWhois.csv | grep $argv[1] > iplist
cat iplist | perl -pi -e 's/,/ /g' | perl -pi -e 's/"/ /g' | awk '{ print "iptables -A INPUT -m iprange --src-range "$1 "-" $2 " -j DROP "}' > run
위 스크립트 실행후 ./run
한국 아이피만 허용하고 모두 막으려면 DROP 부분을 ACCEPT로 수정한 후
iptables -A INPUT -s 0/0 -p tcp -m tcp --dport 80 -j DROP
iptables -A INPUT -s 0/0 -p udp --dport 80 -j DROP
iptables -A INPUT -s 0/0 -p udp --dport 80 -j DROP
이 두줄을 run 에 추가.
[출처 - PHPSCHOOL]
댓글 없음:
댓글 쓰기