wiki:BlockingBittorrent

Preventing (almost all) Bittorrent Activity on an Exit Node

DO NOT ACTUALLY USE THIS. IT HURTS THE TOR NETWORK. Use the Reduced Exit Policy instead if you want to reduce Bittorrent traffic exiting at your relay (or, even better, live with the DMCA complaints). See https://lists.torproject.org/pipermail/tor-relays/2013-April/002047.html for a discussion about this topic.

For anyone who runs a Tor exit node on a Linux machine, the following one-liner blocks via IPTables all* Trackers:

for j in `for a in $(wget -qO- http://www.trackon.org/api/all | awk -F/ ' { print $3 }' ); do dig +short a $a; done |grep -v [a-z]|sort|uniq`; do iptables -I OUTPUT -d $j -j DROP; done

If you do not have any custom IPTables rules, you may want to prefix this with

iptables --flush OUTPUT;

and then have the full one-liner within your crontab to run hourly to ensure that your block lists are kept up to date as possible. To do this:

crontab -e

and enter the line:

0 * * * * iptables --flush OUTPUT;for j in `for a in $(wget -qO- http://www.trackon.org/api/all | awk -F/ ' { print $3 }' ); do dig +short a $a; done |grep -v [a-z]|sort|uniq`; do iptables -I OUTPUT -d $j -j DROP; done

and then save it. If vi, (esc):x(enter)

This is a very rough solution to preventing tracker access, certainly for me it has cut down on abuse complaints.

  • As you can imagine, there are always more trackers than there are known ones. The list the code uses gets updated when they are found.
Last modified 4 years ago Last modified on Apr 10, 2013, 9:05:32 PM