Quick Tip: DNS and resolved configuration with OpenVPN

By | November 10, 2020

After climbing the steep learning curve to get OpenVPN to work on Ubuntu (as a client), I ended up with a VPN that worked but still had issues with DNS name resolution.

What finally worked for me was to use the distribution defaults for everything, but install libnss-resolve and openvpn-systemd-resolved packages. This worked for a while, but then broke. What finally did the trick was to make a change to the OpenVPN client configuration file (located in /etc/openvpn) to add the following lines:

# JRD - Needed to work with systemd-resolvd
# See https://askubuntu.com/questions/1032476/ubuntu-18-04-no-dns-resolution-when-connected-to-openvpn
script-security 2
up /etc/openvpn/update-systemd-resolved
down /etc/openvpn/update-systemd-resolved
down-pre
dhcp-option DOMAIN-ROUTE .

Two posts were instrumental in getting me there:
https://askubuntu.com/questions/1032476/ubuntu-18-04-no-dns-resolution-when-connected-to-openvpn
https://bugs.launchpad.net/ubuntu/+source/glibc/+bug/1769016

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.