更新至 22.04 后 DNS 条目重复

更新至 22.04 后 DNS 条目重复

我的服务器有两个配置了 DHCP 的网络接口,从 Ubuntu 20.04 更新5.4.0-144-generic到 22.04后5.15.0-67-generic,导致/var/run/systemd/resolve/resolv.conf包含重复的 DNS 条目。

/etc/netplan以前的样子

$ cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
network:
  ethernets:
    eno1:
      dhcp4: true
    eno2:
      dhcp4: true
  version: 2

但更新之后,结果如下:

$ cat /var/run/systemd/resolve/resolv.conf
# This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 192.168.18.2
nameserver 192.168.18.1
nameserver 192.168.18.2
# Too many DNS servers configured, the following entries may be ignored.
nameserver 192.168.18.1
search .

在我没有更新的服务器上,/var/run/systemd/resolve/resolv.conf看起来像:

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 192.168.18.2
nameserver 192.168.18.1

两台服务器上的 netplan 配置相同,两台服务器都使用两个接口,但只有新服务器使用设置复制了 DNS dhcp4: true

通常我不会太在意,因为我预计它无论如何都会随机选择一个。但我正在运行一项kubelet服务,它只需要两个 DNS 服务器这个特定的文件,而现在这种情况已经发生改变。

我的临时解决方法是使用dhcp4: false接口eno2(在 netplan 配置中)并手动配置我需要的路由和地址,但这显然是一种解决方法。

我尝试在线查找两个 Ubuntu 版本之间的变化以及 netplan 和重复的 DNS 条目,但我没有找到任何东西,而且在我找到一个好的解决方案之前,我真的不想更新其他服务器。

更新:

我正在运行 NetworkManager 还是 networkd?两台服务器均在运行systemd-networkd

答案1

代替:

dhcp4: false

尝试:

dhcp4: true
dhcp4-overrides:
  use-dns: false

相关内容