kylemanna /docker-openvpn
🔒 OpenVPN server in a Docker container complete with an EasyRSA PKI CA
★ 9,088⑂ 2,408👁 149⑃ 232● 557▤ 2
+0
日增长
9,088
stars
2,408
forks
149
watchers
232
prs
557
issues
2
releases
README
OpenVPN for Docker
OpenVPN server in a Docker container complete with an EasyRSA PKI CA.
Extensively tested on Digital Ocean $5/mo node and has
a corresponding Digital Ocean Community Tutorial.
Upstream Links
Docker Registry @ kylemanna/openvpn
GitHub @ kylemanna/docker-openvpn
Quick Start
Pick a name for the $OVPN_DATA data volume container. It's recommended to
use the ovpn-data- prefix to operate seamlessly with the reference systemd
service. Users are encourage to replace example with a descriptive name of
their choosing.
OVPN_DATA="ovpn-data-example"
Initialize the $OVPN_DATA container that will hold the configuration files
and certificates. The container will prompt for a passphrase to protect the
private key used by the newly generated certificate authority.
docker volume create --name $OVPN_DATA
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_genconfig -u udp://VPN.SERVERNAME.COM
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn ovpn_initpki
Start OpenVPN server process
docker run -v $OVPN_DATA:/etc/openvpn -d -p 1194:1194/udp --cap-add=NET_ADMIN kylemanna/openvpn
Generate a client certificate without a passphrase
docker run -v $OVPN_DATA:/etc/openvpn --rm -it kylemanna/openvpn easyrsa build-client-full CLIENTNAME nopass
Retrieve the client configuration with embedded certificates
docker run -v $OVPN_DATA:/etc/openvpn --rm kylemanna/openvpn ovpn_getclient CLIENTNAME CLIENTNAME.ovpn
Next Steps
More Reading
Miscellaneous write-ups for advanced configurations are available in the
docs folder.
Systemd Init Scripts
A systemd init script is available to manage the OpenVPN container. It will
start the container on system boot, restart the container if it exits
unexpectedly, and pull updates from Docker Hub to keep itself up to date.
Please refer to the systemd documentation to learn more.
Docker Compose
If you prefer to use docker-compose please refer to the documentation.
Debugging Tips
Create an environment variable with the name DEBUG and value of 1 to enable debug output (using "docker -e").
docker run -v $OVPN_DATA:/etc/openvpn -p 1194:1194/udp --cap-add=NET_ADMIN -e DEBUG=1 kylemanna/openvpn
Test using a client that has openvpn installed correctly
$ openvpn --config CLIENTNAME.ovpn
Run through a barrage of debugging checks on the client if things don't just work
$ ping 8.8.8.8 checks connectivity without touching name resolution
$ dig google.com won't use the search directives in resolv.conf
$ nslookup google.com will use search
Consider setting up a systemd service for automatic
start-up at boot time and restart in the event the OpenVPN daemon or Docker
crashes.
How Does It Work?
Initialize the volume container using the kylemanna/openvpn image with the
included scripts to automatically generate:
- Diffie-Hellman parameters
- a private key
- aTop issues
#381Client connected but no internet30 comments · 2018-04-29#101Auto CRL check20 comments · 2016-01-29#288All Traffic Going Through VPN 18 comments · 2017-06-30#272TOTP auth accepts code from any TOTP-user18 comments · 2017-05-30#20IPv6 support16 comments · 2014-12-08#1Add/Test ECDSA support16 comments · 2014-06-05#182Other docker-container in VPN-network15 comments · 2016-11-25#605Error in ovpn_initpki step14 comments · 2020-09-17
Latest release
Alpine 3.2 Release v2.0.0 2016-05-08First Alpine Linux release.