4

My /etc/resolv.conf shows

# Generated by NetworkManager
search [value provided by local network]
nameserver 127.0.1.1

The nameserver value is not the one provided by the local network (checked using nm-applet), but the search is.
I've removed dns=dnsmasqd from /etc/NetworkManager/NetworkManager.conf. There's only dnsmasq-base installed.

I don't want to set DNS permanently because I still want resolv.conf to be updated by the VPN, so
no prepend domain-name servers in /etc/dhcp/dhclient.conf
no dns-nameservers in /etc/network/interfaces
no /etc/resolvconf/resolv.conf.d/ base head tail files.

resolv.conf remains the same when I set the DNS on nm-applet using Automatic (DHCP).
When I set Automatic (DHCP) addresses only, there is no search value, but nameserver 127.0.1.1 is still in resolv.conf.

Edit: Did some more checking. /etc/NetworkManager/dnsmasq.d is empty.

$ cat /usr/lib/NetworkManager/conf.d/10-dns-resolved.conf 
[main]
dns=systemd-resolved


/etc/systemd/resolved.conf is all commented out.

$ systemd-resolve --status
Global
         DNS Servers: 127.0.1.1
          DNS Domain: [same as resolv.conf]

How do I configure that the DNS values from nm-applet overrides the systemd-resolve?.

Ultimately, what I want is to initially set the dns in resolv.conf to my preferred server, and then when I connect to VPN (nm-applet's OpenVPN), resolv.conf will have the value provided by the VPN.

4

It took me a while to get there...

If you already know what you want to set in resolv.conf then you can simply write your settings in /etc/systemd/resolved.conf with your favorite editor.

sudo nano /etc/systemd/resolved.conf

Just uncomment DNS and domains, enter the IPs and searchdomains (blank seperated) and restart systemd-resolv or reboot your host.

#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
DNS=<IP> <IP>
#FallbackDNS=
Domains=<domain> <domain>
#LLMNR=yes
#MulticastDNS=yes
#DNSSEC=no
#Cache=yes
#DNSStubListener=udp

NetworkManager should be able to modify the DNS. I don't have a VPN to test, but I was able to append nameservers with NM on my wired connection.

| improve this answer | |

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.