You can use an Openvpn configuration file instead of using the built in providers.
- There is some implicit behavior that you should be aware of.
- If you encounter any issue, please first open a discussion and then, if it's a valid issue, open an issue.
- My support will be limited from my part as I can't help everyone with VPN providers or private VPN servers I am not familiar with.
- If you want a smooth experience, create an issue to support a new provider, it usually takes 2 to 4 weeks to implement it.
In the following we assume your custom openvpn configuration file is named custom.conf
. Note this can be named something else, for example autralia.ovpn
.
-
Replace the VPN server hostname by one of its IP addresses. In
custom.conf
, find the line starting withremote
. The second field is the VPN server hostname. If it is not an IP address, you need to DNS resolve it, for example withnslookup domain.com
and replace the hostname field with one of its corresponding IP addresses. This is the case as gluetun's firewall is designed not to leak anything including an initial DNS resolution when starting. -
Bind mount your
custom.conf
file to/gluetun/custom.conf
. If you have other files such asca.crt
orup.sh
, bind mount them to/gluetun/
as well. -
If you have other files referenced in your
custom.conf
such asca ca.crt
orup up.sh
, change the paths to be absolute such asca /gluetun/ca.crt
andup /gluetun/up.sh
. This is because your configuration filecustom.conf
is read, parsed, modified and written somewhere else at runtime. -
Set the environment variables:
VPN_SERVICE_PROVIDER=custom
OPENVPN_CUSTOM_CONFIG=/gluetun/custom.conf
-
The environment variables
OPENVPN_USER
andOPENVPN_PASSWORD
are not enforced but should be set if you use authentication. -
Run the container for example with:
docker run -it --rm --cap-add=NET_ADMIN --device /dev/net/tun -e VPN_SERVICE_PROVIDER=custom -e OPENVPN_CUSTOM_CONFIG=/gluetun/custom.conf -v /yourpath/custom.conf:/gluetun/custom.conf:ro -e OPENVPN_USER="youruser" -e OPENVPN_PASSWORD="yourpassword" qmcgaw/gluetun
Files referenced in your OpenVPN configuration file as relative file paths will not work.
This is because your configuration file is read, parsed, modified and rewritten to /etc/openvpn/target.ovpn
(subject to change). You could however adapt these file paths to match that directory, or use absolute paths.
If you have multiple remote
instructions, only the first one is taken into account.
Gluetun adds or overrides the following options:
mute-replay-warnings
suppress-timestamps
auth-nocache
auth-retry nointeract
auth-user-pass /etc/openvpn/auth.conf
pull-filter ignore "auth-token"
-
OPENVPN_VERBOSITY
defaults to1
and adds or overrides theverb
option. -
VPN_INTERFACE
defaults totun0
and adds or overrides thedev
option. -
If
OPENVPN_PROCESS_USER=root
(default), theuser
options is removed so OpenVPN runs as root. Otherwise,user ${OPENVPN_PROCESS_USER}
option is added or overridden. -
If IPv6 is not supported, the following options are added:
pull-filter ignore "route-ipv6" pull-filter ignore "ifconfig-ipv6"
And the
tun-ipv6
option is removed.
OPENVPN_CIPHERS
, if set, adds or overridesdata-ciphers
anddata-ciphers-fallback
OPENVPN_AUTH
, if set, adds or overridesauth
.OPENVPN_MSSFIX
, if set, adds or overridesmssfix
.OPENVPN_ENDPOINT_PORT
, if set, overrides the port of the remote connection found in the file.
The following OpenVPN environment variables have no effect:
OPENVPN_PROTOCOL
- the protocol is determined from your configuration file only.OPENVPN_CLIENTKEY_SECRETFILE
OPENVPN_CLIENTCRT_SECRETFILE
OPENVPN_ENCRYPTED_KEY_SECRETFILE
OPENVPN_KEY_PASSHPRASE_SECRETFILE
OPENVPN_ENDPOINT_IP