无法解析任何 DNS 地址,resolveconf 未安装(且无法安装)

无法解析任何 DNS 地址,resolveconf 未安装(且无法安装)

我刚刚更新到 24.04。从那时起,我的机器就无法解析任何 DNS 名称,因此无法更新或安装任何软件包。

我已关注过许多论坛帖子,它们都要求编辑 resolv.conf,但我的文件(符号链接)指向的目录中不存在的位置(../run/systemd/resolve/stub-resolv.conf)。我没有安装 resolvconf 包,由于存在持续问题,我无法安装它。我还停止并禁用了 NetworkManager,然后重新启动/启用它,但没有任何效果。

我见过的每个人都遇到过这个问题,他们使用 resolvconf 之类的工具来解决这个问题,但出于某种原因,我无法访问任何工具,也不知道如何获取它们。我通过 WiFi 连接在笔记本电脑上运行 ubuntu。

ip 输出:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host noprefixroute 
       valid_lft forever preferred_lft forever
2: wlp58s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 9c:b6:d0:ef:6c:19 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.201/24 brd 192.168.1.255 scope global dynamic noprefixroute wlp58s0
       valid_lft 42702sec preferred_lft 42702sec
    inet6 2603:7080:8e3a:8902::1c9b/128 scope global dynamic noprefixroute 
       valid_lft 604303sec preferred_lft 604303sec
    inet6 fd00:9491:7fc3:b5f8::1c9b/128 scope global dynamic noprefixroute 
       valid_lft 604303sec preferred_lft 604303sec
    inet6 2603:7080:8e3a:8902:af17:8baa:5232:da2d/64 scope global temporary dynamic 
       valid_lft 604303sec preferred_lft 85374sec
    inet6 2603:7080:8e3a:8902:e2fc:6c92:8de0:ebf/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 604544sec preferred_lft 604544sec
    inet6 fd00:9491:7fc3:b5f8:5ea7:41c5:3642:973f/64 scope global temporary dynamic 
       valid_lft 604303sec preferred_lft 85374sec
    inet6 fd00:9491:7fc3:b5f8:2a38:8896:de03:8d4d/64 scope global dynamic mngtmpaddr noprefixroute 
       valid_lft 604544sec preferred_lft 604544sec
    inet6 fe80::2873:cef:157f:5a57/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever

resolvectl 状态输出:

Command 'resolvectl' not found, but can be installed with:
sudo apt install systemd-resolved  # version 253.5-1ubuntu7, or
sudo apt install systemd           # version 253.5-1ubuntu7

cat /etc/netplan/* 输出:

network:
  version: 2
  wifis:
    NM-23531f6d-4afa-4d4e-b910-600d048bcaf3:
      renderer: NetworkManager
      match:
        name: "wlp58s0"
      dhcp4: true
      dhcp6: true
      access-points:
        "":
          auth:
            key-management: "psk"
            password: ""
          networkmanager:
            uuid: "23531f6d-4afa-4d4e-b910-600d048bcaf3"
            name: ""
            passthrough:
              wifi-security.auth-alg: "open"
              ipv6.addr-gen-mode: "default"
              ipv6.ip6-privacy: "-1"
              proxy._: ""
      networkmanager:
        uuid: "23531f6d-4afa-4d4e-b910-600d048bcaf3"
        name: ""
network:
  version: 2
  wifis:
    NM-32c63030-6242-4279-9e5a-a055eeb8d8d9:
      renderer: NetworkManager
      match:
        name: "wlp58s0"
      dhcp4: true
      dhcp6: true
      ipv6-address-generation: "stable-privacy"
      access-points:
        "14mn":
          auth:
            key-management: "psk"
            password:
          networkmanager:
            uuid: "32c63030-6242-4279-9e5a-a055eeb8d8d9"
            name: ""
            passthrough:
              connection.timestamp: "1705184110"
              wifi-security.auth-alg: "open"
              ipv6.ip6-privacy: "-1"
              proxy._: ""
      networkmanager:
        uuid: "32c63030-6242-4279-9e5a-a055eeb8d8d9"
        name: ""
network:
  version: 2
  wifis:
    NM-89d0b746-b032-4da0-924f-55ce8ad62274:
      renderer: NetworkManager
      match:
        name: ""
      dhcp4: true
      dhcp6: true
      ipv6-address-generation: "stable-privacy"
      access-points:
        "":
          auth:
            key-management: "psk"
            password: ""
          networkmanager:
            uuid: "89d0b746-b032-4da0-924f-55ce8ad62274"
            name: ""
            passthrough:
              connection.timestamp: "1710898792"
              wifi-security.auth-alg: "open"
              ipv6.ip6-privacy: "-1"
              proxy._: ""
      networkmanager:
        uuid: "89d0b746-b032-4da0-924f-55ce8ad62274"
        name: ""
network:
  version: 2
  wifis:
    NM-8d26504f-2bd6-4d6a-ad06-0969c5838eb6:
      renderer: NetworkManager
      match:
        name: ""
      dhcp4: true
      dhcp6: true
      ipv6-address-generation: "stable-privacy"
      access-points:
        "":
          auth:
            key-management: "psk"
            password: ""
          networkmanager:
            uuid: "8d26504f-2bd6-4d6a-ad06-0969c5838eb6"
            name: ""
            passthrough:
              connection.timestamp: "1704069031"
              wifi-security.auth-alg: "open"
              ipv6.ip6-privacy: "-1"
              proxy._: ""
      networkmanager:
        uuid: "8d26504f-2bd6-4d6a-ad06-0969c5838eb6"
        name: ""

出于安全原因,我删除了一些 wifi 信息。

答案1

它应该是/run/systemd/resolve/stub-resolv.conf而不是../run/systemd/resolve/stub-resolv.conf

另外,考虑一种新的 systemd 方法,向 systemd-resolved 提供额外的 DNS 信息,而不是stub-resolv.conf直接编辑:https://www.freedesktop.org/software/systemd/man/latest/resolved.conf.html

TL;DR 您可以添加一个新的 conf 文件, /etc/systemd/resolved.conf.d/<some name>.conf 内容如下

[Resolve]
DNS=8.8.8.8

答案2

通常,最好不要在 8 月份发布第一个版本 24.0.1 之前升级。升级后,我听说您遇到了一个问题,即sysyemd-resolved删除了哪些内容。

因此,要解决您的问题,请使用以下命令进行安装:

sudo apt install systemd-resolved

这将重新安装解析器并解决您的问题。

相关内容