qdm12 / gluetun

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.
https://hub.docker.com/r/qmcgaw/gluetun
MIT License
8.04k stars 372 forks source link

Can't start container with Mullvad VPN #252

Closed beechfuzz closed 4 years ago

beechfuzz commented 4 years ago

TLDR: Added --sysctl net.ipv6.conf.all.disable_ipv6=0 to my docker run command, but it throws an error

1. Is this urgent?

- [ ] Yes
- [x] No

2. What VPN service provider are you using?

- [x] Mullvad

3. What's the version of the program?

`Running version latest built on 2020-09-18T19:52:57Z (commit 564d9cb)`

4. What are you using to run the container?

- [x] Docker run

5. Command:

2 commands -- 1 with --sysctl net.ipv6.conf.all.disable_ipv6=0 and one without that.

docker run -d --name="gluetun" \
    --volume /opt/docker/volumes/gluetun:/gluetun \
    --cap-add=NET_ADMIN \
    --env VPNSP="mullvad" \
    --env USER="<masked>" \
    --env COUNTRY="USA" \
    --env CITY="Dallas, TX" \
    --env PORT_FORWARDING="on" \
    --env PORT_FORWARDING_STATUS_FILE="/gluetun/forwarded_port" \
    --sysctl net.ipv6.conf.all.disable_ipv6=0 \
    qmcgaw/private-internet-access

6. Extra information

Logs for the command with --sysctl net.ipv6.conf.all.disable_ipv6=0:

root@server:~# docker run -d --name="gluetun" \
>     --volume /opt/docker/volumes/gluetun:/gluetun \
>     --cap-add=NET_ADMIN \
>     --env VPNSP="mullvad" \
>     --env USER="<masked>" \
>     --env COUNTRY="USA" \
>     --env CITY="Dallas, TX" \
>     --env PORT_FORWARDING="on" \
>     --env PORT_FORWARDING_STATUS_FILE="/gluetun/forwarded_port" \
>     --sysctl net.ipv6.conf.all.disable_ipv6=0 \
>     qmcgaw/private-internet-access
a1ea4f148dff67414510110f8ddcc3c602c904e767c2d04289f9a17abf2a0663
docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"write sysctl key net.ipv6.conf.all.disable_ipv6: open /proc/sys/net/ipv6/conf/all/disable_ipv6: no such file or directory\"": unknown.

Logs for the command without --sysctl net.ipv6.conf.all.disable_ipv6=0:

root@server:~# docker logs gluetun
=========================================
================ Gluetun ================
=========================================
==== A mix of OpenVPN, DNS over TLS, ====
======= Shadowsocks and Tinyproxy =======
========= all glued up with Go ==========
=========================================
=========== For tunneling to ============
======== your favorite VPN server =======
=========================================
=== Made with ā¤ļø  by github.com/qdm12 ====
=========================================

Running version latest built on 2020-09-18T19:52:57Z (commit 564d9cb)

šŸ“£  Update servers information see https://github.com/qdm12/gluetun/wiki/Update-servers-information

šŸ”§  Need help? https://github.com/qdm12/gluetun/issues/new
šŸ’»  Email? quentin.mcgaw@gmail.com
ā˜•  Slack? Join from the Slack button on Github
šŸ’ø  Help me? https://github.com/sponsors/qdm12
2020-09-24T14:31:34.745Z        INFO    IPtables version: v1.8.4
2020-09-24T14:31:34.762Z        INFO    TinyProxy version: 1.10.0
2020-09-24T14:31:34.764Z        INFO    OpenVPN version: 2.4.9
2020-09-24T14:31:34.765Z        INFO    Unbound version: 1.10.1
2020-09-24T14:31:34.766Z        INFO    Settings summary below:
OpenVPN settings:
|--User: [redacted]
|--Password: [redacted]
|--Verbosity level: 1
|--Run as root: no
|--Mullvad settings:
 |--Network protocol: udp
 |--Country: usa
 |--City: dallas, tx
 |--ISP:
 |--Custom port:
