Systemd-resolved 设置意外 DNS 列表

Systemd-resolved 设置意外 DNS 列表

当我连接到手机热点时,我期望 systemd-resolved 使用 dhcp 提供的 dns 列表。出于某种原因,对我来说似乎并非如此。

我正在使用 Ubuntu 22.04.1 LTS

/etc/systemd/resolved.conf是空的

当我连接到手机 WiFi 时,我得到以下结果:

ip 显示 wlp3s0

3: wlp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
    inet 192.168.138.69/24 brd 192.168.138.255 scope global dynamic noprefixroute wlp3s0
       valid_lft 3411sec preferred_lft 3411sec

日志控制

paź 03 09:25:46 pc systemd-resolved[5434]: wlp3s0: Bus client set DNS server list to: 192.168.185.139, 192.168.22.175, 192.168.78.16

tcpdump -i wlp3s0 -e -nn -vv

tcpdump: listening on wlp3s0, link-type EN10MB (Ethernet), snapshot length 262144 bytes
09:25:46.427512 xx:xx:xx:xx:xx:xx > ff:ff:ff:ff:ff:ff, ethertype IPv4 (0x0800), length 339: (tos 0xc0, ttl 64, id 0, offset 0, flags [DF], proto UDP (17), length 325)
    0.0.0.0.68 > 255.255.255.255.67: [udp sum ok] BOOTP/DHCP, Request from xx:xx:xx:xx:xx:xx, length 297, xid 0xd83b70be, secs 1, Flags [none] (0x0000)
      Client-Ethernet-Address xx:xx:xx:xx:xx:xx
      Vendor-rfc1048 Extensions
        Magic Cookie 0x63825363
        DHCP-Message (53), length 1: Request
        Client-ID (61), length 7: ether xx:xx:xx:xx:xx:xx
        Parameter-Request (55), length 17: 
          Subnet-Mask (1), Time-Zone (2), Domain-Name-Server (6), Hostname (12)
          Domain-Name (15), MTU (26), BR (28), Classless-Static-Route (121)
          Default-Gateway (3), Static-Route (33), YD (40), YS (41)
          NTP (42), Unknown (119), Classless-Static-Route-Microsoft (249), Unknown (252)
          RP (17)
        MSZ (57), length 2: 576
        Requested-IP (50), length 4: 192.168.138.69
        Hostname (12), length 13: "pc"
09:25:46.445267 yy:yy:yy:yy:yy:yy > xx:xx:xx:xx:xx:xx, ethertype IPv4 (0x0800), length 366: (tos 0x0, ttl 64, id 44909, offset 0, flags [DF], proto UDP (17), length 352)
    192.168.138.79.67 > 192.168.138.69.68: [udp sum ok] BOOTP/DHCP, Reply, length 324, xid 0xd83b70be, Flags [none] (0x0000)
      Your-IP 192.168.138.69
      Server-IP 192.168.138.79
      Client-Ethernet-Address xx:xx:xx:xx:xx:xx
      Vendor-rfc1048 Extensions
        Magic Cookie 0x63825363
        DHCP-Message (53), length 1: ACK
        Server-ID (54), length 4: 192.168.138.79
        Lease-Time (51), length 4: 3599
        RN (58), length 4: 1799
        RB (59), length 4: 3149
        Subnet-Mask (1), length 4: 255.255.255.0
        BR (28), length 4: 192.168.138.255
        Default-Gateway (3), length 4: 192.168.138.79
        Domain-Name-Server (6), length 4: 192.168.138.79
        Hostname (12), length 13: "pc"
        Vendor-Option (43), length 15: 65.78.68.82.79.73.68.95.77.69.84.69.82.69.68

如果我执行dhclient -r wlp3s0 && dhclient wlp3s0

日志控制

paź 03 09:45:02 pc systemd-resolved[5434]: wlp3s0: Bus client set DNS server list to: 192.168.138.79

发行systemctl restart systemd-resolved会带回意外的 IP。

为什么 systemd-resolved 会分配 ips:192.168.185.139、192.168.22.175、192.168.78.16,而不是 dhcp 提供的 192.168.138.79?它是如何得出这些 ips 的?

更新

resolvectl

Global
       Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub

Link 2 (wlp3s0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: 192.168.78.16
       DNS Servers: 192.168.185.139 192.168.22.175 192.168.78.16
        DNS Domain: --

Link 3 (docker0)
Current Scopes: none
     Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported

cat /usr/lib/NetworkManager/conf.d/10-dns-resolved.conf

[main]
# We need to specify "dns=systemd-resolved" as for the time being our
# /etc/resolv.conf points to resolvconf's generated file instead of
# systemd-resolved's, so the auto-detection does not work.
dns=systemd-resolved

journalctl -b -g "dns" | grep -i -v avahi

paź 07 23:31:17 pc kernel: Key type dns_resolver registered
paź 07 23:31:18 pc NetworkManager[1067]: <info>  [1665178278.7520] Read config: /etc/NetworkManager/NetworkManager.conf (lib: 10-dns-resolved.conf, 20-connectivity-ubuntu.conf, no-mac-addr-change.conf) (run: 10-globally-managed-devices.conf) (etc: 10-ubuntu-fan.conf, default-wifi-powersave-on.conf)
paź 07 23:31:18 pc NetworkManager[1067]: <info>  [1665178278.8699] dns-mgr[0x5653847524a0]: init: dns=systemd-resolved rc-manager=unmanaged (auto), plugin=systemd-resolved
paź 07 23:31:18 pc freshclam[1299]: Fri Oct  7 23:31:18 2022 -> ^Invalid DNS reply. Falling back to HTTP mode.
paź 07 23:31:22 pc NetworkManager[1067]: <info>  [1665178282.8547] policy: set 'x' (wlp3s0) as default for IPv4 routing and DNS
paź 07 23:31:22 pc systemd-resolved[1021]: wlp3s0: Bus client set DNS server list to: 192.168.185.139, 192.168.22.175, 192.168.78.16
paź 07 23:31:39 pc systemd-resolved[1021]: Using degraded feature set UDP instead of UDP+EDNS0 for DNS server 192.168.185.139.
paź 07 23:31:44 pc systemd-resolved[1021]: Using degraded feature set UDP instead of UDP+EDNS0 for DNS server 192.168.22.175.
paź 07 23:31:49 pc systemd-resolved[1021]: Using degraded feature set UDP instead of UDP+EDNS0 for DNS server 192.168.78.16.
paź 07 23:31:54 pc systemd-resolved[1021]: Using degraded feature set TCP instead of UDP for DNS server 192.168.185.139.
paź 07 23:32:04 pc systemd-resolved[1021]: Using degraded feature set TCP instead of UDP for DNS server 192.168.22.175.
paź 07 23:32:14 pc systemd-resolved[1021]: Using degraded feature set TCP instead of UDP for DNS server 192.168.78.16.
paź 07 23:32:35 pc systemd-resolved[1021]: Using degraded feature set UDP instead of TCP for DNS server 192.168.22.175.
paź 07 23:32:50 pc systemd-resolved[1021]: Using degraded feature set UDP instead of TCP for DNS server 192.168.185.139.
paź 07 23:32:56 pc systemd-resolved[1021]: Using degraded feature set TCP instead of UDP for DNS server 192.168.22.175.
paź 07 23:33:06 pc systemd-resolved[1021]: Using degraded feature set UDP instead of TCP for DNS server 192.168.78.16.
paź 07 23:33:11 pc systemd-resolved[1021]: Using degraded feature set TCP instead of UDP for DNS server 192.168.185.139.
paź 07 23:33:21 pc systemd-resolved[1021]: Using degraded feature set UDP instead of TCP for DNS server 192.168.22.175.
paź 07 23:33:27 pc systemd-resolved[1021]: Using degraded feature set TCP instead of UDP for DNS server 192.168.78.16.

systemd-analyze cat-config systemd/resolved.conf

# /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. Local configuration
# should be created by either modifying this file, or by creating "drop-ins" in
# the resolved.conf.d/ subdirectory. The latter is generally recommended.
# Defaults can be restored by simply deleting this file and all drop-ins.
#
# Use 'systemd-analyze cat-config systemd/resolved.conf' to display the full config.
#
# See resolved.conf(5) for details.

#[Resolve]
# Some examples of DNS servers which may be used for DNS= and FallbackDNS=:
# Cloudflare: 1.1.1.1#cloudflare-dns.com 1.0.0.1#cloudflare-dns.com 2606:4700:4700::1111#cloudflare-dns.com 2606:4700:4700::1001#cloudflare-dns.com
# Google:     8.8.8.8#dns.google 8.8.4.4#dns.google 2001:4860:4860::8888#dns.google 2001:4860:4860::8844#dns.google
# Quad9:      9.9.9.9#dns.quad9.net 149.112.112.112#dns.quad9.net 2620:fe::fe#dns.quad9.net 2620:fe::9#dns.quad9.net
#DNS=
#FallbackDNS=
#Domains=
#DNSSEC=no
#DNSOverTLS=no
#MulticastDNS=no
#LLMNR=no
#Cache=no-negative
#CacheFromLocalhost=no
#DNSStubListener=yes
#DNSStubListenerExtra=
#ReadEtcHosts=yes
#ResolveUnicastSingleLabel=no

答案1

原因是 中的静态配置了 IP 地址列表/etc/NetworkManager/system-connections/name.nmconnection

相关内容