Systemd 解析设置意外的 DNS 列表

Systemd 解析设置意外的 DNS 列表

当我连接到手机热点时,我希望systemd-resolved使用 DHCP 提供的 DNS 列表。出于某种原因,我的情况似乎并非如此。

  • 我正在使用 Ubuntu 22.04.1 LTS

  • /etc/systemd/resolved.conf是空的

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

  • IP地址:
    ip a show 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
    
  • 对应的系统日志条目:
    journalctl
    
    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
    
  • 对应的TCP流量
    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
    

如果我执行以下命令,则使用预期的 DNS dhclient -r wlp3s0 && dhclient wlp3s0

  • 系统日志条目:
    journalctl
    
    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使用 IP 地址:192.168.185.139192.168.22.175192.168.78.16作为 DNS 服务器而不是 DHCP 提供的192.168.138.79?它是如何得出地址的?

答案1

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

相关内容