System settings:
|--User ID: 1000
|--Group ID: 1000
|--Timezone:
|--IP Status filepath: /tmp/gluetun/ip
DNS over TLS settings:
 |--DNS over TLS provider:
  |--cloudflare
 |--Caching: enabled
 |--Block malicious: enabled
 |--Block surveillance: disabled
 |--Block ads: disabled
 |--Allowed hostnames:
  |--
 |--Private addresses:
  |--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:0:0/96
 |--Verbosity level: 1/5
 |--Verbosity details level: 0/4
 |--Validation log level: 0/2
 |--IPv6 resolution: disabled
 |--Update: every 24h0m0s
 |--Keep nameserver (disabled blocking): no
Firewall settings:
 |--Allowed subnets:
 |--VPN input ports:
TinyProxy settings: disabled
ShadowSocks settings: disabled
Public IP check period: 12h0m0s
Version information: enabled
Updater: disabled

2020-09-24T14:31:34.800Z        INFO    storage: Merging by most recent 6387 hardcoded servers and 6387 servers read from /gluetun/servers.json
2020-09-24T14:31:34.827Z        INFO    routing: default route found: interface eth0, gateway 172.17.0.1
2020-09-24T14:31:34.827Z        INFO    routing: local subnet found: 172.17.0.0/16
2020-09-24T14:31:34.827Z        INFO    openvpn configurator: checking for device /dev/net/tun
2020-09-24T14:31:34.827Z        WARN    TUN device is not available: open /dev/net/tun: no such file or directory
2020-09-24T14:31:34.827Z        INFO    openvpn configurator: creating /dev/net/tun
2020-09-24T14:31:34.827Z        INFO    firewall: enabling...
2020-09-24T14:31:34.838Z        INFO    firewall: enabled successfully
2020-09-24T14:31:34.838Z        INFO    firewall: setting allowed subnets through firewall...
2020-09-24T14:31:34.838Z        INFO    http server: listening on 0.0.0.0:8000
2020-09-24T14:31:34.838Z        INFO    Launching standard output merger
2020-09-24T14:31:34.838Z        INFO    dns over tls: falling back on plaintext DNS at address 1.1.1.1
2020-09-24T14:31:34.838Z        INFO    dns configurator: using DNS address 1.1.1.1 internally
2020-09-24T14:31:34.838Z        INFO    dns configurator: using DNS address 1.1.1.1 system wide
2020-09-24T14:31:34.839Z        INFO    firewall: setting VPN connections through firewall...
2020-09-24T14:31:34.870Z        INFO    openvpn configurator: starting openvpn
2020-09-24T14:31:34.871Z        INFO    openvpn: Thu Sep 24 14:31:34 2020 Note: option tun-ipv6 is ignored because modern operating systems do not need special IPv6 tun handling anymore.
2020-09-24T14:31:34.872Z        INFO    openvpn: OpenVPN 2.4.9 x86_64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Apr 20 2020
2020-09-24T14:31:34.872Z        INFO    openvpn: library versions: OpenSSL 1.1.1g  21 Apr 2020, LZO 2.10
2020-09-24T14:31:34.874Z        INFO    openvpn: TCP/UDP: Preserving recently used remote address: [AF_INET]174.127.113.5:1194
2020-09-24T14:31:34.874Z        INFO    openvpn: UDP link local: (not bound)
2020-09-24T14:31:34.874Z        INFO    openvpn: UDP link remote: [AF_INET]174.127.113.5:1194
2020-09-24T14:31:34.930Z        WARN    openvpn: 'link-mtu' is used inconsistently, local='link-mtu 1557', remote='link-mtu 1558'
2020-09-24T14:31:34.930Z        WARN    openvpn: 'comp-lzo' is present in remote config but missing in local config, remote='comp-lzo'
2020-09-24T14:31:34.930Z        INFO    openvpn: [us-dal-103.mullvad.net] Peer Connection Initiated with [AF_INET]174.127.113.5:1194
2020-09-24T14:31:46.395Z        INFO    openvpn: setsockopt TCP_NODELAY=1 failed
2020-09-24T14:31:46.395Z        INFO    openvpn: GDG6: NLMSG_ERROR: error Not supported
2020-09-24T14:31:46.395Z        INFO    openvpn:
2020-09-24T14:31:46.396Z        INFO    openvpn: TUN/TAP device tun0 opened
2020-09-24T14:31:46.396Z        INFO    openvpn: /sbin/ip link set dev tun0 up mtu 1500
2020-09-24T14:31:46.397Z        INFO    openvpn: /sbin/ip addr add dev tun0 10.8.0.5/16 broadcast 10.8.255.255
2020-09-24T14:31:46.397Z        INFO    openvpn: /sbin/ip -6 addr add fdda:d0d0:cafe:1194::1003/64 dev tun0
2020-09-24T14:31:46.398Z        INFO    openvpn: Linux ip -6 addr add failed: external program exited with error status: 2
2020-09-24T14:31:46.398Z        INFO    openvpn: Exiting due to fatal error
2020-09-24T14:31:46.434Z        ERROR   openvpn: exit status 1
2020-09-24T14:31:46.434Z        WARN    close |0: file already closed
2020-09-24T14:31:46.434Z        INFO    openvpn: retrying in 30 seconds

Host OS:

root@server:~# cat /etc/*elease
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION="Ubuntu 20.04.1 LTS"
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
qdm12 commented 4 years ago

Hello thanks for reporting the issue. I'm on Mullvad too so I hope I can assist you better. Anyway, searching for your error, I just found an openvpn config line to add to ignore all the ipv6 rules Mullvad pushes. I'll add at noon (in 2hrs) and you could then try without that ipv6 disabled docker config as well. It should make it work. šŸ‘ Will comment back once it's up.

qdm12 commented 4 years ago

Can you please try with the image qmcgaw/private-internet-access:mullvad-disable-ipv6 and see if it works without the Docker ipv6 configuration line? If it does, I'll merge that in the latest docker image. Thanks in advance!

beechfuzz commented 4 years ago

That works!

One final question (totally unrelated): When do you think wireguard will be implemented (if at all)? Not trying to be a choosing beggar, just curious cuz I'm excited to try it with this.

qdm12 commented 4 years ago

Actually that works but doesn't tunnel ipv6, which, let's face it, barely anyone uses, but still.

If your Docker is setup to use ipv6 (again, barely anyone uses that), then it is actually useful. I'll modify the code further to allow people to specify to tunnel Ipv6 for Mullvad (which, by the way, is the only provider to tunnel ipv6)... Anyway very niche but required case šŸ˜…

I quite like Wireguard too, I'm using it as my vpn server of choice. But back then, none of the providers supported it. There is an implementation in Go out there which I could plug in somehow. It is feasible, just a lot of changes to make as it's different IPs, ports, each provider has their own custom steps etc. I definitely have it stored at the back of my head, but I'd say at least 2-3 months (unless I get fired, then days šŸ˜„).

qdm12 commented 4 years ago

Hello again, I pushed the changes I was talking about.

HOWEVER, researching your issue a bit more, can you please run on your host:

ls /proc/sys/net/ipv6/conf/all/ | grep ipv6

On mine it returns disable_ipv6, but yours might be disable. If so, you should be able to run with

docker run -d --name="gluetun" \
    --volume /opt/docker/volumes/gluetun:/gluetun \
    --cap-add=NET_ADMIN \
    --env VPNSP="mullvad" \
    --env USER="<masked>" \
    --env COUNTRY="USA" \
    --env CITY="Dallas, TX" \
    --env PORT_FORWARDING="on" \
    --env PORT_FORWARDING_STATUS_FILE="/gluetun/forwarded_port" \
    --sysctl net.ipv6.conf.all.disable=0 \
    qmcgaw/private-internet-access

Let me know so that I can update the Wiki. I'll add that PR on ipv6 anyway to remove the need for that Docker run flag. Thanks!

beechfuzz commented 4 years ago
root@server:~# ls /proc/sys/net/ipv6/conf/all | grep ipv6
ls: cannot access '/proc/sys/net/ipv6/conf/all': No such file or directory

I had actually tried the --sysctl net.ipv6.conf.all.disable=0 option before, but the container threw an error at me:

docker: Error response from daemon: OCI runtime create failed: container_linux.go:349: starting container process caused "process_linux.go:449: container init caused \"write sysctl key net.ipv6.conf.all.disable_ipv6: open /proc/sys/net/ipv6/conf/all/disable_ipv6: no such file or directory\"": unknown.
qdm12 commented 4 years ago

Hm, what do you get with ls /proc/sys/net/? Maybe ipv6 is just not in your OS/kernel šŸ¤”

I get

bridge/  core/  ipv4/  ipv6/  mptcp/  netfilter/  nf_conntrack_max  unix/
6RASi commented 4 years ago

I'm trying to get this to work with my Mullvad docker-compose.yml but I'm getting a similar error to the original when I try to run it through Portainer

http error: Error response from daemon: OCI runtime create failed: container_linux.go:341: creating new parent process caused "container_linux.go:1923: running lstat on namespace path \"/proc/25893/ns/net\" caused \"lstat /proc/25893/ns/net: no such file or directory\"": unknown (err=Error response from daemon: OCI runtime create failed: container_linux.go:341: creating new parent process caused "container_linux.go:1923: running lstat on namespace path \"/proc/25893/ns/net\" caused \"lstat /proc/25893/ns/net: no such file or directory\"": unknown) (code=500)

My PIA docker-compose is working fine

beechfuzz commented 4 years ago

Hm, what do you get with ls /proc/sys/net/? Maybe ipv6 is just not in your OS/kernel šŸ¤”

I get

bridge/  core/  ipv4/  ipv6/  mptcp/  netfilter/  nf_conntrack_max  unix/
root@server:~# ls -al /proc/sys/net/
total 0
dr-xr-xr-x 1 root root 0 Sep 24 13:31 .
dr-xr-xr-x 1 root root 0 Sep 23 06:19 ..
dr-xr-xr-x 1 root root 0 Sep 24 13:31 bridge
dr-xr-xr-x 1 root root 0 Sep 24 16:16 core
dr-xr-xr-x 1 root root 0 Sep 24 13:31 ipv4
dr-xr-xr-x 1 root root 0 Sep 24 22:49 netfilter
-rw-r--r-- 1 root root 0 Sep 24 22:49 nf_conntrack_max
dr-xr-xr-x 1 root root 0 Sep 24 22:49 unix
qdm12 commented 4 years ago

Alright that makes sense. Most likely you just don't have ipv6 in your Kernel. If you feel curious, you can follow these steps.

Anyway, I'll merge the pull request in latest so you should be able to run it without that ipv6 docker config line.

beechfuzz commented 4 years ago

You're the man! Thanks for being responsive and all your effort. Enjoy a beer on me (not literally -- that would be weird).

qdm12 commented 4 years ago

@beechfuzz Cheers for the monthly beer! I'm in the process of reworking the Wiki and will merge my pull request when I'm done, that may take one more day.

@orion-LY do you mind creating another issue for your case as this seems, well, like another issue šŸ˜‰ And please share your compose configuration on that other issue (omit passwords) too.

qdm12 commented 3 years ago

Hey @beechfuzz

You might be happy with https://github.com/qdm12/gluetun/pull/565 šŸ˜‰ For now it only supports Mullvad, I'm adding more as I write this!