Created
February 10, 2012 12:07
-
-
Save irr/1789100 to your computer and use it in GitHub Desktop.
iptables country-block2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
###PUT HERE COMA SEPARATED LIST OF COUNTRY CODE### | |
COUNTRIES="AK,AR" | |
WORKDIR="/root" | |
####################################### | |
cd $WORKDIR | |
wget -c --output-document=iptables-blocklist.txt http://blogama.org/country_query.php?country=$COUNTRIES | |
if [ -f iptables-blocklist.txt ]; then | |
iptables -F | |
BLOCKDB="iptables-blocklist.txt" | |
IPS=$(grep -Ev "^#" $BLOCKDB) | |
for i in $IPS | |
do | |
iptables -A INPUT -s $i -j DROP | |
iptables -A OUTPUT -d $i -j DROP | |
done | |
fi | |
rm $WORKDIR/iptables-blocklist.txt |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment