Skip to content

Instantly share code, notes, and snippets.

@ansmirnov
Created June 6, 2015 11:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ansmirnov/70bdd04598191d893be0 to your computer and use it in GitHub Desktop.
Save ansmirnov/70bdd04598191d893be0 to your computer and use it in GitHub Desktop.
iptables: Блокировка входящего TOR-трафика
#!/bin/bash
# Block Tor Exit nodes
IPTABLES_TARGET="DROP"
IPTABLES_CHAINNAME="TOR"
EXTERNAL_IP="xx.xx.xx.xx"
if ! iptables -L TOR -n >/dev/null 2>&1 ; then
/sbin/iptables -N TOR >/dev/null 2>&1
/sbin/iptables -A INPUT -p tcp -j TOR 2>&1
fi
/sbin/iptables -F TOR
/usr/bin/curl "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=${EXTERNAL_IP}" 2> /dev/null | /bin/grep -v '#' | /usr/bin/sort | /usr/bin/uniq |
while read IP
do
let COUNT=COUNT+1
/sbin/iptables -A TOR -s $IP -j DROP
done
/sbin/iptables -A TOR -j RETURN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment