Log in

View Full Version : How to block torrent peer on Linux (iptables)?



postcd
03-01-2024, 11:05 AM
One IP address is using multiple connections to download single torrent (qBittorrent):
192689

I have multiple connections from one IP enabled (https://www.libtorrent.org/reference-Settings.html#allow_multiple_connections_per_ip), because i want to allow one person to download multiple torrents, assuming that this setting apply on all torrents, not on just one... Setting is recommended to be enabled (As i have it). UPDATE: later i have disabled this and i have not seen single IP doing multiple connections per torrent, but is allowed to download multiple torrents. So that is the desired state IMO.

I wanted to block the IP:port combination, but i doubt it would be effective (but still i wanted to try). I have been unable to find such connection using netstat -a|grep -E "1.2.3.4|4.3.2.1" and various iptables rules applied on WireGuard server/client (INPUT/FORWARD iptables chain, tcp, udp...) does not block it:

sudo iptables -A INPUT -p udp --dport 123 -s 1.2.3.4 -m string --string "uTP" --algo kmp -j DROP
sudo iptables -A INPUT -p udp --sport 123 -s 1.2.3.4 -m string --string "uTP" --algo kmp -j DROP
sudo iptables -A INPUT -p tcp --sport 123 -s 1.2.3.4 -j DROP -m comment --comment "Duplicate torrent peer"
sudo iptables -A INPUT -p udp --sport 123 -s 1.2.3.4 -j DROP -m comment --comment "Duplicate torrent peer"

So my question is how to display connection of that peer IP on Linux and if i can, then how i can block one of the peer connections?