如何在 Ubuntu 18 上禁用 systemd-resolved 并替换为正常的东西?

gct*_*gct 10 dns

我已经决定 systemd-resolved 是无法挽回的损坏垃圾,我想更换。我有自己的本地 DNS 服务器,地址为 192.168.1.2 我想要。我最好像连接到瘦客户端(NetExtender)与一个VPN,让我一个.local域的DNS服务器。我想让这两件事一起工作,我该怎么办?

小智 6

Gannet 的答案是不正确的。如果您想像早期版本一样使用简单的 ifupdown,没有 netplan 或 NetworkManager(例如在服务器上),使用 dhcp,则需要执行以下操作:

systemctl disable systemd-resolved.service
systemctl stop systemd-resolved.service

# check if resolv.conf is pointing to resolvconf
ls -la /etc/resolv.conf
# lrwxrwxrwx 1 root root 27 May  7 16:15 /etc/resolv.conf -> /run/resolvconf/resolv.conf
# if not, delete /etc/resolv.conf and symlink it like this: 
rm /etc/resolv.conf
ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

# this will remove the resolved stub resolver entry from resolv.conf
resolvconf -d systemd-resolved

# fix dhclient scripts
chmod -x /etc/dhcp/dhclient-enter-hooks.d/resolved
chmod +x /etc/dhcp/dhclient-enter-hooks.d/resolvconf

# on my machine just chmod -x wasn't enough, I had to move the resolved script somewhere else
mv /etc/dhcp/dhclient-enter-hooks.d/resolved ~

# ifdown/ifup your interface to regenerate resolv.conf (or systemctl restart ifup@eth0)
ifdown eth0; ifup eth0

# check /etc/resolv.conf has the right settings

Run Code Online (Sandbox Code Playgroud)


Gan*_*net 3

您始终可以通过命令禁用 systemd-resolved

systemctl disable systemd-resolved.service

。并运行:以像以前的 ubuntu 版本一样

sudo rm /etc/resolv.conf && sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf

使用配置。/etc/resolv.conf