MarkusMcNugen / docker-qBittorrentvpn

Docker container which runs a headless qBittorrent client with WebUI and optional OpenVPN
https://hub.docker.com/r/markusmcnugen/qbittorrentvpn/
GNU General Public License v3.0
168 stars 92 forks source link

Can't get VPN to work #110

Open tessierp opened 2 years ago

tessierp commented 2 years ago

Hi,

No matter what I try, I can't get VPN to work because of this error : Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2). My VPN provider is PIA.... I also logged into the container and indeed the folder /dev/net/tun is missing.

There is also an error regarding OPENVPN Route 6. How can that be fixed?

2021-11-21 15:07:13.649400 [info] VPN_ENABLED defined as 'yes' 2021-11-21 15:07:13.670080 [info] OpenVPN config file (ovpn extension) is located at /config/openvpn/ca_montreal.ovpn dos2unix: converting file /config/openvpn/ca_montreal.ovpn to Unix format... 2021-11-21 15:07:13.692996 [info] VPN remote line defined as 'ca-montreal.privacy.network 1198' 2021-11-21 15:07:13.712423 [info] VPN_REMOTE defined as 'ca-montreal.privacy.network' 2021-11-21 15:07:13.732956 [info] VPN_PORT defined as '1198' 2021-11-21 15:07:13.755162 [info] VPN_PROTOCOL defined as 'udp' 2021-11-21 15:07:13.770586 [info] VPN_DEVICE_TYPE defined as 'tun0' 2021-11-21 15:07:13.786043 [info] LAN_NETWORK defined as '192.168.20.0/23' 2021-11-21 15:07:13.801557 [info] NAME_SERVERS defined as '"8.8.8.8,8.8.4.4"' 2021-11-21 15:07:13.816135 [info] VPN_OPTIONS not defined (via -e VPN_OPTIONS) 2021-11-21 15:07:13.832923 [info] Adding "8.8.8.8 to resolv.conf 2021-11-21 15:07:13.847542 [info] Adding 8.8.4.4" to resolv.conf 2021-11-21 15:07:13.861108 [info] Starting OpenVPN... Sun Nov 21 15:07:13 2021 WARNING: file 'credentials.conf' is group or others accessible Sun Nov 21 15:07:13 2021 OpenVPN 2.4.7 x86_64-pc-linux-gnu [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Jul 19 2021 Sun Nov 21 15:07:13 2021 library versions: OpenSSL 1.1.1f 31 Mar 2020, LZO 2.10 Sun Nov 21 15:07:13 2021 TCP/UDP: Preserving recently used remote address: [AF_INET]199.36.223.251:1198 Sun Nov 21 15:07:13 2021 UDP link local: (not bound) Sun Nov 21 15:07:13 2021 UDP link remote: [AF_INET]199.36.223.251:1198 Sun Nov 21 15:07:13 2021 WARNING: this configuration may cache passwords in memory -- use the auth-nocache option to prevent this Sun Nov 21 15:07:13 2021 [montreal410] Peer Connection Initiated with [AF_INET]199.36.223.251:1198 Sun Nov 21 15:07:15 2021 OpenVPN ROUTE6: OpenVPN needs a gateway parameter for a --route-ipv6 option and no default was specified by either --route-ipv6-gateway or --ifconfig-ipv6 s Sun Nov 21 15:07:15 2021 OpenVPN ROUTE: failed to parse/resolve route for host/network: 2000::/3 Sun Nov 21 15:07:15 2021 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2) Sun Nov 21 15:07:15 2021 Exiting due to fatal error

kamiTT commented 2 years ago

Having the same issue with Mullvad

kamiTT commented 2 years ago

@tessierp #53 Has some information that helped me.

tessierp commented 2 years ago

@kamiTT From the post, it seems the way to fix this is by setting the PUID and PGID to 0 (root) to gain access to /dev/net/tun and giving "High privileges" access from the UI (I presume they meant through portainer)...

I can't say I like this. Sometimes you have to give root access but... I'll try it.

tessierp commented 2 years ago

Just doesn't work for me... Same issue even if I use root :

Wed Nov 24 14:11:38 2021 OpenVPN ROUTE: failed to parse/resolve route for host/network: 2000::/3

Wed Nov 24 14:11:38 2021 ERROR: Cannot open TUN/TAP dev /dev/net/tun: No such file or directory (errno=2)

Wed Nov 24 14:11:38 2021 Exiting due to fatal error

tessierp commented 2 years ago

Also, my issue is I am using docker swarm so privileged and device and all these options wont work for me..

rubenandre commented 2 years ago

adding this to my docker-compose file solved the problem:

    cap_add: 
      - NET_ADMIN
    devices:
      - /dev/net/tun
tessierp commented 2 years ago

@rubenandre

adding this to my docker-compose file solved the problem:

    cap_add: 
      - NET_ADMIN
    devices:
      - /dev/net/tun

That worked. Fixes the device net tun issue. Still can't reach the service on port 6080 and I did configure it correctly I think

environment:
  - OPENVPN_PROVIDER=PIA
  - OPENVPN_CONFIG=xxxxxxxx
  - PGID=1000
  - PUID=1000
  - OPENVPN_USERNAME=xxxxxxxxx
  - OPENVPN_PASSWORD=xxxxxxxxx
  - LAN=192.168.20.0/23
  - QBT_WEBUI_PORT=6080
ports:
  - 6080:6080

Everything works except it seems impossible to use the ports... So strange.

shaunvis commented 2 years ago

I didn't change PGID or anything, just gave docker "High Privilege" and seemed to work

weirlive commented 2 years ago
 cap_add: 
  - NET_ADMIN
devices:
  - /dev/net/tun

This worked for me, thanks!!