Transmission torrent client through VPN

Sorry, what I said earlier wasn’t 100%. For some odd reason, Transmission used other ports as well as the one I specified to make the transfers. So the traffic was split between the tunnel and eth0.

I now settled on a solution that finally seems like redirects all traffic from Transmission to the tunnel.

First, here is my OpenVPN configurations:

config openvpn 'torrentVPN'                                                                                                             
        option dev 'tun1'                                                                                                          
        option nobind '1'                                                                                                          
        option verb '3'                                                                                                            
        option engine 'cryptodev'                                                                                                  
        option tun_mtu '1500'                                                                                                      
        option keepalive '10 60'                                                                                                   
        option persist_key '1'                                                                                                     
        option client '1'                                                                                                          
        option proto 'udp'                                                                                                         
        option resolv_retry 'infinite'                                                                                             
        option tls_client '1'                                                                                                      
        option auth_nocache '1'                                                                                                    
        option route_metric '50'                                                                                                   
        option cipher 'AES-256-CBC'                                                                                                
        option port '1194'                                                                                                         
        option persist_tun '1'                                                                                                     
        option auth_user_pass '/etc/openvpn/windscribeuserpass'                                                                    
        list remote 'uk-008.windscribe.com'                                                                                        
        option auth 'SHA512'                                                                                                       
        option ca '/etc/luci-uploads/windscribe_4096.crt'                                                                          
        option remote_cert_tls 'server'                                                                                            
        option key_direction '1'                                                                                                   
        option tls_auth '/etc/luci-uploads/windscribe_4096.key'                                                                    
        option reneg_sec '432000'                                                                                                  
        option enabled '1'                                                                                                         
        option route_noexec '1'                                                                                                    
        option compress 'lzo'                                                                                                      
        option route_delay '5'                                                                                                     
        option script_security '2'                                                                                                 
        option route_up '/etc/openvpn/updatebindaddress'

With these configurations, /etc/openvpn/updatebindaddress updates the bind_ipv4_address for transmission to be in the range of the VPN local subnet.

Here is the content of the updatebindaddress script (adapted from the post linked by @vgaetera, which won’t work for Openwrt because of the different strings used in the configuration files):

#!/bin/sh                                                                                                                          
                                                                                                                                   
/etc/init.d/transmission stop                                                                                                      
                                                                                                                                   
VPNADDR=`ifconfig | grep -A 5 "tun1" | grep "inet addr:" | cut -d: -f2 | awk '{ print $1}'`                                        
if [ -z "$VPNADDR" ]; then                                                                                                         
        VPNADDR=127.0.0.1                                                                                                          
fi                                                                                                                                 
                                                                                                                                   
cat /etc/config/transmission | sed "s/.*bind_address_ipv4.*/ \toption bind_address_ipv4 \'$VPNADDR\' /g" > /etc/config/transmission
                                                                                                                                   
chmod 666 /etc/config/transmission_test                                                                                            
                                                                                                                                   
mv /etc/config/transmission_test /etc/config/transmission                                                                          
                                                                                                                                   
/etc/init.d/transmission start 

If you’re going to use the script above, make sure to change tun1 to whatever the name of your tunnel interface.

Now the issue that I was having, was that the version of OBPR I was running didn’t create any UDP port rules (even when appropriate settings were selected, i.e. UDP support in advanced configurations section).

So with the latest OBPR, here is the rule that worked:

config policy                                                                                                                      
        option comment 'P2P'                                                                                                       
        option interface 'torrentVPN'                                                                                                   
        option proto 'tcp udp'                                                                                                     
        option local_address '10.0.0.0/8'                                                                                          
        option local_port '1-65535'                                                                                                
        option chain 'OUTPUT'  

So traffic originating from the router, with address range 10.0.0.0/8, will go through the tunnel. Checking the realtime graphs section shows a 1:1 image of the speed I see in transmission.

Hope this helps! This issue is solved now, so if there is any way to mark this thread as solved, let me know :slightly_smiling_face:

As always, many many thanks to @stangri for the amazing OPBR package!

6 Likes