OpenVPN Docker
In this blog post, we are going to discuss how to install and run an OpenVPN docker container.
Clone Github Docker repo written by Kylemanna.
git clone https://github.com/kylemanna/docker-openvpn.git
Now Build the Docker image
cd docker-openvpn/
docker build -t myownvpn .
Now create a folder to store your configuration files.
cd ..
mkdir vpn-data
Now Generate OpenVPN config file.
docker run -v $PWD/vpn-data:/etc/openvpn --rm myownvpn ovpn_genconfig -u udp://SERVER_IP_ADDRESS:ANY_CUSTOM_PORT
example lets say your port is 20000.
Initialize your private key
docker run -v $PWD/vpn-data:/etc/openvpn --rm -it myownvpn ovpn_initpki
Enter name and password as asked via CLI
Run the VPN Server
docker run -v $PWD/vpn-data:/etc/openvpn -d -p 20000:1194/udp --cap-add=NET_ADMIN myvpn
Create a user to interact
docker run -v $PWD/vpn-data:/etc/openvpn --rm -it myownvpn easyrsa build-client-full USER_NAME nopass
Generate a configuration file for the above user
docker run -v $PWD/vpn-data:/etc/openvpn --rm myownvpn ovpn_getclient USER_NAME > CONFIGURATION_FILE_NAME.ovpn
download the above generate file on your local system, and this *.ovpn file will be used by the client VPN software to connect with server.
Running OpenVPN client on your machine.
Next step is to download open VPN client to your client machine from https://openvpn.net/community-downloads/
Load the configuration file in the software and then hit connect button.
Congrats! You have successfully installed openVPN and connected with it. Go to the browser and type my ip and search. You will get your server IP everywhere.
Source of this blog- 1. My practical implementation. 2. OpenVPN docs. 3. Medium.com