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

feat(privatevpn): support natively port forwarding #2285

Merged
merged 6 commits into from
Aug 16, 2024
Merged

Conversation

qdm12
Copy link
Owner

@qdm12 qdm12 commented May 18, 2024

Try with docker run -it --rm --cap-add=NET_ADMIN -e OPENVPN_USER=a -e OPENVPN_PASSWORD=b -e VPN_SERVICE_PROVIDER=privatevpn -e VPN_PORT_FORWARDING=on qmcgaw/gluetun:pr-2285

For issue #1859

  • Implemenation done
  • User feedback
  • Wiki updated

@qdm12 qdm12 changed the title Privatevpn pf 1859 feat(privatevpn): support natively port forwarding May 18, 2024
@qdm12 qdm12 marked this pull request as ready for review August 3, 2024 09:52
@teopost
Copy link

teopost commented Aug 11, 2024

Hi,
I tried running the image qmcgaw/gluetun:pr-2285.
I'm getting this error:

2024-08-11T20:10:14Z ERROR [vpn] getting VPN assigned IP address: network interface tun0 not found: route ip+net: no such network interface

this is the ful log

========================================
========================================
=============== gluetun ================
========================================
=========== Made with ❤️ by ============
======= https://github.com/qdm12 =======
========================================
========================================

Running version pr-2285 built on 2024-08-04T09:03:35.974Z (commit 85b4150)

🔧 Need help? https://github.com/qdm12/gluetun/discussions/new
🐛 Bug? https://github.com/qdm12/gluetun/issues/new
✨ New feature? https://github.com/qdm12/gluetun/issues/new
☕ Discussion? https://github.com/qdm12/gluetun/discussions/new
💻 Email? quentin.mcgaw@gmail.com
💰 Help me? https://www.paypal.me/qmcgaw https://github.com/sponsors/qdm12
2024-08-11T20:09:40Z INFO [routing] default route found: interface eth0, gateway 172.22.0.1, assigned IP 172.22.0.4 and family v4
2024-08-11T20:09:40Z INFO [routing] local ethernet link found: eth0
2024-08-11T20:09:40Z INFO [routing] local ipnet found: 172.22.0.0/16
2024-08-11T20:09:40Z INFO [firewall] enabling...
2024-08-11T20:09:40Z INFO [firewall] enabled successfully
2024-08-11T20:09:47Z INFO [storage] merging by most recent 20476 hardcoded servers and 20476 servers read from /gluetun/servers.json
2024-08-11T20:09:49Z INFO Alpine version: 3.20.2
2024-08-11T20:09:49Z INFO OpenVPN 2.5 version: 2.5.10
2024-08-11T20:09:49Z INFO OpenVPN 2.6 version: 2.6.11
2024-08-11T20:09:49Z INFO Unbound version: 1.20.0
2024-08-11T20:09:49Z INFO IPtables version: v1.8.10
2024-08-11T20:09:49Z INFO Settings summary:
├── VPN settings:
|   ├── VPN provider settings:
|   |   ├── Name: privatevpn
|   |   ├── Server selection settings:
|   |   |   ├── VPN type: openvpn
|   |   |   ├── Countries: Netherlands
|   |   |   └── OpenVPN server selection settings:
|   |   |       └── Protocol: UDP
|   |   └── Automatic port forwarding settings:
|   |       ├── Redirection listening port: disabled
|   |       ├── Use port forwarding code for current provider
|   |       ├── Forwarded port file path: /tmp/gluetun/forwarded_port
|   |       └── Credentials:
|   |           ├── Username: utente@gmail.com
|   |           └── Password: [set]
|   └── OpenVPN settings:
|       ├── OpenVPN version: 2.6
|       ├── User: [set]
|       ├── Password: [set]
|       ├── Network interface: tun0
|       ├── Run OpenVPN as: root
|       └── Verbosity level: 1
├── DNS settings:
|   ├── Keep existing nameserver(s): no
|   ├── DNS server address to use: 127.0.0.1
|   └── DNS over TLS settings:
|       ├── Enabled: yes
|       ├── Update period: every 24h0m0s
|       ├── Unbound settings:
|       |   ├── Authoritative servers:
|       |   |   └── cloudflare
|       |   ├── Caching: yes
|       |   ├── IPv6: no
|       |   ├── Verbosity level: 1
|       |   ├── Verbosity details level: 0
|       |   ├── Validation log level: 0
|       |   ├── System user: root
|       |   └── Allowed networks:
|       |       ├── 0.0.0.0/0
|       |       └── ::/0
|       └── DNS filtering settings:
|           ├── Block malicious: yes
|           ├── Block ads: no
|           ├── Block surveillance: no
|           └── Blocked IP networks:
|               ├── 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:127.0.0.1/104
|               ├── ::ffff:10.0.0.0/104
|               ├── ::ffff:169.254.0.0/112
|               ├── ::ffff:172.16.0.0/108
|               └── ::ffff:192.168.0.0/112
├── Firewall settings:
|   └── Enabled: yes
├── Log settings:
|   └── Log level: info
├── Health settings:
|   ├── Server listening address: 127.0.0.1:9999
|   ├── Target address: cloudflare.com:443
|   ├── Duration to wait after success: 5s
|   ├── Read header timeout: 100ms
|   ├── Read timeout: 500ms
|   └── VPN wait durations:
|       ├── Initial duration: 6s
|       └── Additional duration: 5s
├── Shadowsocks server settings:
|   └── Enabled: no
├── HTTP proxy settings:
|   ├── Enabled: yes
|   ├── Listening address: :8888
|   ├── User:
|   ├── Password: [not set]
|   ├── Stealth mode: no
|   ├── Log: no
|   ├── Read header timeout: 1s
|   └── Read timeout: 3s
├── Control server settings:
|   ├── Listening address: :8000
|   └── Logging: yes
├── OS Alpine settings:
|   ├── Process UID: 1000
|   └── Process GID: 1000
├── Public IP settings:
|   ├── Fetching: every 12h0m0s
|   ├── IP file path: /tmp/gluetun/ip
|   └── Public IP data API: ipinfo
└── Version settings:
    └── Enabled: yes

2024-08-11T20:09:49Z INFO [routing] default route found: interface eth0, gateway 172.22.0.1, assigned IP 172.22.0.4 and family v4
2024-08-11T20:09:49Z INFO [routing] adding route for 0.0.0.0/0
2024-08-11T20:09:49Z INFO [firewall] setting allowed subnets...
2024-08-11T20:09:49Z INFO [routing] default route found: interface eth0, gateway 172.22.0.1, assigned IP 172.22.0.4 and family v4
2024-08-11T20:09:49Z INFO [dns] using plaintext DNS at address 1.1.1.1
2024-08-11T20:09:49Z INFO [http proxy] listening on :8888
2024-08-11T20:09:49Z INFO [http server] http server listening on [::]:8000
2024-08-11T20:09:49Z INFO [firewall] allowing VPN connection...
2024-08-11T20:09:49Z INFO [healthcheck] listening on 127.0.0.1:9999
2024-08-11T20:09:49Z INFO [openvpn] OpenVPN 2.6.11 aarch64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD]
2024-08-11T20:09:49Z INFO [openvpn] library versions: OpenSSL 3.3.1 4 Jun 2024, LZO 2.10
2024-08-11T20:09:49Z INFO [openvpn] TCP/UDP: Preserving recently used remote address: [AF_INET]193.180.119.196:1194
2024-08-11T20:09:49Z INFO [openvpn] UDPv4 link local: (not bound)
2024-08-11T20:09:49Z INFO [openvpn] UDPv4 link remote: [AF_INET]193.180.119.196:1194
2024-08-11T20:09:49Z INFO [openvpn] [PrivateVPN] Peer Connection Initiated with [AF_INET]193.180.119.196:1194
2024-08-11T20:09:50Z INFO [openvpn] TUN/TAP device tun0 opened
2024-08-11T20:09:50Z INFO [openvpn] /sbin/ip link set dev tun0 up mtu 1500
2024-08-11T20:09:51Z INFO [openvpn] /sbin/ip link set dev tun0 up
2024-08-11T20:09:51Z INFO [openvpn] /sbin/ip addr add dev tun0 10.35.14.63/23
2024-08-11T20:09:51Z INFO [openvpn] UID set to nonrootuser
2024-08-11T20:09:51Z INFO [openvpn] Initialization Sequence Completed
2024-08-11T20:09:51Z INFO [dns] downloading DNS over TLS cryptographic files
2024-08-11T20:09:51Z INFO [healthcheck] healthy!
2024-08-11T20:09:52Z INFO [dns] downloading hostnames and IP block lists
2024-08-11T20:10:14Z INFO [healthcheck] program has been unhealthy for 6s: restarting VPN
2024-08-11T20:10:14Z INFO [healthcheck] 👉 See https://github.com/qdm12/gluetun-wiki/blob/main/faq/healthcheck.md
2024-08-11T20:10:14Z INFO [healthcheck] DO NOT OPEN AN ISSUE UNLESS YOU READ AND TRIED EACH POSSIBLE SOLUTION
2024-08-11T20:10:14Z INFO [vpn] stopping
2024-08-11T20:10:14Z ERROR [vpn] getting public IP address information: fetching information: Get "https://ipinfo.io/": context canceled
2024-08-11T20:10:14Z ERROR [vpn] cannot get version information: Get "https://api.github.com/repos/qdm12/gluetun/releases": context canceled
2024-08-11T20:10:14Z INFO [port forwarding] starting
2024-08-11T20:10:14Z ERROR [vpn] getting VPN assigned IP address: network interface tun0 not found: route ip+net: no such network interface
2024-08-11T20:10:14Z INFO [vpn] starting
2024-08-11T20:10:14Z INFO [firewall] allowing VPN connection...
2024-08-11T20:10:15Z INFO [openvpn] OpenVPN 2.6.11 aarch64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD]
2024-08-11T20:10:15Z INFO [openvpn] library versions: OpenSSL 3.3.1 4 Jun 2024, LZO 2.10
2024-08-11T20:10:15Z INFO [openvpn] TCP/UDP: Preserving recently used remote address: [AF_INET]193.180.119.196:1194
2024-08-11T20:10:15Z INFO [openvpn] UDPv4 link local: (not bound)
2024-08-11T20:10:15Z INFO [openvpn] UDPv4 link remote: [AF_INET]193.180.119.196:1194
2024-08-11T20:10:15Z INFO [openvpn] [PrivateVPN] Peer Connection Initiated with [AF_INET]193.180.119.196:1194
2024-08-11T20:10:16Z INFO [openvpn] TUN/TAP device tun0 opened
2024-08-11T20:10:16Z INFO [openvpn] /sbin/ip link set dev tun0 up mtu 1500
2024-08-11T20:10:16Z INFO [openvpn] /sbin/ip link set dev tun0 up
2024-08-11T20:10:16Z INFO [openvpn] /sbin/ip addr add dev tun0 10.35.14.69/23
2024-08-11T20:10:16Z ERROR [openvpn] OpenVPN tried to add an IP route which already exists (RTNETLINK answers: File exists)
2024-08-11T20:10:16Z WARN [openvpn] Previous error details: Linux route add command failed: external program exited with error status: 2
2024-08-11T20:10:16Z ERROR [openvpn] Linux route add command failed
2024-08-11T20:10:16Z INFO [openvpn] UID set to nonrootuser
2024-08-11T20:10:16Z INFO [openvpn] Initialization Sequence Completed
2024-08-11T20:10:25Z INFO [dns] init module 0: validator
2024-08-11T20:10:25Z INFO [dns] init module 1: iterator
2024-08-11T20:10:25Z INFO [dns] start of service (unbound 1.20.0).
2024-08-11T20:10:25Z INFO [dns] generate keytag query _ta-4a5c-4f66-9728. NULL IN
2024-08-11T20:10:25Z INFO [dns] generate keytag query _ta-4a5c-4f66-9728. NULL IN
2024-08-11T20:10:26Z INFO [healthcheck] healthy!
2024-08-11T20:10:26Z INFO [ip getter] Public IP address is 80.239.140.196 (Netherlands, North Holland, Amsterdam)
2024-08-11T20:10:26Z INFO [port forwarding] starting
2024-08-11T20:10:26Z ERROR [vpn] port forwarding for the first time: custom port forwarding obtention is not supported: for privatevpn
2024-08-11T20:10:26Z INFO [dns] ready

