Here are the steps to set up an OpenVPN server on Ubuntu Linux in 5 minutes:
- Install OpenVPN:
sudo apt-get update
sudo apt-get install openvpn easy-rsa
- Copy the sample OpenVPN configuration files:
sudo cp /usr/share/doc/openvpn/examples/sample-config-files/server.conf.gz /etc/openvpn/
sudo gzip -d /etc/openvpn/server.conf.gz
- Modify the OpenVPN configuration file:
sudo nano /etc/openvpn/server.conf
- Change the
proto
setting toudp
ortcp
depending on your desired protocol. - Change the
port
setting to the desired port number. - Change the
dev tun
setting todev tap
if you want to use TAP mode instead of TUN mode. - Change the
server
setting to specify the subnet for the virtual network. - Uncomment the
push "redirect-gateway def1 bypass-dhcp"
line to enable client-side routing.
- Generate the SSL certificate and key:
sudo make-ccd-keys
- Start the OpenVPN server:
sudo systemctl start openvpn@server
- Enable the OpenVPN server to start automatically on boot:
sudo systemctl enable openvpn
That’s it! Your OpenVPN server is now up and running. You can now create client configuration files and connect to the server.