The easiest way to install simple OpenVPN server application in Linux Ubuntu on Digital Ocean Droplet. (We tested on Ubuntu 18.x and Ubuntu 20.x)
- This guide using existing installation guide from (https://github.com/angristan/openvpn-install).
- curl -O https://raw.githubusercontent.com/angristan/openvpn-install/master/openvpn-install.sh
- chmod +x openvpn-install.sh
- ./openvpn-install.sh
Alternatively, If you wish to use droplet’s FLOATING ip as VPN host, you need to add the below strings into the above downloaded ‘openvpn-install.sh’ script.
ANCHOR_IP=echo "$(curl -s http://169.254.169.254/metadata/v1/interfaces/public/0/anchor_ipv4/address)"
echo "local $ANCHOR_IP" >> /etc/openvpn/server.conf
echo "iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source $ANCHOR_IP" >> /etc/iptables/rm-openvpn-rules.sh
echo "iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -j SNAT --to-source $ANCHOR_IP" >> /etc/iptables/add-openvpn-rules.sh
service openvpn restart
Digital Ocean Ubuntu VPN