Set up OpenVPN connection on Ubuntu with DNS solving
2020-07-11
Part 1. Set up OpenVPN
Install OpenVPN:
sudo apt install openvpn
Write down your configuration:
sudo vim /etc/openvpn/client.conf
Example:
client
proto udp
dev tun
remote ovpn.myvpnserver.net
nobind
persist-key
persist-tun
comp-lzo
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf
Download update-resolv-conf script:
sudo wget -O /etc/openvpn/update-resolv-conf https://raw.githubusercontent.com/alfredopalhares/openvpn-update-resolv-conf/master/update-resolv-conf.sh
sudo chmod +x /etc/openvpn/update-resolv-conf
Part 2. Set up DNS solving
Way 1. Via resolvconf
Set up resolvconf package so it will manage DNS settings
sudo apt install resolvconf
Create symlink to resolv.conf
sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf
Way 2. Via NetworkManager
Described here https://www.comss.ru/page.php?id=6994
Part 3. Connect OpenVPN
sudo service openvpn start