diff options
-rwxr-xr-x | torblock.sh | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/torblock.sh b/torblock.sh new file mode 100755 index 0000000..5638a80 --- /dev/null +++ b/torblock.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +set -e + +get_ips() { + curl -sSL "https://check.torproject.org/cgi-bin/TorBulkExitList.py?ip=$(curl icanhazip.com)" | sed '/^#/d' | grep -Eo "([0-9]{1,3}[\.]){3}[0-9]{1,3}" +} + +ipset flush tor || true +ipset create -exist tor iphash + +get_ips | sed 's#^#add tor #' | ipset restore + +iptables -I INPUT -m set --match-set tor src -j REJECT --reject-with icmp-admin-prohibited |