-
Notifications
You must be signed in to change notification settings - Fork 25
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
[RFE] - Port Forwarding #125
Comments
Last time I checked, port forwarding was only available in the Windows Desktop version. Unless it has recently changed, it is not be possible to enable it in this service. |
There are two features request for that :
|
Port forwarding works under Linux, even with an OpenVPN client ;) First of all, append Once connected to ProtonVPN networks, we should issue multiple commands:
If it's available, then we must do:
Source: https://protonvpn.com/support/port-forwarding-manual-setup/ |
I used
It seems to create a mapping. I tried to connect to it by throwing up a
Seems to also work. As does like (I actually use podman and podman-compose in the above):
|
I guess one can use any container as a |
The end result was this: I'm using it for a service I run, and it seems ok. |
@tsjk 7.3.0-alpha1 has all the tools you need to run it (though without the custom scripts from your fork). |
Sure. Let me work on it some more. The other day I realized that I really don't want this container to die and vanish (for whatever reason - I observed some fatal indexing error when metadata fails to refresh) as that will disable ALL networking in dependent containers. If the dependent containers have this and Tor via a socks port, for instance - the vpn temporarily going down is not a big problem. I'll tend to this issue first and then look at sub-commanding. I imagine looping the protonwire script with a signal handler. |
Hello guys ! Here is the important part of my docker compose : services:
protonvpn:
container_name: protonvpn
image: ghcr.io/tprasadtp/protonwire:7.3.0-alpha1
command: "sh /config/protonvpn-init.sh"
environment:
- WIREGUARD_PRIVATE_KEY=YOURKEY
- PROTONVPN_SERVER=YOURNODEURL
cap_add:
- NET_ADMIN
sysctls:
net.ipv4.conf.all.rp_filter: 2
net.ipv6.conf.all.disable_ipv6: 1
volumes:
- type: tmpfs
target: /tmp
- /local_path_to/protonvpn-port:/config/protonvpn-port
- /local_path_to/protonvpn-init.sh:/config/protonvpn-init.sh
ports:
- "yourport:yourport"
yourservice:
image: yourservice
container_name: yourservice
network_mode: service:protonvpn
volumes:
- /local_path_to/protonvpn-port:/config/protonvpn-port # Do whatever you want with this
restart: always Here is the entry script for protonvpn : /usr/bin/protonwire connect --container &
sleep 10
natpmpc -a 1 0 udp 60 -g 10.2.0.1
natpmpc -a 1 0 tcp 60 -g 10.2.0.1 | grep -oP 'public\ port\ \K\w+' > /config/protonvpn-port
echo "Port written to protonvpn-port file"
cat /config/protonvpn-port
while true ; do date ; natpmpc -a 1 0 udp 60 -g 10.2.0.1 && natpmpc -a 1 0 tcp 60 -g 10.2.0.1 || { echo -e "ERROR with natpmpc command \a" ; break ; } ; sleep 45 ; done Nothing crazy here, I start protonwire in the background, put in an arbitrary sleep because I didn't know how else I could wait for protonwire to connect successfully (there is probably a smart way to do this), and then just execute the natpmpc commands exactly like in the protonvpn documentation and extract the port number to a file on the host system via regexp. After that I just retrieve the content of the protonvpn-port file in my other container and update my application with it. Of course, if any error happens, everything goes to hell, it's a quick script for non critical applications, don't use it for anything important ! |
i'm using @le-martre's solution for a k8s deployment:
|
Hello everyone, I've made a few improvements to the scripts shared in this thread. I am using on my Docker Compose as a multi-line command for now, perhaps if it gets bigger I will transform in a script with its own file. To pass the port value to a secondary container, you can write to a shared file and use the healthcheck to control the initialization of the secondary container. In Docker Compose multi-line will be something like this;
Some details about the improvements. First of all, the option Second, instead of using the arbitrary sleep to check the connection, there is a command that we could utilize; Lastly, the logs output is cleaner and it can be easily filtered directly with the Finally, there are some corner cases that could still be improved. For example, when dealing with error control of the |
Version of
protonvpn-docker
NA
Details about Feature/Enhancement
Having the ability to connect to a port forwarding server and maybe providing an endpoint or something in the logs that prints the currently enabled forwarded port would be useful.
Here's a reference to the feature in the desktop client:
Code of Conduct & PII Redaction
The text was updated successfully, but these errors were encountered: