systemd-resolve 不使用来自 DHCP 的 DNS

systemd-resolve 不使用来自 DHCP 的 DNS

我的 Ubuntu 客户端仍在 systemd-resolve 中使用旧的 DNS。当我运行时,systemd-resolve --status我发现旧的和新的 DNS。新的 DNS 已使用我的网络上的 DHCP 范围选项进行设置。我已成功更新所有 RHEL 系统,但 Debian/Ubuntu systemd 并非如此:

systemd-resolve --status:

      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.10.44 ( OLD )
                      192.168.10.69 ( NEW )

已解决.conf

cat /etc/systemd/resolved.conf
#  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=no
#MulticastDNS=no
#DNSSEC=no
#Cache=yes
#DNSStubListener=yes

解析配置文件

# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# 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 127.0.0.53
search example.com

/etc/systemd/网络/是空的。

我无数次尝试重新启动 systemd-resolved 和 systemd-networkd,因为我在 Github systemd 存储库中读到 systemd-networkd 负责使用 DHCP 更新 systemd-resolve 将使用的内容。

编辑:
/run/systemd/resolve/stub-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 to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# 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 127.0.0.53
search example.com

编辑2: 作为最近评论的一部分
/etc/netplan/50-cloud-init.yml

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    version: 2
    ethernets:
        ens3:
            dhcp4: true
            match:
                macaddress: XX:XX:XX:XX:XX
            set-name: ens3

答案1

NETWORK_FILE=/run/systemd/network/10-netplan-ens3.network您在评论中提到的似乎是指 Netplan 生成的配置文件systemd-networkd

建议 Netplan中的评论/etc/netplan/50-cloud-init.yml反过来又由以下控制cloud-init

# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.

因此,cloud-init 会将其推送到,50-cloud-init.yml并且/etc/netplan如果您修改它,可能会将其更改回来。但这是吗全部是吗?它的日志文件/var/log/cloud-init*.log可能会提供启发。

如果事实证明 cloud-init 强制添加您的旧 DNS 设置,那么它也已经告诉您如何让 cloud-init 不干涉您的网络设置:

# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}

相关内容