3

I want to block all P2P (including bittorrent) traffic going through my Ubuntu Server. I have tried :

  1. Blocking certain strings, but it's not effective or user friendly
  2. Blocking IPs that resolve to trackers, but it's impossible to keep pace with them so I need a more effective solution

What other options are there?

Oli
  • 299,380
Vitalik Jimbei
  • 379
  • 2
  • 7
  • 19

2 Answers2

-1
iptables -I FORWARD -p tcp -m iprange --src-range 192.168.1.2-192.168.1.100 --dport 1000:65010 -m time --timestart 05:00 --timestop 23:59 --weekdays Mon,Tue,Wed,Thu,Fri,Sat,Sun -j DROP
iptables -I FORWARD -p udp -m iprange --src-range 192.168.1.2-192.168.1.100 --dport 1000:65010 -m time --timestart 05:00 --timestop 23:59 --weekdays Mon,Tue,Wed,Thu,Fri,Sat,Sun -j DROP
-2

Block torrents using iptables

Log Torrent

iptables -N LOGDROP > /dev/null 2> /dev/null
iptables -F LOGDROP
iptables -A LOGDROP -j LOG --log-prefix "LOGDROP "
iptables -A LOGDROP -j DROP

Block Torrent

iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string "peer_id=" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string ".torrent" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string "torrent" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string "announce" -j LOGDROP
iptables -A FORWARD -m string --algo bm --string "info_hash" -j LOGDROP

Block DHT keyword

iptables -A FORWARD -m string --string "get_peers" --algo bm -j LOGDROP
iptables -A FORWARD -m string --string "announce_peer" --algo bm -j LOGDROP
iptables -A FORWARD -m string --string "find_node" --algo bm -j LOGDROP

References

How to Block BitTorrent traffic on your Linux firewall

How to Block Bittorrent Traffic with IPtables