Advertisement
vartik

geoipblock.sh

Dec 5th, 2016
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.40 KB | None | 0 0
  1. #!/bin/sh
  2. [ -z "$1" ] && echo "Usage: $0 <country_code> [<target (default: ACCEPT)>]" && exit
  3. target=ACCEPT
  4. [ -z "$2" ] || target=$2
  5. ( echo "*filter"
  6. GET "http://ipdeny.com/ipblocks/data/aggregated/$1-aggregated.zone" | while read i ; do
  7.     echo "-I INPUT 1 -s $i -j $target"
  8. done
  9. echo "COMMIT" ) | iptables-restore
  10. # Monitor with: iptables -vnL | egrep -A 1 "INPUT|ACCEPT.*\*" | grep -v "^    0     0"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement