Reply to topic

Ktorrent won't respect specified network interface

fandingo
Registered Member
Posts
2
Karma
0
OS
I have two ISPs because one comes at basically no cost to me. I would like to route torrents over that ISP since it negatively impacts online gaming on my main ISP.

I have set ktorrent to use wlan0, my second ISP. However, examining traffic with wireshark shows that all of the traffic is going to eth2, my primary ISP. There's literally no traffic going over wlan0.

I have no problems accessing the wlan0 network. I can communicate with all of the computers on it.

Could it have something to do with my routes?
Code: Select all
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.0.0        *               255.255.255.224 U     0      0        0 br0
192.168.1.0     *               255.255.255.0   U     2      0        0 wlan0
192.168.122.0   *               255.255.255.0   U     0      0        0 virbr0
68.184.192.0    *               255.255.240.0   U     1      0        0 eth2
default         68-184-192-1.dh 0.0.0.0         UG    0      0        0 eth2


How can I get ktorrent to work over wlan0?

Thanks a lot.
netcelli
Registered Member
Posts
44
Karma
0
OS
You said you set wlan0 interface in Network page of setting dialog right?
George
Moderator
Posts
5421
Karma
1
Setting the network interface, only tells ktorrent on which IP address it should bind. It does not have anything to do with routing, which is controlled by the routing table of the operating system.
pmendl
Registered Member
Posts
7
Karma
0
Reopening this topic with more specific question.

I have exactly the same need, different routing for torrents then rest of the traffic.

I am able to configure routing based on my IP derived from the virtual interface. I use this method in several other applications without problem.

So I set eth0 (default) for "normal" traffic and set new eth0:2 (eth0:1 is in use for other apps) intended for torrents. Verified IP addresses and routing tables for all interfaces, all seems fine.

Still, even after ktorrent restart (quit and start again), I see just eth0 and eth1 (besides lo and others, off course) in the interface pulldown in Settings->Configure->Network. No eth0:1, eth0:2 ... no eth1:1, eth1:2...

Am I doing something wrong, is it principal problem or should I fill wishlist request (or try to make patch myself - any recommendation and references to proper part of source code welcome then).

My distro:
Debian squeeze
Linux 2.6.32-5-amd64 #1 SMP Wed Jan 12 03:40:32 UTC 2011 x86_64 GNU/Linux


pmendl, proud to be a member of KDE forums since 2008-Nov.
George
Moderator
Posts
5421
Karma
1
KDE's solid library is used to get a list of all network interfaces, so if it isn't in that list, then solid does not support virtual interfaces.
imported4-John
Registered Member
Posts
4
Karma
0
Sticking this here as it's related to getting KT to not run on undesired interfaces.

KT does seem to eventually 'rollover' to whatever interface it can find, even when an interface is set in config.

KT probably needs a checkbox or something to "Only use interface XXXX" And there would have to be a text box to allow us to specify the interface, as it may not currently be up.

Code: Select all
#!/bin/sh

####
# KTorrent 'helper' script
#
#  Reason:
#   With ~2K torrents, KT crashes alot
#   Want KT to only run when tunnel is up
#
#  Does:
#   Starts and stops KT based on if ppp0 is up
#   Turns off KDE crash handler
#   Captures / Eliminates crashes from old C++ error
#     See thread:  http://ubuntuforums.org/showthread.php?t=175050
#   Restarts KT if crashed
#
#   Additionally:
#     You can add the below to your .profile to disable coredumps (supposedly)
#       "limit coredumpsize 0"
#     For Gnome:  also remove package "bug buddy"
#
#  To Do:
#     Add "/etc/sysconfig/network-scripts/ifdown-eth eth0" type network control
#
####

## Leave these here (or add to your .bashrc)
# stops "*** glibc detected *** double free or corruption" crashes
   export MALLOC_CHECK_=0
# stops KDE crash handler
   export KDE_DEBUG=1

while [ 1 ]
do
   date
   TEST=`/sbin/ifconfig | grep ppp0 | awk '{print $1}'`
   if [ $TEST ]; then
      echo "Found ppp0, Starting Ktorrent              Found ppp0"
      TEST2=`ps -A | grep ktorrent | awk '{print $1}'`
      if [ $TEST2 ]; then
         echo "Found Ktorrent running                     Already Running"
      else
         echo "No Ktorrent                                Starting"
         ktorrent
#         use below to suppress all messages from KT
#         ktorrent  > /dev/null 2>&1
      fi
   else
      echo "No ppp0, Stopping Ktorrent                 Stopping"
      killall ktorrent
   fi
   date
   echo "######## end ##############"
   sleep 10m
done

imported4-Sam
Registered Member
Posts
22
Karma
0
John wrote:Sticking this here as it's related to getting KT to not run on undesired interfaces.

