Last active
November 29, 2016 20:09
-
-
Save random-robbie/676d317246a49d46c8cd87f1db3490c7 to your computer and use it in GitHub Desktop.
Block Russia via iptables
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 | |
WORKDIR="/root" | |
####################################### | |
cd $WORKDIR | |
wget --no-check-certificate -c --output-document=iptables-blocklist.txt https://gist.githubusercontent.com/txt3rob/c122b29639c2507079e0ed2a797c75da/raw/russia.txt | |
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