Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: ProtonVPN Port Forwarding #1488

Closed
tazz4843 opened this issue Mar 28, 2023 · 109 comments · Fixed by #1543
Closed

Feature request: ProtonVPN Port Forwarding #1488

tazz4843 opened this issue Mar 28, 2023 · 109 comments · Fixed by #1543

Comments

@tazz4843
Copy link

What's the feature 🧐

The current method of port forwarding appears to be unsupported by gluetun. ProtonVPN has a guide on their site to set up port forwarding: https://protonvpn.com/support/port-forwarding-manual-setup/. This requires the binary natpmpc which currently does not exist in the container image.

Extra information and references

No response

@BraveLilToaster
Copy link

I fell down a rabbit hole looking for a solution and stumbled onto this repo. I just tested it and it seems to work.

config example:

version: "3"
services:
  gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    network_mode: bridge
    ports:
      - 8888:8888/tcp # HTTP proxy
      - 8388:8388/tcp # Shadowsocks
      - 8388:8388/udp # Shadowsocks
      - 8000:8000/tcp # Built-in HTTP control server
        # other containers ports
      - 6881:6881     # qBittorrent
      - 6881:6881/udp # qBittorrent
      - 8080:8080     # qBittorrent
    environment:
      - VPN_SERVICE_PROVIDER=custom
      - VPN_TYPE=wireguard
      - VPN_ENDPOINT_IP=${VPN_ENDPOINT_IP}
      - VPN_ENDPOINT_PORT=${VPN_ENDPOINT_PORT}
      - WIREGUARD_PUBLIC_KEY=${WIREGUARD_PUBLIC_KEY}
      - WIREGUARD_PRIVATE_KEY=${WIREGUARD_PRIVATE_KEY}
      # - WIREGUARD_PRESHARED_KEY={WIREGUARD_PRESHARED_KEY}
      - WIREGUARD_ADDRESSES=${WIREGUARD_ADDRESSES}
      - VPN_DNS_ADDRESS=${VPN_DNS_ADDRESS}
      # - FIREWALL_OUTBOUND_SUBNETS=192.168.178.0/24
    restart: unless-stopped

  qbittorrent:
    container_name: qbittorrent
    image: lscr.io/linuxserver/qbittorrent:latest
    environment:
      - PUID=1000
      - PGID=1000
      - UMASK=002
      - TZ=${SERVARR_TIMEZONE}
      - WEBUI_PORT=8080
    network_mode: "service:gluetun"
    volumes:
      - /docker/appdata/qbittorrent:/config
      - /data:/downloads
    restart: unless-stopped

  qbittorrent_natmap:
    container_name: qbittorrent_natmap
    image: ghcr.io/soxfor/qbittorrent-natmap:latest
    environment:
      - QBITTORRENT_SERVER=10.2.0.2 
      - VPN_GATEWAY=10.2.0.1
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    network_mode: "service:gluetun"
    depends_on:
      gluetun:
        condition: service_healthy
      qbittorrent: 
        condition: service_started
    restart: unless-stopped

@tazz4843
Copy link
Author

I did stumble upon that repo before opening this issue, but given I'm using Deluge, that wasn't really an option for me.

@qdm12
Copy link
Owner

qdm12 commented Apr 4, 2023

I'm working on a custom implementation of the natpmp protocol in Go, I'll comment back once I have a test image to try it with (2-3 days from my guesstimate)

@pvanryn
Copy link

pvanryn commented Apr 18, 2023

I'm using soxfor's method to open a port with Transmission and ProtonVPN, but it would be awesome if it was native to Gluetun.

@qdm12
Copy link
Owner

qdm12 commented Apr 20, 2023

It's like 95% done, but I'm struggling to find the time to get on a keyboard currently 😸 I think this weekend is the right weekend to start testing something!

@pvanryn
Copy link

pvanryn commented Apr 21, 2023

If you want any beta testers, let me know.

@qdm12
Copy link
Owner

qdm12 commented Apr 23, 2023

Try with image qmcgaw/gluetun:pr-1543 (being built here), and with env variable PORT_FORWARDING=on, does it work? I didn't try at all and it might not work at all, I'll try to test it more locally tomorrow/Tuesday.

@pvanryn
Copy link

pvanryn commented Apr 23, 2023

Not working with ProtonVPN and PORT_FORWARDING=on. I get this in the log:

gluetun    | 2023-04-23T22:44:29Z WARN You are using the old environment variable PORT_FORWARDING, please consider changing it to PRIVATE_INTERNET_ACCESS_VPN_PORT_FORWARDING
gluetun    | 2023-04-23T22:44:29Z INFO [routing] default route found: interface eth0, gateway 172.27.0.1 and assigned IP 172.27.0.2
gluetun    | 2023-04-23T22:44:29Z INFO [routing] local ethernet link found: eth0
gluetun    | 2023-04-23T22:44:29Z INFO [routing] local ipnet found: 172.27.0.0/16
gluetun    | 2023-04-23T22:44:29Z INFO [firewall] enabling...
gluetun    | 2023-04-23T22:44:29Z INFO [firewall] enabled successfully
gluetun    | 2023-04-23T22:44:30Z INFO [storage] creating /gluetun/servers.json with 13056 hardcoded servers
gluetun    | 2023-04-23T22:44:30Z ERROR VPN settings: provider settings: port forwarding: port forwarding cannot be enabled: for provider custom, it is only available for private internet access
gluetun    | 2023-04-23T22:44:30Z INFO Shutdown successful
gluetun exited with code 1

@ahatdude
Copy link

Just commenting to follow this topic closely, since I'm very interested :-)

@qdm12
Copy link
Owner

qdm12 commented Apr 27, 2023

Can you try re-pulling that image docker pull qmcgaw/gluetun:pr-1543 and set VPN_PORT_FORWARDING=on and see what the logs say? 🤔 Even if it works, I would be curious to see what logs we get.

@pvanryn
Copy link

pvanryn commented Apr 27, 2023

First I tried "custom" for provider, and I got:

Running version pr-1543 built on 2023-04-27T10:30:25.876Z (commit d96995b)
2023-04-27T17:28:35Z INFO [routing] default route found: interface eth0,  gateway 172.24.0.1 and assigned IP 172.24.0.2
2023-04-27T17:28:35Z INFO [routing] local ethernet link found: eth0
2023-04-27T17:28:35Z INFO [routing] local ipnet found: 172.24.0.0/16
2023-04-27T17:28:36Z INFO [firewall] enabling...
2023-04-27T17:28:36Z INFO [firewall] enabled successfully
2023-04-27T17:28:36Z INFO [storage] creating /gluetun/servers.json with 13056 hardcoded servers
2023-04-27T17:28:36Z ERROR VPN settings: provider settings: port forwarding: port forwarding cannot be enabled: for provider custom, it is only available for private internet access, protonvpn
2023-04-27T17:28:36Z INFO Shutdown successful

And then I tried with protonvpn as the provider:

Running version pr-1543 built on 2023-04-27T10:30:25.876Z (commit d96995b)
2023-04-27T17:30:36Z INFO [routing] default route found: interface eth0, gateway 172.25.0.1 and assigned IP 172.25.0.2
2023-04-27T17:30:36Z INFO [routing] local ethernet link found: eth0
2023-04-27T17:30:36Z INFO [routing] local ipnet found: 172.25.0.0/16
2023-04-27T17:30:36Z INFO [firewall] enabling...
2023-04-27T17:30:36Z INFO [firewall] enabled successfully
2023-04-27T17:30:36Z INFO [storage] creating /gluetun/servers.json with 13056 hardcoded servers
2023-04-27T17:30:36Z ERROR VPN settings: provider settings: VPN provider name is not valid: "protonvpn" can only be one of airvpn, custom, ivpn, mullvad, surfshark or windscribe
2023-04-27T17:30:36Z INFO Shutdown successful
gluetun exited with code 1

@tazz4843
Copy link
Author

2023-04-30T09:42:36-06:00 WARN You are using the old environment variable VPNSP, please consider changing it to VPN_SERVICE_PROVIDER
2023-04-30T09:42:36-06:00 WARN You are using the old environment variable WIREGUARD_ADDRESS, please consider changing it to WIREGUARD_ADDRESSES
2023-04-30T09:42:36-06:00 INFO [routing] default route found: interface eth0, gateway 172.25.0.1 and assigned IP 172.25.0.4
2023-04-30T09:42:36-06:00 INFO [routing] local ethernet link found: eth0
2023-04-30T09:42:36-06:00 INFO [routing] local ipnet found: 172.25.0.0/16
2023-04-30T09:42:36-06:00 INFO [firewall] enabling...
2023-04-30T09:42:36-06:00 INFO [firewall] enabled successfully
2023-04-30T09:42:37-06:00 INFO [storage] merging by most recent 13056 hardcoded servers and 13056 servers read from /gluetun/servers.json
2023-04-30T09:42:37-06:00 ERROR VPN settings: provider settings: port forwarding: port forwarding cannot be enabled: for provider custom, it is only available for private internet access, protonvpn
2023-04-30T09:42:37-06:00 INFO Shutdown successful

Same issue, VPN_PORT_FORWARDING and PORT_FORWARDING are both set to on

I'm using Wireguard since I notice a massive speed and CPU use improvement over OpenVPN.

@qdm12
Copy link
Owner

qdm12 commented May 1, 2023

So you are mixing different problems here...

  • @pvanryn Wireguard is for now (natively) unsupported for Protonvpn, explaining the error VPN settings: provider settings: VPN provider name is not valid: "protonvpn" can only be one of airvpn, custom, ivpn, mullvad, surfshark or windscribe - note this error string got improved in the latest image to be VPN provider name is not valid for Wireguard since that was indeed obscured.
  • @pvanryn and @tazz4843 VPN settings: provider settings: port forwarding: port forwarding cannot be enabled: for provider custom, it is only available for private internet access, protonvpn - related to the point above, you need to use protonvpn as provider and openvpn as protocol. The custom provider has no associated custom code to get the port forwarded, however I might work on this to allow the user to select a custom port forwarding code (from pia, protonvpn for now), although please verify it works with openvpn first.

Side note referring to Protonvpn (link), do they still have a unique private key + peer address for each of their server? I would love to natively support it but this makes it highly unpractical for the user (better to use the custom provider directly, and soon wireguard conf files).

@connordeckers
Copy link

@qdm12 I've just pulled it down and confirmed it working with the following config:

  gluetun:
    image: qmcgaw/gluetun:pr-1543
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    volumes:
      - ./gluetun:/gluetun
    environment:
      - VPN_SERVICE_PROVIDER=protonvpn
      - VPN_TYPE=openvpn
      - VPN_PORT_FORWARDING=on
      - OPENVPN_USER=**************+pmp
      - OPENVPN_PASSWORD=*************

I'd be super keen on seeing if you can pin a forwarded port, so that it can be used in other apps (qBittorrent, in my case) without needing a looping userland update script.

Thanks for the awesome work!

@ahatdude
Copy link

ahatdude commented May 1, 2023

I'd be super keen on seeing if you can pin a forwarded port, so that it can be used in other apps (qBittorrent, in my case) without needing a looping userland update script.

This is would be the ideal scenario, if possible :-)

@ahatdude
Copy link

ahatdude commented May 1, 2023

So you are mixing different problems here...

  • @pvanryn Wireguard is for now (natively) unsupported for Protonvpn, explaining the error VPN settings: provider settings: VPN provider name is not valid: "protonvpn" can only be one of airvpn, custom, ivpn, mullvad, surfshark or windscribe - note this error string got improved in the latest image to be VPN provider name is not valid for Wireguard since that was indeed obscured.
  • @pvanryn and @tazz4843 VPN settings: provider settings: port forwarding: port forwarding cannot be enabled: for provider custom, it is only available for private internet access, protonvpn - related to the point above, you need to use protonvpn as provider and openvpn as protocol. The custom provider has no associated custom code to get the port forwarded, however I might work on this to allow the user to select a custom port forwarding code (from pia, protonvpn for now), although please verify it works with openvpn first.

Side note referring to Protonvpn (link), do they still have a unique private key + peer address for each of their server? I would love to natively support it but this makes it highly unpractical for the user (better to use the custom provider directly, and soon wireguard conf files).

ProtonVPN does indeed provide a private and public key for wireguard. The private key changes with each "wireguard.conf" file you create, however the public key remain the same. This is from what I've gathered having various qBit instances using each their own VPN.

Here it does indeed show that Linux is apparently not supported with wireguard anymore, which is strange since I can still create a wireguard.conf for Linux on their website.

Is the plan to reintegrate wireguard on ProtonVPN eventually from your part or will you be waiting until ProtonVPN "officially accepts" it again?

Also, as you mentioned, it would be fantastic if somehow we could just point Gluetun to a wireguard.conf file created by ProtonVPN and maybe pin a port to it to make P2P connections a bit easier.

Thank you so much for all your time and work on this :-)

@connordeckers
Copy link

@qdm12 I've just pulled it down and confirmed it working with the following config:

  gluetun:
    image: qmcgaw/gluetun:pr-1543
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    volumes:
      - ./gluetun:/gluetun
    environment:
      - VPN_SERVICE_PROVIDER=protonvpn
      - VPN_TYPE=openvpn
      - VPN_PORT_FORWARDING=on
      - OPENVPN_USER=**************+pmp
      - OPENVPN_PASSWORD=*************

I'd be super keen on seeing if you can pin a forwarded port, so that it can be used in other apps (qBittorrent, in my case) without needing a looping userland update script.

Thanks for the awesome work!

I may have spoken a little too soon. Whilst the container runs quite happily, I can't seem to access the container via the forwarded port. I've tested it with the port checker as well (as described in the wiki), and nothing successfully connects through to the IP:PORT combo :(

Any ideas?

@pvanryn
Copy link

pvanryn commented May 1, 2023

I corrected my docker-compose to OpenVPN, and the container runs w/o any problems. I chose tcp for the openvpn protocol if that makes any difference. I put the full log in a pastebin in case you want to look at it.

Like connerdeckers, I can't figure out what I am supposed to do with it - but maybe we are getting ahead of you?

What I do currently is run a natpmpc script to open/close ports in my gluetun firewall to match the active port that protonvpn provides.

@qdm12
Copy link
Owner

qdm12 commented May 10, 2023

(sorry for the delay)

@connordeckers @ahatdude

I'd be super keen on seeing if you can pin a forwarded port, so that it can be used in other apps (qBittorrent, in my case) without needing a looping userland update script.

Gluetun has a nat-pmp client built-in, which fetches the port (code) and then maintains it every 45 seconds (it expires after 60s) (code). The NAT-PMP client code is in https://github.com/qdm12/gluetun/tree/68ed7c1504e729e835e3358ef6b5b5ad5886dd36/internal/natpmp (might be chinese to you but it's there). Maybe the port-forwarding does not trigger at all, at the very least the info logged line gateway external IPv4 address is ... should show up, and this doesn't seem the case from looking at logs from @pvanryn

I pushed some debug logs, can you docker pull qmcgaw/gluetun:pr-1543 and use LOG_LEVEL=debug, what debug logs do you see about port forwarding?? Thanks!


Out of the topic @ahatdude but here comes some answers 😉

The private key changes with each "wireguard.conf" file you create, however the public key remain the same.

That doesn't make any sense, the public key should be unique by server instead. Anyway since they made the private key unique by user and server, there is little point supporting natively protonvpn for wireguard since you would have to change your key every time; it's easier to bind mount a different wireguard config - see PR almost done in #1120

@pvanryn
Copy link

pvanryn commented May 10, 2023

I started the container, and everything worked, with the forwarded port in /tmp/gluetun/forwarded_port. Log here.

But after I restarted, no forwarded port again. I finally figured out that it is the server I am pulling. I have:

  • SERVER_CITIES=Los Angeles
    in my docker-compose, but apparently not all Los Angeles servers are port forwarded. I'm not sure how to pull a particular ip with openvpn, maybe someone who is following this thread can tell me how to do that. I had to restart until I got an ip that worked.

I then ran Transmission in my stack with gluetun, but I cannot get an open port, even though gluetun shows it is open. iptables --list gives me:

Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  anywhere             192.168.0.0/20      
ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:36735
ACCEPT     udp  --  anywhere             anywhere             udp dpt:36735

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
ACCEPT     all  --  2cc17af48fbd         192.168.0.0/20      
ACCEPT     udp  --  anywhere             unn-138-199-35-97.datapacket.com  udp dpt:openvpn
ACCEPT     all  --  anywhere             anywhere    

I can set Transmission's configured port for 36735, but transmission-remote -pt shows it as closed. This is the method I use with my natpmpc side car, and I'm not sure why it won't work in gluetun.

@pvanryn
Copy link

pvanryn commented May 14, 2023

so if I start my natpmp sidecar and run this command on gluetun:pr-1543,
natpmpc -g ${VPN gateway IP address} -a 0 0 tcp 300 | grep -oP '(?<=Mapped public port.).*(?=.protocol.*)'
my transmission port is open. The iptables look exactly the same as above.

Is it possible to invoke the go code as a command, e.g. "go natpmp blah blah" ?

@qdm12
Copy link
Owner

qdm12 commented May 21, 2023

Thanks @pvanryn for getting back 👍

Keeping the port forwarded

2023-05-10T15:02:23Z INFO [port forwarding] gateway external IPv4 address is 91.219.212.229
2023-05-10T15:02:23Z INFO [port forwarding] port forwarded is 46927

means the first port forward fetch worked (or at least should have), now it might be the keep that port routing that doesn't work (which should trigger every 45 seconds as per protonvpn documentation). I added info log lines, can you docker pull qmcgaw/gluetun:pr-1543, it should log at the info level the lines (previous debug lines got removed):

keeping port forward with port XXX
keeping port forward triggered by 45s timer
port XXX, assigned internal port YYY, assigned external port ZZZ, assignled lifetime BBB

Pick server with port forwarding

You can pick a particular VPN server IP address with VPN_TARGET_IP. The servers data for Protonvpn is obtained from https://api.protonmail.ch/vpn/logicals which lists a features field for each server, but it's a number like 1, 4, 12 etc. and I have no clue what it means. Maybe you can figure out which is for port forwarding or contact Protonvpn support about it?

iptables

If 36735 is the forwarded port, then it's correct (allows input tcp and udp on 36735)

natpmpc

Sorry I'm confused, does running your command with natpmpc forward the port correctly? Does it work with transmission?

Is it possible to invoke the go code as a command, e.g. "go natpmp blah blah" ?

Yes but it should very much be automated and built-in, otherwise the user also has to fiddle with the firewall which is not great, and then he might as well just use natpmpc directly.
Maybe try with a dumb http server like https://github.com/qdm12/port-checker as a side container, configure it to listen on the forwarded port, and then try accessing it at http://yourvpnip:yourforwardedport ?

@js6pak
Copy link

js6pak commented May 21, 2023

Maybe you can figure out which is for port forwarding

https://github.com/ProtonVPN/protonvpn-nm-lib/blob/31d5f99fbc89274e4e977a11e7432c0eab5a3ef8/protonvpn_nm_lib/enums.py#L44-L49

Could we get gluetun server filtering to work with these? Something like SERVER_FEATURES=P2P

@qdm12
Copy link
Owner

qdm12 commented May 21, 2023

Thanks @js6pak I created #1582 for that, although are you sure the P2P feature corresponds to the port forwarding availability?? If so I'll re-prioritise #1582 to get this issue resolved.

@js6pak
Copy link

js6pak commented May 21, 2023

are you sure the P2P feature corresponds to the port forwarding availability??

I can't find anything on the protonvpn website that says that explicitly, but the windows client filters by P2P servers when port forwarding is enabled (https://github.com/ProtonVPN/win-app/blob/7194fccdacc9d38a399cb6bfde86ec4ee275e08b/src/ProtonVPN.App/Core/Service/Vpn/VpnConnector.cs#L109-L114) and in my experience only P2P servers can open ports.

@definitelynotaduckreally
Copy link

definitelynotaduckreally commented May 22, 2023

although are you sure the P2P feature corresponds to the port forwarding availability??

On a relatively new page they do explicitly say this is the case, under "Step 1:"

https://protonvpn.com/support/port-forwarding-manual-setup/

If I manually select one of the servers that's P2P using VPN_ENDPOINT_IP and set VPN_PORT_FORWARDING=on, and add +pmp to my ProtonVPN username, I can say everything appears to work as expected. Really brilliant.

@varac
Copy link

varac commented Aug 30, 2023

Anyone waiting for the v3.36.0 release can try my image I built today from commit 1ac031e. It seem to work fine, IP and forwarded port are recognized with ProtonVPN 💯

@varac
Copy link

varac commented Aug 30, 2023

I'm still having issues with Transmission though, I can connect to trackers but doesn't download any data. Will further look into it and created a dedicated issue if needed.

@jahanson
Copy link

jahanson commented Sep 4, 2023

Protonvpn port forwarding is now part of the latest image, and will be part of release image v3.36.0.

@qdm12 Do you mind releasing 3.36.0 so we can use/test this new great feature please ?

Please do this as truecharts relies on specifically releases to auto update, I'd love to start using the port forwarding feature as soon as it's released!

I'm hoping to see this released soon as well. I can't use a custom image with Truecharts. Can we release v3.36 @qdm12 ?

@ahatdude
Copy link

Is this working with qBit and portfowarding on proton?

Thanks in advance

@archibaldodlc
Copy link

archibaldodlc commented Sep 20, 2023

@ahatdude It is working.

This is my docker-compose.yml:

gluetun:
    image: qmcgaw/gluetun
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    devices:
      - /dev/net/tun:/dev/net/tun
    environment:
      - VPN_SERVICE_PROVIDER=custom
      - VPN_TYPE=wireguard
      - VPN_ENDPOINT_IP=endpoint_ip_from_wireguard_conf
      - VPN_ENDPOINT_PORT=endpoint_port_from_wirguard_conf
      - VPN_PORT_FORWARDING_PROVIDER=protonvpn
      - WIREGUARD_PUBLIC_KEY=public_key_from_proton_wireguard_conf
      - WIREGUARD_PRIVATE_KEY=private_key_from_proton_wireguard_conf
      - WIREGUARD_ADDRESSES=address_from_proton_wireguard_conf
      - FIREWALL_OUTBOUND_SUBNETS=192.168.0.0/16 # Internal network
      - VPN_PORT_FORWARDING=on
    ports:
      - 80:80
      - 34803:34803/udp #This is the port that proton wireguard assign. Check below.
    restart: always 

  qbittorrent:
    image: lscr.io/linuxserver/qbittorrent:latest
    container_name: qbittorrent
    network_mode: "service:gluetun"
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Etc/UTC
      - WEBUI_PORT=80
    volumes:
      - ./config:/config
      - /downloads:/downloads
    depends_on:
      - gluetun
    restart: always

To see the port that proton Wireguard assigns, you can run:

docker exec -it gluetun cat /tmp/gluetun/forwarded_port

Then I set the port in qbitorrent to 34803 and I did a port forward in my router.

Hope it helps.

The VPN port forward resist 'docker compose up -d --force-recreate' command, which is great!

I take this opportunity to extend my gratitude to @qdm12 for his fantastic job.

Regards,

@ahatdude
Copy link

@archibaldodlc Thanks for your response and it will be of great help!

I won't be able to test it immediately, however I remember there was previously an issue with the port being assigned only for a period of time instead of "indefinitely" and persistent through container restarts. Is that what the 'docker compose up -d --force-recreate' command does?

Also, is there a way to specify a port or must I choose the one selected by proton wireguard?

Sorry for any confusion.

@archibaldodlc
Copy link

@ahatdude I tried with 'docker compose restart' and 'docker compose up -d --force-recreate' (which recreates the containers). In both cases the port remains the same.

About the port, you must choose the one selected by proton wireguard.

Regards

@ahatdude
Copy link

Thanks again @archibaldodlc

I hope you don't mind, just 2 more questions:

  • In the variable VPN_SERVICE_PROVIDER=custom, can this be "protonvpn"? I only mention it since it appears as an option in the dropdown menu in the unRAID template.
  • When creating the Wireguard configuration in the proton website, what should the following options look like
    firefox_EwG6y2owIY
    firefox_V3RUJNkh4Z

I appreciate all your time.

@archibaldodlc
Copy link

archibaldodlc commented Sep 22, 2023

@ahatdude I don't know how it works UnRAID, but those are the environment variables for the container.

When you create the Wireguard configuration, you must select NAT-PMP and optional VPN Accelerator (I have selected). Just ensure that the server supports P2P (they have an icon in the right columns of the list)

This is how it looks my configuration:

[Interface]
# Key for qtr
# Bouncing = 11
# NetShield = 0
# NAT moderada = off
# NAT-PMP (Enrutamiento de puertos) = on
# VPN Accelerator = on
PrivateKey = ***edited**
Address = **edited**
DNS = **edited**

[Peer]
# DE#68
PublicKey = ***edited***
AllowedIPs = 0.0.0.0/0
Endpoint = IP_VPN_SERVER:PORT

@ahatdude
Copy link

hey @archibaldodlc ,
I have it all currently running, however I cannot fetch the port.
This is what I get:

docker exec -it GluetunVPN-qbittorrent-vpn-4k-movies cat /tmp/gluetun/forwarded_port
cat: can't open '/tmp/gluetun/forwarded_port': No such file or directory

Other than this, I've checked with curl ifconfig.io in the qbit container and I get the IP from the proton configuration, therefore I believe that aspect is fine and gluetun and qbit are running in tandem. However, I'm not sure why that directory is not existing. I did check manually inside the docker image with ls -la and it wasn't there.

Thanks for your time. :-)