and this is a portion of my compose file

services:
  gluetun:
    image: qmcgaw/gluetun:pr-2285
#    image: qmcgaw/gluetun:latest
    container_name: gluetun
    cap_add:
      - NET_ADMIN
    ports:
      - 8091:8000/tcp 
      - 8888:8888/tcp # HTTP proxy
      - 8388:8388/tcp # Shadowsocks
      - 8388:8388/udp # Shadowsocks
      - "0.0.0.0:9091:9091/tcp"  # transmission
      - 51413:51413/tcp          # transmission
      - 51413:51413/udp          # transmission
    volumes:
      - ./configs/gluetun-config:/gluetun
    devices:
      - /dev/net/tun:/dev/net/tun
    environment:
      - HTTPPROXY=on
      - VPN_SERVICE_PROVIDER=privatevpn
      - VPN_PORT_FORWARDING=on
      - OPENVPN_USER=<username>
      - OPENVPN_PASSWORD=<password>
      - SERVER_COUNTRIES=Netherlands

    restart: unless-stopped
    networks:
      - internal

@qdm12
Copy link
Owner Author

qdm12 commented Aug 16, 2024

Fixed! Please try pulling the image 😉

ERROR [vpn] getting VPN assigned IP address: network interface tun0 not found was due to just the VPN being torn down due to being unhealthy (vpn] stopping). The real error that got fixed was ERROR [vpn] port forwarding for the first time: custom port forwarding obtention is not supported: for privatevpn. This was a simple bug due to me updating this branch on top of the master branch where code was changed to support multiple forwarded ports, but the privatevpn was still on the single-port support, so that was the mismatch fixed in 5d3526c

@qdm12 qdm12 merged commit 11c2354 into master Aug 16, 2024
7 checks passed
@qdm12 qdm12 deleted the privatevpn-pf-1859 branch August 16, 2024 12:20
@varac
Copy link

varac commented Aug 31, 2024

Should this also work for wireguard ?
I'm getting

...
INFO [port forwarding] starting
ERROR [vpn] starting port forwarding service: port forwarding for the first time: port forwarding not supported for this VPN server     

Using qmcgaw/gluetun:latest(I tried :2285 as well) and:

      VPN_PORT_FORWARDING: "on"
      VPN_PORT_FORWARDING_PROVIDER: privatevpn

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

Successfully merging this pull request may close these issues.

3 participants