KT does seem to eventually 'rollover' to whatever interface it can find, even when an interface is set in config.

KT probably needs a checkbox or something to "Only use interface XXXX" And there would have to be a text box to allow us to specify the interface, as it may not currently be up.



A better version is now at viewtopic.php?f=2&t=4163

I was John, now I'm Sam
User avatar latebeat
Registered Member
Posts
70
Karma
0
Hi all,
I'm posting in this one trying to reopen the subject as I'm noticing that ktorrent still doesn't respect the specified network interface.
So I have 2 connections with 2 different gateways. One is eth0 10.0.0.8 and the other is wlan0 192.168.1.12
I want to limit the non important traffic to the wlan0 interface.
I've setup policy routing and I've chosen the option to bind ktorrent to wlan0 from the settings>network menu.

I wanted to check my established connections so I did:
Code: Select all
#netstat -np | grep ktorr | grep ESTA
...
tcp        0   2698 10.0.0.8:42727          111.184.33.190:27721    ESTABLISHED 12339/ktorrent 
tcp        0      0 192.168.1.12:19908      218.81.225.86:38816     ESTABLISHED 12339/ktorrent 
tcp        0     82 192.168.1.12:19908      190.186.158.178:56410   ESTABLISHED 12339/ktorrent 
tcp        0   3205 10.0.0.8:45998          78.175.187.181:58328    ESTABLISHED 12339/ktorrent 
tcp        0      0 192.168.1.12:19908      80.39.214.7:20054       ESTABLISHED 12339/ktorrent 
tcp        0    259 192.168.1.12:19908      125.212.44.197:50274    ESTABLISHED 12339/ktorrent 
tcp        0      0 192.168.1.12:19908      218.61.24.67:14446      ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:33589          83.93.196.86:54700      ESTABLISHED 12339/ktorrent 
tcp        0      0 192.168.1.12:19908      113.225.123.8:56395     ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:34908          2.137.225.125:6714      ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:43835          41.233.150.47:32758     ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:35754          2.90.117.84:47355       ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:44798          188.251.115.204:42831   ESTABLISHED 12339/ktorrent 
tcp        0      0 192.168.1.12:19908      83.33.72.34:18311       ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:41332          81.62.208.211:56199     ESTABLISHED 12339/ktorrent 
tcp        0      0 10.0.0.8:32963          173.248.230.116:37816   ESTABLISHED 12339/ktorrent 
....


As you can see, ktorrent is not binding all connections exclusively to wlan0 (192.168.1.12). A lot of them (about 50%) are still bound to the system default interface (10.0.0.8 ip) even though I've selected the appropriate option from the settings.

I have also installed Vuse jut to check if it was doing the same and I can confirm that it is not the case.
Vuse is binding all the connections to wlan0 and nothing was "leaking" to eth0

any thoughts?
George
Moderator
Posts
5421
Karma
1
We only bind for incoming connections, outgoing ones aren't bound at all, the kernel chooses the port and interface, but that shouldn't really matter.
AFAIK the kernel routes the packets based on it's routing tables, bound interface shouldn't matter in the routing decision.
User avatar latebeat
Registered Member
Posts
70
Karma
0
George wrote:We only bind for incoming connections, outgoing ones aren't bound at all, the kernel chooses the port and interface, but that shouldn't really matter.
AFAIK the kernel routes the packets based on it's routing tables, bound interface shouldn't matter in the routing decision.


Why are you not binding outgoing ones? These are the ones that needed to be bound the most. Plus ktorrent is the only client that supports binding to an interface that does this. I've tested qbittorent and Vuse and they both work fine .. i.e. binding ONLY to the specified interface.

Assume you have a Linux system with more than one network interface card — say eth0 and eth1. By default, you can define a single, default route (on eth0). However, if you receive traffic (i.e., ICMP pings) on eth1, the return traffic will go out eth0 by default.
This can be a bit of a problem — especially when the two NICs share the same parent network and you’re trying to preserve sane traffic flows. In a nutshell, you need to ensure traffic going into eth0 goes out only on eth0, as well as enforce all traffic going into eth1 goes out only on eth1.

that's what policy routing is! If I'm binding ktorrent to eth1, I'm doing so because I want all my connections in and out going to that interface. Ktorrent binding only incoming connections doesn't help at all. In fact it complicates things even more.

 
Reply to topic

Bookmarks



Who is online

Registered users: alake, Alexa [Bot], Baidu [Spider], Bing [Bot], bobo01, einar, Exabot [Bot], Google [Bot], Hei Ku, joshaughnessy, Marand, mgraesslin, nezumi, orbmiser, TheraHedwig, Yahoo [Bot]