@archibaldodlc
Copy link

Hi, @ahatdude Can you share your docker-compose.yml and the logs from gluetun container?

@ahatdude
Copy link

Hey @archibaldodlc
This is a docker-compose I generated from the docker template I use in unRAID. All the variables are indeed there, but I only use the ones that are necessary. I edited the sensitive information out. I see the variable "VPN_PORT_FORWADING_STATUS_FILE" and it is indeed where you told me to look, but there seems to be no file when I actually go around searching for it. I apologise in advance for the very big docker-compose.

networks:
  proxynet:
    external: true
    name: "proxynet"

services:

  GluetunVPN-qbittorrent-vpn-4k-movies:

    container_name: "GluetunVPN-qbittorrent-vpn-4k-movies"

    devices:
      - "/dev/net/tun:/dev/net/tun"

    entrypoint:
      - "/gluetun-entrypoint"

    environment:

      - "VPN_ENDPOINT_PORT=51820"

      - "LOG_LEVEL=info"

      - "PUBLICIP_FILE=/gluetun/ip"

      - "PUBLICIP_PERIOD=12h"

      - "HTTP_CONTROL_SERVER_LOG=on"

      - "HOST_HOSTNAME=Tower"

      - "BLOCK_SURVEILLANCE=off"

      - "HEALTH_VPN_DURATION_INITIAL=6s"

      - "VPN_ENDPOINT_IP=IP_HERE"

      - "OPENVPN_VERBOSITY=1"

      - "WIREGUARD_PRESHARED_KEY="

      - "FIREWALL=on"

      - "HEALTH_SERVER_ADDRESS=127.0.0.1:9999"

      - "DOT_IPV6=off"

      - "DNS_KEEP_NAMESERVER=off"

      - "VERSION_INFORMATION=on"

      - "DNS_UPDATE_PERIOD=24h"

      - "UPDATER_PERIOD=0"

      - "BLOCK_MALICIOUS=on"

      - "SHADOWSOCKS=off"

      - "PUID=1000"

      - "HOST_CONTAINERNAME=GluetunVPN-qbittorrent-vpn-4k-movies"

      - "VPN_TYPE=wireguard"

      - "WIREGUARD_IMPLEMENTATION=auto"

      - "FIREWALL_DEBUG=off"

      - "DOT_PRIVATE_ADDRESS=127.0.0.1/8,10.0.0.0/8,172.16.0.0/12,192.168.0.0/16,169.254.0.0/16,::1/128,fc00::/7,fe80::/10,::ffff:7f00:1/104,::ffff:a00:0/104,::ffff:a9fe:0/112,::ffff:ac10:0/108,::ffff:c0a8:0/112"

      - "TZ=Europe/Zurich"

      - "DOT_PROVIDERS=cloudflare"

      - "DOT_VALIDATION_LOGLEVEL=0"

      - "DOT=on"

      - "VPN_INTERFACE=wg0"

      - "WIREGUARD_PRIVATE_KEY=PRIVATE_KEY_HERE"

      - "WIREGUARD_ADDRESSES=ADDRESS_HERE"

      - "SHADOWSOCKS_PASSWORD="

      - "OPENVPN_PROTOCOL=udp"

      - "HTTPPROXY_LOG=off"

      - "HTTPPROXY_STEALTH=off"

      - "SHADOWSOCKS_LOG=off"

      - ":8388=:8388"

      - "SHADOWSOCKS_CIPHER=chacha20-ietf-poly1305"

      - "DOT_VERBOSITY_DETAILS=0"

      - "DOT_CACHING=on"

      - "HTTPPROXY=off"

      - "HEALTH_TARGET_ADDRESS=github.com:443"

      - "PGID=1000"

      - "OPENVPN_VERSION=2.5"

      - "WIREGUARD_PUBLIC_KEY=PUBLIC_KEY_HERE"

      - "BLOCK_ADS=off"

      - "HEALTH_VPN_DURATION_ADDITION=5s"

      - "HOST_OS=Unraid"

      - "VPN_SERVICE_PROVIDER=custom"

      - "DOT_VERBOSITY=1"

      - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

      - "OPENVPN_USER="

      - "OPENVPN_PASSWORD="

      - "OPENVPN_USER_SECRETFILE=/run/secrets/openvpn_user"

      - "OPENVPN_PASSWORD_SECRETFILE=/run/secrets/openvpn_password"

      - "OPENVPN_FLAGS="

      - "OPENVPN_CIPHERS="

      - "OPENVPN_AUTH="

      - "OPENVPN_PROCESS_USER=root"

      - "OPENVPN_CUSTOM_CONFIG="

      - "WIREGUARD_ALLOWED_IPS="

      - "WIREGUARD_MTU=1400"

      - "SERVER_REGIONS="

      - "SERVER_COUNTRIES="

      - "SERVER_CITIES="

      - "SERVER_HOSTNAMES="

      - "ISP="

      - "OWNED_ONLY=no"

      - "PRIVATE_INTERNET_ACCESS_OPENVPN_ENCRYPTION_PRESET="

      - "VPN_PORT_FORWARDING=off"

      - "VPN_PORT_FORWARDING_PROVIDER="

      - "VPN_PORT_FORWARDING_STATUS_FILE=/tmp/gluetun/forwarded_port"

      - "OPENVPN_CERT="

      - "OPENVPN_KEY="

      - "OPENVPN_CLIENTCRT_SECRETFILE=/run/secrets/openvpn_clientcrt"

      - "OPENVPN_CLIENTKEY_SECRETFILE=/run/secrets/openvpn_clientkey"

      - "OPENVPN_ENCRYPTED_KEY="

      - "OPENVPN_ENCRYPTED_KEY_SECRETFILE=/run/secrets/openvpn_encrypted_key"

      - "OPENVPN_KEY_PASSPHRASE="

      - "OPENVPN_KEY_PASSPHRASE_SECRETFILE=/run/secrets/openvpn_key_passphrase"

      - "SERVER_NUMBER="

      - "SERVER_NAMES="

      - "FREE_ONLY="

      - "MULTIHOP_ONLY="

      - "PREMIUM_ONLY="

      - "FIREWALL_VPN_INPUT_PORTS="

      - "FIREWALL_INPUT_PORTS="

      - "FIREWALL_OUTBOUND_SUBNETS="

      - "HEALTH_SUCCESS_WAIT_DURATION=5s"

      - "UNBLOCK="

      - "DNS_ADDRESS=127.0.0.1"

      - "HTTPPROXY_LISTENING_ADDRESS=:8888"

      - "HTTPPROXY_USER="

      - "HTTPPROXY_PASSWORD="

      - "HTTPPROXY_USER_SECRETFILE=/run/secrets/httpproxy_user"

      - "HTTPPROXY_PASSWORD_SECRETFILE=/run/secrets/httpproxy_password"

      - "SHADOWSOCKS_LISTENING_ADDRESS=:8388"

      - "SHADOWSOCKS_PASSWORD_SECRETFILE=/run/secrets/shadowsocks_password"

      - "HTTP_CONTROL_SERVER_ADDRESS=:8000"

      - "UPDATER_MIN_RATIO=0.8"

      - "UPDATER_VPN_SERVICE_PROVIDERS="

      - "PPROF_ENABLED=no"

      - "PPROF_BLOCK_PROFILE_RATE=0"

      - "PPROF_MUTEX_PROFILE_RATE=0"

      - "PPROF_HTTP_SERVER_ADDRESS=:6060"

    hostname: "86a431cc38eb"

    image: "qmcgaw/gluetun"

    ipc: "private"

    labels:
      net.unraid.docker.icon: "https://raw.githubusercontent.com/qdm12/gluetun/master/doc/logo_256.png"
      net.unraid.docker.managed: "dockerman"
      net.unraid.docker.webui: "http://[IP]:[PORT:8000]"
      org.opencontainers.image.authors: "quentin.mcgaw@gmail.com"
      org.opencontainers.image.created: "2023-09-23T13:31:26.334Z"
      org.opencontainers.image.description: "VPN client in a thin Docker container\
        \ for multiple VPN providers, written in Go, and using OpenVPN or Wireguard,\
        \ DNS over TLS, with a few proxy servers built-in."
      org.opencontainers.image.documentation: "https://github.com/qdm12/gluetun"
      org.opencontainers.image.licenses: "MIT"
      org.opencontainers.image.revision: "aa6dc786a48f4f051dc5e5876ac69dee62e5ac72"
      org.opencontainers.image.source: "https://github.com/qdm12/gluetun"
      org.opencontainers.image.title: "gluetun"
      org.opencontainers.image.url: "https://github.com/qdm12/gluetun"
      org.opencontainers.image.version: "latest"

    logging:
      driver: "json-file"
      options:
        max-file: "1"
        max-size: "50m"

    networks:
      - "proxynet"

    ports:
      - "8000:8000/tcp"
      - "8888:8888/tcp"

    restart: "always"

    volumes:
      - "/mnt/nvme_cache/appdata/gluetun-4k-movies:/gluetun"

  qbittorrent-vpn-4k-movies:

    container_name: "qbittorrent-vpn-4k-movies"

    entrypoint:
      - "/init"

    environment:
      - "UMASK=002"
      - "TZ=Europe/Berlin"
      - "HOST_OS=Unraid"
      - "HOST_HOSTNAME=Tower"
      - "VPN_LAN_NETWORK="
      - "VPN_ADDITIONAL_PORTS="
      - "PGID=100"
      - "HOST_CONTAINERNAME=qbittorrent-vpn-4k-movies"
      - "VPN_ENABLED=false"
      - "VPN_CONF=wg0"
      - "VPN_IP_CHECK_DELAY=120"
      - "PUID=99"
      - "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      - "APP_DIR=/app"
      - "CONFIG_DIR=/config"
      - "ARGS="
      - "XDG_CONFIG_HOME=/config/.config"
      - "XDG_CACHE_HOME=/config/.cache"
      - "XDG_DATA_HOME=/config/.local/share"
      - "LANG=C.UTF-8"
      - "LC_ALL=C.UTF-8"
      - "S6_BEHAVIOUR_IF_STAGE2_FAILS=2"
      - "S6_CMD_WAIT_FOR_SERVICES_MAXTIME=0"
      - "BUILD_ARCHITECTURE=linux-amd64"
      - "WEBUI_PORTS=8080/tcp,8080/udp"
      - "PRIVOXY_ENABLED=false"
      - "S6_SERVICES_GRACETIME=180000"
      - "S6_STAGE2_HOOK=/init-hook"

    expose:
      - "8080/tcp"

    hostname: "86a431cc38eb"

    image: "cr.hotio.dev/hotio/qbittorrent:legacy"

    ipc: "private"

    labels:
      net.unraid.docker.icon: "https://hotio.dev/webhook-avatars/qbittorrent.png"
      net.unraid.docker.managed: "dockerman"
      net.unraid.docker.webui: "http://[IP]:[PORT:8080]"
      org.opencontainers.image.created: "2023-09-19T12:43:43Z"
      org.opencontainers.image.revision: "db17655e5c01f88a69ca3446bb1e996432a34af3"
      org.opencontainers.image.source: "https://github.com/hotio/qbittorrent/tree/legacy"
      org.opencontainers.image.title: "hotio/qbittorrent:legacy"
      org.opencontainers.image.url: "https://github.com/hotio/qbittorrent/blob/master/README.md"
      org.opencontainers.image.vendor: "hotio"
      org.opencontainers.image.version: "4.3.9"

    logging:
      driver: "json-file"
      options:
        max-file: "1"
        max-size: "50m"

    volumes:
      - "/mnt/nvme_cache/appdata/qbittorrent-vpn-4k-movies:/config"
      - "/mnt/user/data/torrents/qbit-4k-movies:/data/torrents/qbit-4k-movies"

