Help create firewall rules to detect BT connections.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
.gitignore
LICENSE
README.md
trackers.py

README.md

BitTorrent Tracker Firewall Helper

Chinese (中文)

It's known that detecting BT traffic itself is difficult. However, in most of time, BT client will connect to some tracker servers during running. This kind of connections can be detected easily by a few of firewall rules.

This program try to simplify the process of configuring firewalls to detect connections with BT tracker servers by providing the following two functions:

  • Reading tracker server addresses from a set of torrents.
  • Resolve server name, and generate firewall rules.

Example

Collect tracker servers from torrent files, then add them to ipset blacklist:

$ ./trackers.py torrent *.torrent > trackers.txt
$ ./trackers.py ipset blacklist trackers.txt > ipset-rules
# ipset restore -file ipset.rules

Or by one line:

# ./trackers.py torrent *.torrent | ./trackers.py ipset blacklist - | ipset restore

You may use iptables to match this ipset, and do filter, logging or something.

Generating iptables commands directly is also supported by ./trackers.py iptables command. If you want more custom, try ./trackers.py raw, which print address, protocol and port number without any other addition information.