1

I am posting this on Ubuntu, since Linux Mint is quite related to it and I think this behaviour is the same on both.

I am using the Networkmanager GUI in Cinnamon.

My Linux Mint box connects to WLAN hotspot, which acts as DHCP server and propagates itself as DNS server. So far, so good.

However, when I connect to a VPN, the DHCP server of the VPN tunnel assignes an IP address to my client (which works) and a DNS server - which is ignored. Even entering the DNS server statically is ignored.

How can I tell Networkmanager/DNSMasq to use another DNS server when connected to the VPN? I cannot find anything related on the GUI, neither in the docs how to configure it in a config file.

Note, this DNS server must only be used in the VPN, because it is a company-wide DNS server which resolves a local TLD (.loc). It is not done by replacing the standard DNS server (the WLAN hotspot) with a public one.

3
  • Hmm, a very similar issue came up yesterday. Could there be a regression in network manager?
    – zwets
    Aug 6, 2018 at 10:40
  • 1
    Note there is the package openvpn-systemd-resolved which supposedly integrates OpenVPN with systemd-resolved. You could try if it helps.
    – zwets
    Aug 8, 2018 at 11:46
  • @zwets at least it is OpenVPN. I'll give it a try a soon as I get to this computer again and keep you informed. Aug 8, 2018 at 13:01

1 Answer 1

2

For anyone who stumbles upon this problem, I finally solved it on my own.

The newest Ubuntu versions no longer use DNSMasq, but Systemd-resolve. However, Systemd-resolve does not get informed by the NetworkManager to update the DNS settings when a tunnel is opened. To overcome this issue, one can create a dispatcher script like this:

#!/bin/bash
UUID='uuid-of-vpn-connection-file'
VPNIF="$(nmcli -t connection show "$UUID"| sed -n '^GENERAL\.DEVICES:/{s/^[^:]*:\([^\s]*\)}/\1/;p}
[[ "$1" =~ ^tun -a "$2" = 'up' ]] && systemd-resolve --set-dns xxx.xxx.xxx.xxx --interface "$VPNIF"

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.