And this is the log:

09/25/2023
5:02:29 AM
========================================
09/25/2023
5:02:29 AM
========================================
09/25/2023
5:02:29 AM
=============== gluetun ================
09/25/2023
5:02:29 AM
========================================
09/25/2023
5:02:29 AM
=========== Made with ❤️ by ============
09/25/2023
5:02:29 AM
======= https://github.com/qdm12 =======
09/25/2023
5:02:29 AM
========================================
09/25/2023
5:02:29 AM
========================================
09/25/2023
5:02:29 AM
09/25/2023
5:02:29 AM
Running version latest built on 2023-09-24T16:54:36.207Z (commit 9b00763)
09/25/2023
5:02:29 AM
09/25/2023
5:02:29 AM
🔧 Need help? https://github.com/qdm12/gluetun/discussions/new
09/25/2023
5:02:29 AM
🐛 Bug? https://github.com/qdm12/gluetun/issues/new
09/25/2023
5:02:29 AM
✨ New feature? https://github.com/qdm12/gluetun/issues/new
09/25/2023
5:02:29 AM
☕ Discussion? https://github.com/qdm12/gluetun/discussions/new
09/25/2023
5:02:29 AM
💻 Email? quentin.mcgaw@gmail.com
09/25/2023
5:02:29 AM
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [routing] default route found: interface eth0, gateway REMOVED_BY_ME, assigned IP REMOVED_BY_ME and family v4
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [routing] local ethernet link found: eth0
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [routing] local ipnet found: 172.19.0.0/16
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [firewall] enabling...
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [firewall] enabled successfully
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [storage] merging by most recent 17689 hardcoded servers and 17689 servers read from /gluetun/servers.json
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO Alpine version: 3.18.3
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO OpenVPN 2.5 version: 2.5.8
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO OpenVPN 2.6 version: 2.6.5
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO Unbound version: 1.17.1
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO IPtables version: v1.8.9
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO Settings summary:
09/25/2023
5:02:29 AM
├── VPN settings:
09/25/2023
5:02:29 AM
|   ├── VPN provider settings:
09/25/2023
5:02:29 AM
|   |   ├── Name: custom
09/25/2023
5:02:29 AM
|   |   └── Server selection settings:
09/25/2023
5:02:29 AM
|   |       ├── VPN type: wireguard
09/25/2023
5:02:29 AM
|   |       ├── Target IP address: REMOVED_BY_ME
09/25/2023
5:02:29 AM
|   |       └── Wireguard selection settings:
09/25/2023
5:02:29 AM
|   |           ├── Endpoint IP address: REMOVED_BY_ME
09/25/2023
5:02:29 AM
|   |           ├── Endpoint port: 51820
09/25/2023
5:02:29 AM
|   |           └── Server public key: REMOVED_BY_ME
09/25/2023
5:02:29 AM
|   └── Wireguard settings:
09/25/2023
5:02:29 AM
|       ├── Private key: REMOVED_BY_ME
09/25/2023
5:02:29 AM
|       ├── Interface addresses:
09/25/2023
5:02:29 AM
|       |   └── 10.2.0.2/32
09/25/2023
5:02:29 AM
|       ├── Allowed IPs:
09/25/2023
5:02:29 AM
|       |   ├── 0.0.0.0/0
09/25/2023
5:02:29 AM
|       |   └── ::/0
09/25/2023
5:02:29 AM
|       └── Network interface: wg0
09/25/2023
5:02:29 AM
|           └── MTU: 1400
09/25/2023
5:02:29 AM
├── DNS settings:
09/25/2023
5:02:29 AM
|   ├── Keep existing nameserver(s): no
09/25/2023
5:02:29 AM
|   ├── DNS server address to use: 127.0.0.1
09/25/2023
5:02:29 AM
|   └── DNS over TLS settings:
09/25/2023
5:02:29 AM
|       ├── Enabled: yes
09/25/2023
5:02:29 AM
|       ├── Update period: every 24h0m0s
09/25/2023
5:02:29 AM
|       ├── Unbound settings:
09/25/2023
5:02:29 AM
|       |   ├── Authoritative servers:
09/25/2023
5:02:29 AM
|       |   |   └── cloudflare
09/25/2023
5:02:29 AM
|       |   ├── Caching: yes
09/25/2023
5:02:29 AM
|       |   ├── IPv6: no
09/25/2023
5:02:29 AM
|       |   ├── Verbosity level: 1
09/25/2023
5:02:29 AM
|       |   ├── Verbosity details level: 0
09/25/2023
5:02:29 AM
|       |   ├── Validation log level: 0
09/25/2023
5:02:29 AM
|       |   ├── System user: root
09/25/2023
5:02:29 AM
|       |   └── Allowed networks:
09/25/2023
5:02:29 AM
|       |       ├── 0.0.0.0/0
09/25/2023
5:02:29 AM
|       |       └── ::/0
09/25/2023
5:02:29 AM
|       └── DNS filtering settings:
09/25/2023
5:02:29 AM
|           ├── Block malicious: yes
09/25/2023
5:02:29 AM
|           ├── Block ads: no
09/25/2023
5:02:29 AM
|           ├── Block surveillance: no
09/25/2023
5:02:29 AM
|           └── Blocked IP networks:
09/25/2023
5:02:29 AM
|               ├── 127.0.0.1/8
09/25/2023
5:02:29 AM
|               ├── 10.0.0.0/8
09/25/2023
5:02:29 AM
|               ├── 172.16.0.0/12
09/25/2023
5:02:29 AM
|               ├── 192.168.0.0/16
09/25/2023
5:02:29 AM
|               ├── 169.254.0.0/16
09/25/2023
5:02:29 AM
|               ├── ::1/128
09/25/2023
5:02:29 AM
|               ├── fc00::/7
09/25/2023
5:02:29 AM
|               ├── fe80::/10
09/25/2023
5:02:29 AM
|               ├── ::ffff:127.0.0.1/104
09/25/2023
5:02:29 AM
|               ├── ::ffff:10.0.0.0/104
09/25/2023
5:02:29 AM
|               ├── ::ffff:169.254.0.0/112
09/25/2023
5:02:29 AM
|               ├── ::ffff:172.16.0.0/108
09/25/2023
5:02:29 AM
|               └── ::ffff:192.168.0.0/112
09/25/2023
5:02:29 AM
├── Firewall settings:
09/25/2023
5:02:29 AM
|   └── Enabled: yes
09/25/2023
5:02:29 AM
├── Log settings:
09/25/2023
5:02:29 AM
|   └── Log level: INFO
09/25/2023
5:02:29 AM
├── Health settings:
09/25/2023
5:02:29 AM
|   ├── Server listening address: 127.0.0.1:9999
09/25/2023
5:02:29 AM
|   ├── Target address: github.com:443
09/25/2023
5:02:29 AM
|   ├── Duration to wait after success: 5s
09/25/2023
5:02:29 AM
|   ├── Read header timeout: 100ms
09/25/2023
5:02:29 AM
|   ├── Read timeout: 500ms
09/25/2023
5:02:29 AM
|   └── VPN wait durations:
09/25/2023
5:02:29 AM
|       ├── Initial duration: 6s
09/25/2023
5:02:29 AM
|       └── Additional duration: 5s
09/25/2023
5:02:29 AM
├── Shadowsocks server settings:
09/25/2023
5:02:29 AM
|   └── Enabled: no
09/25/2023
5:02:29 AM
├── HTTP proxy settings:
09/25/2023
5:02:29 AM
|   └── Enabled: no
09/25/2023
5:02:29 AM
├── Control server settings:
09/25/2023
5:02:29 AM
|   ├── Listening address: :8000
09/25/2023
5:02:29 AM
|   └── Logging: yes
09/25/2023
5:02:29 AM
├── OS Alpine settings:
09/25/2023
5:02:29 AM
|   ├── Process UID: 1000
09/25/2023
5:02:29 AM
|   ├── Process GID: 1000
09/25/2023
5:02:29 AM
|   └── Timezone: europe/zurich
09/25/2023
5:02:29 AM
├── Public IP settings:
09/25/2023
5:02:29 AM
|   ├── Fetching: every 12h0m0s
09/25/2023
5:02:29 AM
|   └── IP file path: /gluetun/ip
09/25/2023
5:02:29 AM
└── Version settings:
09/25/2023
5:02:29 AM
    └── Enabled: yes
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [routing] default route found: interface eth0, gateway 172.19.0.1, assigned IP 172.19.0.51 and family v4
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [routing] adding route for 0.0.0.0/0
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [firewall] setting allowed subnets...
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [routing] default route found: interface eth0, gateway 172.19.0.1, assigned IP 172.19.0.51 and family v4
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [dns] using plaintext DNS at address 1.1.1.1
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [http server] http server listening on [::]:8000
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [firewall] allowing VPN connection...
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [healthcheck] listening on 127.0.0.1:9999
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [wireguard] Using available kernelspace implementation
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [wireguard] Connecting to REMOVED_BY_ME
09/25/2023
5:02:29 AM
2023-09-25T05:02:29+02:00 INFO [wireguard] Wireguard setup is complete. Note Wireguard is a silent protocol and it may or may not work, without giving any error message. Typically i/o timeout errors indicate the Wireguard connection is not working.
09/25/2023
5:02:30 AM
2023-09-25T05:02:30+02:00 INFO [dns] downloading DNS over TLS cryptographic files
09/25/2023
5:02:30 AM
2023-09-25T05:02:30+02:00 INFO [healthcheck] healthy!
09/25/2023
5:02:31 AM
2023-09-25T05:02:31+02:00 INFO [dns] downloading hostnames and IP block lists
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [dns] init module 0: validator
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [dns] init module 1: iterator
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [dns] start of service (unbound 1.17.1).
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [dns] ready
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [vpn] You are running on the bleeding edge of latest!
09/25/2023
5:02:34 AM
2023-09-25T05:02:34+02:00 INFO [ip getter] Public IP address is 185.159.157.52 (Switzerland, Zurich, Zürich)
09/25/2023
6:50:39 AM
2023-09-25T06:50:39+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
9:32:47 AM
2023-09-25T09:32:47+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
12:14:55 PM
2023-09-25T12:14:55+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
2:57:08 PM
2023-09-25T14:57:08+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
5:02:35 PM
2023-09-25T17:02:35+02:00 INFO [ip getter] Public IP address is 185.159.157.52 (Switzerland, Zurich, Zürich)
09/25/2023
5:39:16 PM
2023-09-25T17:39:16+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
7:27:20 PM
2023-09-25T19:27:20+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/25/2023
11:57:41 PM
2023-09-25T23:57:41+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
2:39:54 AM
2023-09-26T02:39:54+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
5:02:29 AM
2023-09-26T05:02:29+02:00 INFO [dns] downloading DNS over TLS cryptographic files
09/26/2023
5:02:31 AM
2023-09-26T05:02:31+02:00 INFO [dns] downloading hostnames and IP block lists
09/26/2023
5:02:32 AM
2023-09-26T05:02:32+02:00 INFO [dns] stopping
09/26/2023
5:02:32 AM
2023-09-26T05:02:32+02:00 INFO [dns] using plaintext DNS at address 1.1.1.1
09/26/2023
5:02:32 AM
2023-09-26T05:02:32+02:00 INFO [dns] starting
09/26/2023
5:02:32 AM
2023-09-26T05:02:32+02:00 INFO [dns] downloading DNS over TLS cryptographic files
09/26/2023
5:02:32 AM
2023-09-26T05:02:32+02:00 INFO [dns] downloading hostnames and IP block lists
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [dns] init module 0: validator
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [dns] init module 1: iterator
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [dns] start of service (unbound 1.17.1).
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [dns] ready
09/26/2023
5:02:35 AM
2023-09-26T05:02:35+02:00 INFO [ip getter] Public IP address is 185.159.157.52 (Switzerland, Zurich, Zürich)
09/26/2023
9:32:48 AM
2023-09-26T09:32:48+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
1:09:02 PM
2023-09-26T13:09:02+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
2:57:10 PM
2023-09-26T14:57:10+02:00 INFO [dns] generate keytag query _ta-4a5c-4f66. NULL IN
09/26/2023
4:48:12 PM
2023-09-26T16:48:12+02:00 INFO [http server] 400 GET  wrote 41B to 192.168.1.105:62126 in 6.398µs
09/26/2023
4:48:12 PM
2023-09-26T16:48:12+02:00 INFO [http server] 400 GET /favicon.ico wrote 41B to 192.168.1.105:62126 in 6.513µs

