问题描述
如何在Ubuntu 17.04中禁用systemd-resolved?
使用systemctl disable
禁用它不起作用,该服务似乎重新启动(由Networkmanager?)
最佳解决方案
此方法适用于Ubuntu Releases 17.04(Zasty),17.10(Artful),18.04(Bionic)和18.10(Cosmic):
禁用并停止systemd-resolved服务:
sudo systemctl disable systemd-resolved.service
sudo systemctl stop systemd-resolved
然后将以下行放在/etc/NetworkManager/NetworkManager.conf
的[main]
部分中:
dns=default
删除符号链接/etc/resolv.conf
rm /etc/resolv.conf
重新启动network-manager
sudo service network-manager restart
另请注意,禁用systemd-resolvd可能会破坏VPN中某些用户的名称解析。见this bug on launchpad(谢谢,Vincent)。
次佳解决方案
我最近升级到(k)Ubuntu 17.04,我也偶然发现了对systemd的更改。
我认为我的设置非常典型,因为我的宽带HUB中有一个DNS提供商,这是我网络上所有设备的主要信息来源(我有一些)。
在systemd中有一些美,它并不是一件坏事,但真正糟糕的是文档,Ubuntu团队和gung-ho缺乏沟通“让我们改变它,尽管它打破了每个人的心态”。
撕掉一些头发后的解决方案是编辑/etc/systemd/resolved.conf:
[Resolve]
DNS=192.168.1.254 # <-- change to your router address
#FallbackDNS=8.8.8.8 8.8.4.4 2001:4860:4860::8888 2001:4860:4860::8844
Domains=lan # <-- change to your localdomain name (maybe .local)
#LLMNR=yes <-- I dabbled with this for a while but it doesn't matter
#DNSSEC=no
#Cache=yes
#DNSStubListener=udp
在不明白为什么这不起作用后,我发现还需要将/etc/resolv.conf切换到systemd提供的那个。在out-of-a-box安装中不是这种情况(由于我不知道的原因)。
sudo ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
然后不使用本地DNS服务器,并将所有DNS请求发送到我的HUB。
我认为这是一个比切断并放入其他解决方案更好的解决方案,因为systemd-resolv现在是默认的。
btw的一个相关问题是/etc/nsswitch.conf是绝对的。
它应该是:
hosts:files mdns4_minimal dns [NOTFOUND = return] resolve [!UNAVAIL = return] dns
这是一个令人困惑的配置,因为[NOTFOUND = return]意味着处理结束。之后的条目永远不会被使用。