通过NetworkManager / nm-applet设置DNS不会更新/etc/resolv.conf(17.10)
我的/etc/resolv.conf
显示
# Generated by NetworkManager search [value provided by local network] nameserver 127.0.1.1
nameserver
值不是本地网络提供的值(使用nm-applet检查),但search
是。
我从/etc/NetworkManager/NetworkManager.conf
删除了dns=dnsmasqd
/etc/NetworkManager/NetworkManager.conf
。 只安装了dnsmasq-base
。
我不想永久设置DNS,因为我仍然希望VPN更新resolv.conf
,所以
/etc/dhcp/dhclient.conf
没有prepend domain-name servers
/etc/network/interfaces
没有dns-nameservers
没有/etc/resolvconf/resolv.conf.d/
base
head
tail
文件。
当我使用Automatic (DHCP)
在nm-applet上设置DNS时, resolv.conf
保持不变。
当我仅设置Automatic (DHCP) addresses only
,没有search
值,但nameserver 127.0.1.1
仍在resolv.conf
。
编辑:做了一些检查。 /etc/NetworkManager/dnsmasq.d
为空。
$ cat /usr/lib/NetworkManager/conf.d/10-dns-resolved.conf [main] dns=systemd-resolved
/etc/systemd/resolved.conf
已全部注释掉。
$ systemd-resolve --status Global DNS Servers: 127.0.1.1 DNS Domain: [same as resolv.conf]
如何配置nm-applet中的DNS值会覆盖systemd-resolve
?。
最终,我想要的是最初将resolv.conf
的dns设置为我的首选服务器,然后当我连接到VPN(nm-applet的OpenVPN)时, resolv.conf
将具有VPN提供的值。
我花了一段时间才到达那里……
如果您已经知道要在resolv.conf中设置什么,那么您只需使用自己喜欢的编辑器在/etc/systemd/resolved.conf
编写设置即可。
sudo nano /etc/systemd/resolved.conf
只需取消注释DNS和域 ,输入IP和搜索域 (空白分隔)并重新启动systemd-resolv或重新启动主机。
# 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= #FallbackDNS= Domains= #LLMNR=yes #MulticastDNS=yes #DNSSEC=no #Cache=yes #DNSStubListener=udp
NetworkManager应该能够修改DNS。 我没有要测试的VPN,但是我能够在有线连接上添加带有NM的名称服务器。