@SnoringDragon
Copy link

@ahatdude in your docker-compose, these are the lines for your port forwarding configuration.

...

  - "VPN_PORT_FORWARDING=off"

  - "VPN_PORT_FORWARDING_PROVIDER="

  - "VPN_PORT_FORWARDING_STATUS_FILE=/tmp/gluetun/forwarded_port"

...

Notably, you need to set VPN_PORTFORWARDING=on and VPN_PORT_FORWARDING_PROVIDER=protonvpn.

It might also be worth checking that you enabled port forwarding in the wireguard profile you for from the PtotonVPN Website.

@SnoringDragon
Copy link

Protonvpn port forwarding is now part of the latest image, and will be part of release image v3.36.0.

@qdm12 Do you mind releasing 3.36.0 so we can use/test this new great feature please ?

Please do this as truecharts relies on specifically releases to auto update, I'd love to start using the port forwarding feature as soon as it's released!

I'm hoping to see this released soon as well. I can't use a custom image with Truecharts. Can we release v3.36 @qdm12 ?

@jahanson I'm not sure about truecharts specifically, but I have just been using the gluetun:latest image for quite a while now, and it has had support for port forwarding. So you may want to give it a try.

@ahatdude
Copy link

@ahatdude in your docker-compose, these are the lines for your port forwarding configuration.

