9

How does one use the dns pushed via an openvpn server with systemd-resolved ?

Before I decide to 'upgrade' to systemd-networkd. I could use some variant of openvpn-resolv-conf script to call resolvconf to manage entries in /etc/resolv.conf on successfully establishing a vpn tunnel.

This would allow me to resolve names on the remote end of the vpn tunnel.

Now that systemd-resolved manages /run/systemd/resolved/resolv.conf is it possible to automatically add DNS pushed via a openvpn connection to the list of nameservers used for resolution?

6

Use up/down scripts from https://github.com/jonathanio/update-systemd-resolved in your OpenVPN's config file. These use systemd-resolved's DBus interface to update DNS information.

3

Edit: as of today, this solution is mostly obsolete. Users of newer systemd versions should refer to the solution given by Piotr Dobrogost.

The trick is to create a temporary network configuration file with DNS settings, and then restart systemd-network so it will apply global DNS settings.

I have written a modified script that does exactly that. You can check it out here: update-systemd-network.sh

3
  • 1
    I find that there's a race condition with creation of routes pushed via the openvpn config on restart of systemd-networkd. However, instead of creating a new network config and restarting systemd-network it's possible to create a very similar file in /run/systemd/resolved-conf.d/ and then restart systemd-resolved which seems to work – sw1nn Mar 14 '16 at 18:35
  • looks like the above features in systemd-resolved were added in 229 after my original question. – sw1nn Mar 14 '16 at 18:57
  • According to @grawity from #systemd – the proper way to make it work is to call org.freedesktop.resolve1.Manager.SetLinkDNS() via DBus – Piotr Dobrogost Mar 25 '16 at 8:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.