Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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