...

  - "VPN_PORT_FORWARDING=off"

  - "VPN_PORT_FORWARDING_PROVIDER="

  - "VPN_PORT_FORWARDING_STATUS_FILE=/tmp/gluetun/forwarded_port"

...

Notably, you need to set VPN_PORTFORWARDING=on and VPN_PORT_FORWARDING_PROVIDER=protonvpn.

It might also be worth checking that you enabled port forwarding in the wireguard profile you for from the PtotonVPN Website.

For some reason, even when I add this as a variable in the unRAID template, it still remains OFF, until I understand why I'm just using the docker-compose linked above by @archibaldodlc

It's currently giving me this error:

2023-09-27T22:50:03Z ERROR VPN settings: Wireguard settings: private key is not valid: wgtypes: failed to parse base64-encoded key: illegal base64 data at input byte 40

I've tried to put the password in between "" but still didn't work.

@joshward9182
Copy link

I have a script to auto-update qBitTorrent but every so often, the Gluetun container returns 0 for the forwarded port by Proton. It only goes to non-0 on a container restart.
Anyone else have the problem? I feel like it's user error, bad setup, but not sure where to look.

I've specified Server Countries which have P2P, as per the docs (UK, US & Netherlands).

I've recently moved to Unraid, so not sure how to share my config yet, like I would have done with docker compose. I've only recently got Proton too, so not sure if this would have happened on my previous Ubuntu server.

root@UnraidServer:~# curl 192.168.1.5:8000/v1/openvpn/portforwarded
{"port":0}

@Blinky-Lights
Copy link

@joshward9182

I have a script to auto-update qBitTorrent but every so often, the Gluetun container returns 0 for the forwarded port by Proton. It only goes to non-0 on a container restart. Anyone else have the problem? I feel like it's user error, bad setup, but not sure where to look.

I've specified Server Countries which have P2P, as per the docs (UK, US & Netherlands).

I've recently moved to Unraid, so not sure how to share my config yet, like I would have done with docker compose. I've only recently got Proton too, so not sure if this would have happened on my previous Ubuntu server.

root@UnraidServer:~# curl 192.168.1.5:8000/v1/openvpn/portforwarded
{"port":0}

I am also seeing this on my end. I am currently not specifying only P2P servers and assumed this is the issue. By chance are you connecting to only P2P servers and still experiencing this?

@FlorentLM
Copy link

@joshward9182 @Blinky-Lights This command returns the port used by the OpenVPN server (as you can see in the http request url), not the Wireguard, so it's kind of expected to get {"port":0} if you use Wireguard.

AFAIK the server unfortunately does not provide any way to get the port when using Wireguard, so you can use the temp file instead as a workaround.

I currently have this set up with a scheduled cat command in my rtorrent.rc and it works fine :)

@joshward9182
Copy link

@Blinky-Lights
Good question.. I thought the list on the Proton website showed whether P2P is supported at a country level:

Screenshot_20240101-175728.jpg

But upon checking again, I've just noticed a drop down and noticed that the US has a few servers that don't:

Screenshot_20240101-180023.jpg

However, I'm sure a friend of mine used only UK & Netherlands (all servers support P2P) and was having the same problem.

Is there a way to check which server I'm connected to when It happens?
I know I can get IP, and therefore location, but each location with a non-P2P server also has server which does support it.

Might take a while to confirm because it doesn't happen very often.

@FlorentLM
I'm using an OpenVPN config and it works most of the time. It just seems to latch into the failed state until I restart the container.

@Blinky-Lights
Copy link

Blinky-Lights commented Jan 1, 2024

@joshward9182 Yeah, I came to the same conclusion. While Proton shows P2P at the country level, when you drill down there are definitely servers that do not include port forwarding which I think is the issue. There's no way to only specify P2P servers unless you use the config file which limits you to using a single Proton server. I didn't want to do that as there have been instances where Proton decides to take a server offline, which would leave the connection inoperable until updating the config file again.

I have a script that updates qbittorrent's port similar to you, so as a workaround I ended up adding logic into the script that after it gets the forwarded port information from /v1/openvpn/portforwarded if the port returned is equal to 0 to then the script will send the following command to gluetun: curl -X PUT -H "Content-Type: application/json" -d '{"status":"stopped"}' "http://SERVERIP:CONTROLPORT/v1/openvpn/status" replace SERVERIP with your IP and CONTROLPORT with your control port. This forces gluetun to stop openvpn which in turn will force an unhealthy status and causes the connection to re-connect to Proton. I then have the script sleep for 5 minutes and check the port again, which usually corrects the issue. So far this seems to have helped.

Reference for the control server commands here: https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md

@joshward9182
Copy link

@Blinky-Lights I didn't think stopping it using that method would work and didn't think to try either.

Works perfectly though, thanks!

@0x20Fearless
Copy link

@joshward9182 Yeah, I came to the same conclusion. While Proton shows P2P at the country level, when you drill down there are definitely servers that do not include port forwarding which I think is the issue. There's no way to only specify P2P servers unless you use the config file which limits you to using a single Proton server. I didn't want to do that as there have been instances where Proton decides to take a server offline, which would leave the connection inoperable until updating the config file again.

I have a script that updates qbittorrent's port similar to you, so as a workaround I ended up adding logic into the script that after it gets the forwarded port information from /v1/openvpn/portforwarded if the port returned is equal to 0 to then the script will send the following command to gluetun: curl -X PUT -H "Content-Type: application/json" -d '{"status":"stopped"}' "http://SERVERIP:CONTROLPORT/v1/openvpn/status" replace SERVERIP with your IP and CONTROLPORT with your control port. This forces gluetun to stop openvpn which in turn will force an unhealthy status and causes the connection to re-connect to Proton. I then have the script sleep for 5 minutes and check the port again, which usually corrects the issue. So far this seems to have helped.

Reference for the control server commands here: https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md

Could you share the script?

@joshward9182
Copy link

@joshward9182 Yeah, I came to the same conclusion. While Proton shows P2P at the country level, when you drill down there are definitely servers that do not include port forwarding which I think is the issue. There's no way to only specify P2P servers unless you use the config file which limits you to using a single Proton server. I didn't want to do that as there have been instances where Proton decides to take a server offline, which would leave the connection inoperable until updating the config file again.

I have a script that updates qbittorrent's port similar to you, so as a workaround I ended up adding logic into the script that after it gets the forwarded port information from /v1/openvpn/portforwarded if the port returned is equal to 0 to then the script will send the following command to gluetun: curl -X PUT -H "Content-Type: application/json" -d '{"status":"stopped"}' "http://SERVERIP:CONTROLPORT/v1/openvpn/status" replace SERVERIP with your IP and CONTROLPORT with your control port. This forces gluetun to stop openvpn which in turn will force an unhealthy status and causes the connection to re-connect to Proton. I then have the script sleep for 5 minutes and check the port again, which usually corrects the issue. So far this seems to have helped.

Reference for the control server commands here: https://github.com/qdm12/gluetun-wiki/blob/main/setup/advanced/control-server.md

Could you share the script?

Are you looking for a shell script? Or something else?

I have done it in Node-Red as part of my Home Assistant instance. Could knock up a quick shell script though, if needed.

