openvpn: ubuntu server dns problems

when connecting to an openvpn server (at least on ubuntu 20.04) you lose your dns server, meaning you're not able to access any remote hosts via ip. 

you can basically sucessfully ping, but if you ping it will fail, because it cannot translate google to an ip. 

the solution is here:


basically install openresolv

sudo apt-get install -y openresolv


add the instructions in the openvpn config file to update the dns after connection.

# This updates the resolvconf with dns settings
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
script-security 2
up /etc/openvpn/update-resolv-conf
down /etc/openvpn/update-resolv-conf


Leave a Reply

Your email address will not be published. Required fields are marked *