How to configure Deluge to only torrent when connected to a VPN?

General support for problems installing or using Deluge
Locked
Limp
New User
New User
Posts: 3
Joined: Mon Aug 29, 2016 9:54 pm

How to configure Deluge to only torrent when connected to a VPN?

Post by Limp »

Basically I want my Deluge config to be foolproof against VPN disconnects. It must not operate when disconnected from my VPN provider. My VPN provider has a built in kill switch in its service management utility for such events, but I'd rather not solely rely on it.

Can I achieve this functionality in Deluge? If so, where should I look for (in presumably Preferences) to enable?

Thanks
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by mhertz »

There are multiple ways e.g. referenced here: http://forum.deluge-torrent.org/viewtop ... =7&t=49883

In the prefs of deluge, you can bind an IP, not an interface. I don't know if it's 100% working by using the IP of your VPN, but in theory it should I believe, but never had a need to verify it as personally using a socks5 proxy instead of VPN(I use ltconfig plugin to enable force_proxy flag of libtorrent which is "killswitch" for proxys). The above link has two methods; one using iptables to restrict, and another using the openvpn UP directive to run a script starting deluge with the binded IP of the VPN and a script in a cron-job run every 5 mins to restart openvn if down.
Limp
New User
New User
Posts: 3
Joined: Mon Aug 29, 2016 9:54 pm

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by Limp »

mhertz wrote:There are multiple ways e.g. referenced here: http://forum.deluge-torrent.org/viewtop ... =7&t=49883

In the prefs of deluge, you can bind an IP, not an interface. I don't know if it's 100% working by using the IP of your VPN, but in theory it should I believe, but never had a need to verify it as personally using a socks5 proxy instead of VPN(I use ltconfig plugin to enable force_proxy flag of libtorrent which is "killswitch" for proxys). The above link has two methods; one using iptables to restrict, and another using the openvpn UP directive to run a script starting deluge with the binded IP of the VPN and a script in a cron-job run every 5 mins to restart openvn if down.
Thank you for your reply. Yeah I've seen that thread, but surely there's a cleaner method to achieve killswitch functionality? I prefer to use a built in option within Deluge, rather than use a script.

Is it correct that in order to achieve what I need, I just need to browse to Preferences > Network, and under the "interface" tab, enter the IP of my VPN provider I'm currently using?

Sorry for asking noob questions. I'm new to Deluge, and new to using a VPN in combination with a torrent application in general.
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by mhertz »

Yes, for strictly killswitch functionality, then binding to VPN IP through deluge prefs should be OK. However, the scripts and iptables are adding functionality of restarting deluge and the VPN when the VPN goes down and you can direct only deluge to use the VPN if wanted and use regular connection for everything else.
Limp
New User
New User
Posts: 3
Joined: Mon Aug 29, 2016 9:54 pm

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by Limp »

mhertz wrote:Yes, for strictly killswitch functionality, then binding to VPN IP through deluge prefs should be OK. However, the scripts and iptables are adding functionality of restarting deluge and the VPN when the VPN goes down and you can direct only deluge to use the VPN if wanted and use regular connection for everything else.
Okay, neat. I'll look into the scripts and iptables as well. Thank you very much.
mhertz
Moderator
Moderator
Posts: 2182
Joined: Wed Jan 22, 2014 5:05 am
Location: Denmark

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by mhertz »

Yes indeed, though it also works fine with e.g. PIA, which the OP uses. I recently gotten PIA also and set it up like described above i,e, only for torrenting and everything else goes through normal connection. I use linux though, where its much easier to setup than windows. I have a script I run which detects the VPN local address and starts torrent client with the IP binded to, so as getting VPN-tunneling+kill-switch behaviour only for the torrent app(I used rtorrent here though, but deluge works too). I'm trying to figure out if I want VPN or socks5 proxy in the feature. Socks5 is slightly faster but you need to trust the torrent-app/backend to not leak your IP. VPN is slightly overkill for torrenting imho(the encryption is only usefull here for throttling, but not all are throttled and the torrent-client can often fix that too with there encryption), but needed if not trusting 100% the socks5 proxying capabilities of the app used and also uses more cpu for the added encryption.

VPN only for torrenting on linux, is just a matter of adding 3 lines or so to your openvpn config-file and adding 2 batch-scripts which is auto-run on VPN up/down and is found online(can be made into a single script easily too) and then lastly a 2 lines script to retrieve vpn local ip and bind torrent-client of choice to it as means of starting your torrent-client.

Also, it's a possibility to use a VM only for torrenting, where you run your torrent-client through a sandboxed environment with only the VPN as connection to outside. Some added overhead indeed, but still a viable solution used by many.

This is also very easy for windows users. Just install e.g. VirtualBox and setup a small VM with OS of choice, and use that for torrenting through your VPN.
Team503
New User
New User
Posts: 4
Joined: Tue Apr 12, 2016 7:58 pm

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by Team503 »

This is also very easy for windows users. Just install e.g. VirtualBox and setup a small VM with OS of choice, and use that for torrenting through your VPN.
Well, unless you want to get to your downloads at some point. If you share the storage from the VM, then it needs a network interface to reach the rest of the network. Similar if you connect to shared storage on the LAN.
Team503
New User
New User
Posts: 4
Joined: Tue Apr 12, 2016 7:58 pm

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by Team503 »

And for a double-bump, is there any progress on binding to an interface instead of an IP? Functionally VERY different and seems like it would be very useful.
shamael
Compulsive Poster
Compulsive Poster
Posts: 667
Joined: Sat Oct 08, 2016 9:28 am

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by shamael »

There are some topics about namespace, creating a virtual interface bind to Deluge. Such way avoid any failback to the real IP out of VPN and remove the iptable change, I never tested them so far.

https://schnouki.net/posts/2014/12/12/o ... -on-linux/
https://gist.github.com/JimboMonkey1234 ... 1c7eef770d

Better solution to my perspective than iptable (idea at least) but yeah, as said not tested.
shamael
Compulsive Poster
Compulsive Poster
Posts: 667
Joined: Sat Oct 08, 2016 9:28 am

Re: How to configure Deluge to only torrent when connected to a VPN?

Post by shamael »

to mention it at least, beside the namespace possibility I mentioned earlier there is a new interesting topic that may be integrated in Linux distribution: https://www.wireguard.com/
It may ease the namespace idea a lot!
Locked