qbittorrent / qBittorrent

qBittorrent BitTorrent client
https://www.qbittorrent.org
Other
28.21k stars 3.97k forks source link

Manually Assign Source Port Range For qBittorrent As A Whole #6728

Open datdamnmachine opened 7 years ago

datdamnmachine commented 7 years ago

Please provide the following information

qBittorrent version and Operating System:

3.3.12 Windows 10 Enterprise 1607 x64

If on linux, libtorrent and Qt version:

What is the problem:

Inabilility to properly traffic shape ALL qBittorrent communications such as tracker annoucements.

What is the expected behavior:

Steps to reproduce:

Test your torrent IP address with these links:

http://ipmagnet.services.cbcdn.com

https://www.doileak.com/?cb=xpmdt95sp0wyoae4

You will see announcements and other types of traffic use ephemeral ports provided by the OS instead of the Outgoing Ports configuration in the advanced options of qbittorent. You can also use this command to see those ports while running the test:

netstat -nabo > c:\netstat.txt

Extra info(if any):

This would help greatly for traffic shapping ALL qbittorent activities. For example, I want to shape torrent traffic to utilize a another ISP connection other than the primary or a VPN connection. Without this, you can shape the outgoing ports and your incoming server port but announcements, due to the dynamic ports being used, will go out the normal ISP connection or non-VPN interface. Because of this, you are announcing the incorrect address to other peers which can reduce the performance of your downloads and uploads.

birdie-github commented 7 years ago

Tools -> Options -> Advanced -> Network Interface/Optional IP address to bind to

datdamnmachine commented 7 years ago

Interesting idea. The only problem I see with that solution is that other programs would bind to that address as well. This would negate being able to traffic shape just qBittorrent as it would mean other traffic would be caught in the traffic shaping as well.

What I'm using now is I have firewall rules set up to match the bittorrent server port as a source port outbound, the outgoing port ranges as a source port, and, finally, all the trackers I'm using as destination addresses. It's a tad bit clunky but it doing it except for connections to one address are getting flagged.

Edit: I found this article:

https://blogs.technet.microsoft.com/rmilne/2012/02/08/fine-grained-control-when-registering-multiple-ip-addresses-on-a-network-card/

Essentially, you use the below command to ensure that the address isn't registered in DNS and that no applications can bind to it unless they specifically request binding to that address. It looks like this:

netsh int ipv4 add address “Local Area Connection” 192.168.1.2 255.255.255.0 skipassource=true

I ran "netstat -anob" to see if any processes had binded to this (I even closed and re-opened Outlook) and, so far, only qBittorrent is using the address.

It appears that this is working, exactly the same, as the firewall rules I had previously. As such, I did some digging about the one address that was getting flagged and not traffic shapped that I may have to submit a separate issue on.

datdamnmachine commented 7 years ago

Regarding this, see the updates in the issue referenced above:

sledgehammer999 Just to be clear we spoof the user agent when we do non-bittorrent related stuff (eg fetching rss, search results, update version). The activity you see is that qbt tries to download the favicon for that particular tracker to display it in the sidepanel. It doesn't always work. And I guess sometimes dodgy trackers sent back malicious files when you request a favicon. Your best bet is to either delete that tracker or disable favicon download in the advanced settings.

So, this explains why bittorrent traffic is being traffic shaped but non-bittorrent traffic is not.

I still think this is a valid improvement or, even better, the ability to bind qBittorrent as a whole, or its seperate parts (app and bittorrent) to seperate or the same IP address. This would make traffic shaping even easier.

kathampy commented 6 years ago

I need this for traffic shaping too. Please allow all outbound connections to use a specified source / ephemeral port.