Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- IPT=/sbin/iptables
- ISO="cn af al eg kp lb ly ma ng ne sa so sn sd sy tn ug ae ye zm zw"
- #Short list for testing purposes.
- #ISO="af al"
- if [ -d /root/iptables_zones ]
- then echo "dir exists" && pwd
- else
- echo "dir doesn't exist, creating... "
- mkdir /root/iptables_zones && pwd
- fi
- cd /root/iptables_zones/ && ls -lAh
- #optional - download all aggregated blocklists:
- #wget -r -nd -A *.zone http://www.ipdeny.com/ipblocks/data/aggregated/
- #ls -lAh
- echo "Clearing current iptables rules!"
- $IPT -F
- $IPT -X
- $IPT -P INPUT ACCEPT
- $IPT -P OUTPUT ACCEPT
- $IPT -P FORWARD ACCEPT
- for zf in $ISO
- do
- echo "Testing for $zf-aggregated.zone"
- if [ -f $zf-aggregated.zone ] ; then
- echo -e "\t$zf-aggregated.zone exists, skipping... "
- else
- echo -e "\t$zf-aggregated.zone missing, downloading... "
- wget -nd http://www.ipdeny.com/ipblocks/data/aggregated/$zf-aggregated.zone
- fi
- echo -e "Done. \nCreating new rules.\nThis will take a while..."
- for i in $(cat $zf-aggregated.zone)
- do
- $IPT -A INPUT -s $i -j LOG --log-prefix "IP ZONE BLOCK $zf: "
- $IPT -A INPUT -s $i -j DROP
- done
- echo -e "\tNew block rules for $zf created."
- done
- echo 'Rules created for: '\"$ISO\""."
RAW Paste Data