September 10, 2018

118 words 1 min read

Openvpn: Update dns servers FIX

Openvpn: Update dns servers FIX

Because newer Ubuntu versions are using systemd for dns resolution instead of resolvconf, you need to modify your Openvpn client config a bit.

Add following lines to your config (/etc/openvpn/myconnection.conf):

script-security 2
setenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved

Simply add the new update script by running:

sudo apt install openvpn-systemd-resolved

Or add the script manually:

sudo wget -P /etc/openvpn/

Server config

To route all clients over the vpn gateway add following lines to your server config:

push "redirect-gateway def1"
push "dhcp-option DNS"
push "dhcp-option DNS"
push "dhcp-option DOMAIN"

FYI: You can route just single clients via your vpn gateway by adding these same lines to a client-config-dir (ccd) file.