@0x20Fearless
Copy link

needed

I run docker on Pi4, unraid, and Synology (it can do SSH), so a bash script sounds most versatile

@Blinky-Lights
Copy link

Blinky-Lights commented Jan 16, 2024

Documenting this here for anyone else that comes across it:

I am by no means an expert so take all of this with a grain of salt. When originally tackling the issue of wanting to update the port I found this script from someone else a while back and have modified it to fit my needs. I ended up creating a separate container that is running from a docker file using the following dockerfile:

FROM alpine:3.18

RUN apk add --no-cache curl && \
    apk add --no-cache jq

ENV QBITTORRENT_WEBUI_HOST=127.0.0.1 \
    QBITTORRENT_WEBUI_PORT=8080 \
    QBITTORRENT_WEBUI_USERNAME=admin \
    QBITTORRENT_WEBUI_PASSWORD=adminadmin \
    GLUETUN_CONTROL_HOST=127.0.0.1\
    GLUETUN_CONTROL_PORT=8000 \
    INITIAL_DELAY_SEC=10 \
    CHECK_INTERVAL_SEC=60 \
    ERROR_INTERVAL_SEC=5 \
    ERROR_INTERVAL_COUNT=5

CMD ["/bin/sh", "config/port-update.sh"]

Within my docker compose file, I use the following to create the container:

###########################################################################
###########################################################################
##
##  Docker Compose File: qBittorrent-port-update
##  Function: Update qBittorent port from Gluetun
##
##  Documentation: Self Created
##
###########################################################################
###########################################################################
  qbittorrent-port-update:
    #image: qbittorrent-port-update
    build: 
      dockerfile: ./qbittorrent-port-update/df-qbittorrent-port-update
    container_name: qbittorrent-port-update
    restart: unless-stopped
    volumes:
      - ${FOLDER_FOR_CONFIGS:?err}/qbittorrent-port-update:/config
    environment:
      - PUID=${PUID:?err}
      - PGID=${PGID:?err}
      - UMASK=${UMASK:?err}
      - TZ=${TIMEZONE:?err}
      - QBITTORRENT_WEBUI_HOST=${LOCAL_DOCKER_IP:?err}
      - QBITTORRENT_WEBUI_PORT=${WEBUI_PORT_QBITTORRENT:?err}
      - GLUETUN_CONTROL_HOST=${LOCAL_DOCKER_IP:?err}
      - GLUETUN_CONTROL_PORT=${GLUETUN_CONTROL_PORT:?err}
      - INITIAL_DELAY_SEC=${INITIAL_DELAY_SEC:?err}
      - CHECK_INTERVAL_SEC=${CHECK_INTERVAL_SEC:?err}
      - ERROR_INTERVAL_SEC=${ERROR_INTERVAL_SEC:?err}
      - ERROR_INTERVAL_COUNT=${ERROR_INTERVAL_COUNT:?err}
    network_mode: "service:gluetun"

And I'm passing these variables via my env file:

#QBIT-PORT-UPDATE 

GLUETUN_CONTROL_PORT=8000
INITIAL_DELAY_SEC=300
CHECK_INTERVAL_SEC=600
ERROR_INTERVAL_SEC=30
ERROR_INTERVAL_COUNT=10

and the script itself:

trap "echo Caught SIGTERM, exiting; exit 0" TERM

echo "Starting qbittorent-gluetun-port-update"
echo "Config:"
echo "QBITTORRENT_WEBUI_HOST=$QBITTORRENT_WEBUI_HOST"
echo "QBITTORRENT_WEBUI_PORT=$QBITTORRENT_WEBUI_PORT"
echo "QBITTORRENT_WEBUI_USERNAME=$QBITTORRENT_WEBUI_USERNAME"
CENSORED_QBITTORRENT_WEBUI_PASSWORD=$(echo $QBITTORRENT_WEBUI_PASSWORD | sed 's/./*/g')
echo "QBITTORRENT_WEBUI_PASSWORD=$CENSORED_QBITTORRENT_WEBUI_PASSWORD"
echo "GLUETUN_CONTROL_HOST=$GLUETUN_CONTROL_HOST"
echo "GLUETUN_CONTROL_PORT=$GLUETUN_CONTROL_PORT"
echo "INITIAL_DELAY_SEC=$INITIAL_DELAY_SEC"
echo "CHECK_INTERVAL_SEC=$CHECK_INTERVAL_SEC"
echo "ERROR_INTERVAL_SEC=$ERROR_INTERVAL_SEC"
echo "ERROR_INTERVAL_COUNT=$ERROR_INTERVAL_COUNT"

qbittorrent_base_url="http://$QBITTORRENT_WEBUI_HOST:$QBITTORRENT_WEBUI_PORT"
gluetun_base_url="http://$GLUETUN_CONTROL_HOST:$GLUETUN_CONTROL_PORT"

current_port="0"
new_port=$current_port

error_count=0

echo "Waiting $INITIAL_DELAY_SEC seconds for initial delay"
sleep $INITIAL_DELAY_SEC &
wait $!

while :
do
    if [ $error_count -ge $ERROR_INTERVAL_COUNT ]; then
        echo "Reached maximum error count ($error_count), sleeping for $CHECK_INTERVAL_SEC sec"
        sleep $CHECK_INTERVAL_SEC &
        wait $!
        error_count=0
    fi

    echo "Checking port..."
    new_port=$(curl $gluetun_base_url/v1/openvpn/portforwarded 2> /dev/null | jq .port)
    echo "Received: $new_port"

    if [ -z "$new_port" ] || [ "$new_port" = "0" ]; then
        echo "Error: New port is empty or 0"
        error_count=$((error_count+1))
        echo "Restarting Gluetun..."
        curl -X PUT -H "Content-Type: application/json" -d '{"status":"stopped"}' "$gluetun_base_url/v1/openvpn/status"
        echo "Sleeping for $INITIAL_DELAY_SEC sec"
        sleep $INITIAL_DELAY_SEC &
        wait $!
        continue
    fi

    if [ "$new_port" = "$current_port" ]; then
        echo "New port is the same as current port, nothing to do"
        sleep $CHECK_INTERVAL_SEC &
        wait $!
        continue
    fi

    echo "Updating port..."

    echo "Logging into qBittorrent WebUI"
    login_data="username=$QBITTORRENT_WEBUI_USERNAME&password=$QBITTORRENT_WEBUI_PASSWORD"
    login_url="$qbittorrent_base_url/api/v2/auth/login"
    find_cookie="/set-cookie/ {print substr(\$2, 1, length(\$2)-1)}"
    cookie=$(curl -i --data "$login_data" $login_url 2> /dev/null | awk -e "$find_cookie")

    if [ -z "$cookie" ]; then
        echo "Failed to login to qBittorrent WebUI at $login_url"
        error_count=$((error_count+1))
        sleep $ERROR_INTERVAL_SEC &
        wait $!
        continue
    fi

    echo "Sending new port to qBittorrent WebUI"
    set_preferences_url="$qbittorrent_base_url/api/v2/app/setPreferences"
    curl $set_preferences_url --cookie "$cookie" -d "json={\"listen_port\":$new_port}" 2> /dev/null

    echo "Confirming new port"
    get_preferences_url="$qbittorrent_base_url/api/v2/app/preferences"
    confirm_port=$(curl $get_preferences_url --cookie "$cookie" 2> /dev/null | jq .listen_port)

    echo "Logging out"
    curl -X POST $qbittorrent_base_url/api/v2/auth/logout --cookie "$cookie" 2> /dev/null

    if [ "$confirm_port" != "$new_port" ]; then
        echo "Failed updating port"
        error_count=$((error_count+1))
        sleep $ERROR_INTERVAL_SEC &
        wait $!
        continue
    fi

    echo "Successfully updated port"

    current_port=$new_port

    sleep $CHECK_INTERVAL_SEC &
    wait $!
done

Hope this helps!

@SnoringDragon
Copy link

@Blinky-Lights
I have a similar project hosted here that also has a docker image available to simplify the process if people would like to utilize it.

Side note: I like your idea to provide users the option to customize refresh rates. Would you be okay with my repressing that within my project?

@Blinky-Lights
Copy link

@SnoringDragon By all means, please feel free. Nice work on your project by the way!

@notDavid
Copy link

I currently have this set up with a scheduled cat command in my rtorrent.rc and it works fine :)

Hey @FlorentLM , would you be so kind to share the relevant lines in your rtorrent.rc ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.