Skip to content

Instantly share code, notes, and snippets.

@random-robbie
Last active November 29, 2016 20:09
Show Gist options
  • Save random-robbie/676d317246a49d46c8cd87f1db3490c7 to your computer and use it in GitHub Desktop.
Save random-robbie/676d317246a49d46c8cd87f1db3490c7 to your computer and use it in GitHub Desktop.
Block Russia via iptables
#!/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