kfei / docktorrent

:zap: Full-featured BitTorrent box runs in Docker
377 stars 65 forks source link

VPN Support - OpenVPN #36

Open wjbeckett opened 8 years ago

wjbeckett commented 8 years ago

Would love to have VPN support so all torrent traffic was routed via the VPN (OpenVPN for example) however the web interface on port 80 was still accessible via the local interface (non-VPN).

Hirohqv commented 8 years ago

+1 for that

rhazegh commented 8 years ago

+1 for OpenVPN support

rhazegh commented 8 years ago

I thought I'd try installing openvpn in the downloaded container and if it worked, I'd add it to the Dockerfile.

I ran a bash in the docker container:

$ sudo docker exec -it 93210504de5c bash

Then, in the docker container, tried to install openvpn but no luck:

root@93210504de5c:~# apt-get install openvpn
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  easy-rsa liblzo2-2 libpkcs11-helper1 opensc opensc-pkcs11 openssl
Suggested packages:
  ca-certificates resolvconf
The following NEW packages will be installed:
  easy-rsa liblzo2-2 libpkcs11-helper1 opensc opensc-pkcs11 openssl openvpn
0 upgraded, 7 newly installed, 0 to remove and 1 not upgraded.
Need to get 2178 kB of archives.
After this operation, 5789 kB of additional disk space will be used.
Do you want to continue? [Y/n] Y
Get:1 http://httpredir.debian.org/debian/ jessie/main liblzo2-2 amd64 2.08-1.2 [54.6 kB]
Get:2 http://httpredir.debian.org/debian/ jessie/main libpkcs11-helper1 amd64 1.11-2 [45.4 kB]
Get:3 http://httpredir.debian.org/debian/ jessie/main opensc-pkcs11 amd64 0.14.0-2 [687 kB]
Err http://httpredir.debian.org/debian/ jessie/main openssl amd64 1.0.1k-3+deb8u2
  404  Not Found [IP: 207.210.46.249 80]
Get:4 http://httpredir.debian.org/debian/ jessie/main openvpn amd64 2.3.4-5+deb8u1 [477 kB]
Get:5 http://httpredir.debian.org/debian/ jessie/main easy-rsa all 2.2.2-1 [17.1 kB]
Get:6 http://httpredir.debian.org/debian/ jessie/main opensc amd64 0.14.0-2 [219 kB]
Err http://security.debian.org/ jessie/updates/main openssl amd64 1.0.1k-3+deb8u2
  404  Not Found [IP: 149.20.20.19 80]
Fetched 1501 kB in 2s (566 kB/s)
E: Failed to fetch http://security.debian.org/pool/updates/main/o/openssl/openssl_1.0.1k-3+deb8u2_amd64.deb  404  Not Found [IP: 149.20.20.19 80]

E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

Also tried apt-get install openvpn --fix-missing but that failed too.


Update 1 Looks like openvpn was installed despite all those errors.

I had to add --cap-add=NET_ADMIN --device=/dev/net/tun when running the container to add /dev/net/tun which is needed by openvpn.

Then in the command line: $ openvpn --config your_vpn_config.ovpn

And it works like a charm 👍 It just needs to be automated and streamlined in the Dockerfile.

ghost commented 8 years ago

@rhazegh Six weeks on, are you using the above on a regular basis? Any issues?

rhazegh commented 8 years ago

@ribmo I only did some experiments but did not use this for real.

I think if one wants to use VPN for a torrent client, all network connections should be blocked if the VPN is dropped. I am not sure if these settings provide this requirement.