DNS 停止工作(22.04)

DNS 停止工作(22.04)

更新 #2:启动后的第二天,我启用并启动了 systemd-resolved,这显然将其重置为默认配置。输出resolvectl status看起来正常,DNS 现在又可以与存根解析器配合使用,一切正常。

更新:我停止并禁用了 systemd-resolved 服务,然后向 /etc/resolv.conf 添加了名称服务器,一切正常。

我重新启动后,/etc/resolv.conf 不见了,所以我启用了 systemd-resolved,并启动它,DNS 又可以正常工作了。

============================================

DNS 在 Ubuntu 22.04 上停止工作。真实桌面系统。已使用 3 年以上。通常使用 WiFi 连接到互联网,但使用以太网电缆连接到家用路由器进行测试,出现相同错误。其他设备、笔记本电脑和手机使用家用 WiFi 没有任何问题。

使用“dig”命令的“@”选项指定 DNS 服务器是可行的,例如,它dig @1.1.1.1 askubuntu.com可以得到预期的结果,但是dig askubuntu.com会出现普通的超时情况,如下面的 nmcli 输出末尾所示。

我清除了 DNS 缓存,sudo resolvectl flush-caches但没有什么变化。有没有办法重置解析器服务?

$ nmcli device
DEVICE          TYPE      STATE                   CONNECTION               
wlp6s0          wifi      connected               logicprobe               
ipv6leakintrf0  dummy     connected               pvpn-ipv6leak-protection 
virbr0          bridge    connected (externally)  virbr0                   
p2p-dev-wlp6s0  wifi-p2p  disconnected            --                       
enp5s0          ethernet  unavailable             --                       
lo              loopback  unmanaged               --                       

$ nmcli device show wlp6s0
GENERAL.DEVICE:                         wlp6s0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         8C:C6:81:9C:CD:3B
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     logicprobe
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/7
IP4.ADDRESS[1]:                         172.16.1.22/24
IP4.GATEWAY:                            172.16.1.1
IP4.ROUTE[1]:                           dst = 172.16.1.0/24, nh = 0.0.0.0, mt = 600
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 172.16.1.1, mt = 600
IP4.DNS[1]:                             8.8.8.8
IP6.GATEWAY:                            --

$ nmcli device show wlp6s0
GENERAL.DEVICE:                         wlp6s0
GENERAL.TYPE:                           wifi
GENERAL.HWADDR:                         8C:C6:81:9C:CD:3B
GENERAL.MTU:                            1500
GENERAL.STATE:                          100 (connected)
GENERAL.CONNECTION:                     logicprobe
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/ActiveConnection/7
IP4.ADDRESS[1]:                         172.16.1.22/24
IP4.GATEWAY:                            172.16.1.1
IP4.ROUTE[1]:                           dst = 172.16.1.0/24, nh = 0.0.0.0, mt = 600
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 172.16.1.1, mt = 600
IP4.DNS[1]:                             8.8.8.8
IP6.GATEWAY:                            --

$ nmcli connection show id logicprobe
connection.id:                          logicprobe
connection.uuid:                        9093c97c-ddf8-4743-bdb0-91fd3cd67dd0
connection.stable-id:                   --
connection.type:                        802-11-wireless
connection.interface-name:              wlp6s0
connection.autoconnect:                 yes
connection.autoconnect-priority:        0
connection.autoconnect-retries:         -1 (default)
connection.multi-connect:               0 (default)
connection.auth-retries:                -1
connection.timestamp:                   1686104423
connection.read-only:                   no
connection.permissions:                 --
connection.zone:                        --
connection.master:                      --
connection.slave-type:                  --
connection.autoconnect-slaves:          -1 (default)
connection.secondaries:                 --
connection.gateway-ping-timeout:        0
connection.metered:                     unknown
connection.lldp:                        default
connection.mdns:                        -1 (default)
connection.llmnr:                       -1 (default)
connection.dns-over-tls:                -1 (default)
connection.wait-device-timeout:         -1
802-11-wireless.ssid:                   logicprobe
802-11-wireless.mode:                   infrastructure
802-11-wireless.band:                   --
802-11-wireless.channel:                0
802-11-wireless.bssid:                  --
802-11-wireless.rate:                   0
802-11-wireless.tx-power:               0
802-11-wireless.mac-address:            --
802-11-wireless.cloned-mac-address:     --
802-11-wireless.generate-mac-address-mask:--
802-11-wireless.mac-address-blacklist:  --
802-11-wireless.mac-address-randomization:default
802-11-wireless.mtu:                    auto
802-11-wireless.seen-bssids:            94:A6:7E:F7:2B:E4
802-11-wireless.hidden:                 no
802-11-wireless.powersave:              0 (default)
802-11-wireless.wake-on-wlan:           0x1 (default)
802-11-wireless.ap-isolation:           -1 (default)
802-11-wireless-security.key-mgmt:      wpa-psk
802-11-wireless-security.wep-tx-keyidx: 0
802-11-wireless-security.auth-alg:      --
802-11-wireless-security.proto:         --
802-11-wireless-security.pairwise:      --
802-11-wireless-security.group:         --
802-11-wireless-security.pmf:           0 (default)
802-11-wireless-security.leap-username: --
802-11-wireless-security.wep-key0:      <hidden>
802-11-wireless-security.wep-key1:      <hidden>
802-11-wireless-security.wep-key2:      <hidden>
802-11-wireless-security.wep-key3:      <hidden>
802-11-wireless-security.wep-key-flags: 0 (none)
802-11-wireless-security.wep-key-type:  unknown
802-11-wireless-security.psk:           <hidden>
802-11-wireless-security.psk-flags:     0 (none)
802-11-wireless-security.leap-password: <hidden>
802-11-wireless-security.leap-password-flags:0 (none)
802-11-wireless-security.wps-method:    0x0 (default)
802-11-wireless-security.fils:          0 (default)
ipv4.method:                            auto
ipv4.dns:                               --
ipv4.dns-search:                        --
ipv4.dns-options:                       --
ipv4.dns-priority:                      0
ipv4.addresses:                         --
ipv4.gateway:                           --
ipv4.routes:                            --
ipv4.route-metric:                      -1
ipv4.route-table:                       0 (unspec)
ipv4.routing-rules:                     --
ipv4.ignore-auto-routes:                no
ipv4.ignore-auto-dns:                   no
ipv4.dhcp-client-id:                    --
ipv4.dhcp-iaid:                         --
ipv4.dhcp-timeout:                      0 (default)
ipv4.dhcp-send-hostname:                yes
ipv4.dhcp-hostname:                     --
ipv4.dhcp-fqdn:                         --
ipv4.dhcp-hostname-flags:               0x0 (none)
ipv4.never-default:                     no
ipv4.may-fail:                          yes
ipv4.required-timeout:                  -1 (default)
ipv4.dad-timeout:                       -1 (default)
ipv4.dhcp-vendor-class-identifier:      --
ipv4.dhcp-reject-servers:               --
ipv6.method:                            disabled
ipv6.dns:                               --
ipv6.dns-search:                        --
ipv6.dns-options:                       --
ipv6.dns-priority:                      0
ipv6.addresses:                         --
ipv6.gateway:                           --
ipv6.routes:                            --
ipv6.route-metric:                      -1
ipv6.route-table:                       0 (unspec)
ipv6.routing-rules:                     --
ipv6.ignore-auto-routes:                no
ipv6.ignore-auto-dns:                   no
ipv6.never-default:                     no
ipv6.may-fail:                          yes
ipv6.required-timeout:                  -1 (default)
ipv6.ip6-privacy:                       -1 (unknown)
ipv6.addr-gen-mode:                     stable-privacy
ipv6.ra-timeout:                        0 (default)
ipv6.dhcp-duid:                         --
ipv6.dhcp-iaid:                         --
ipv6.dhcp-timeout:                      0 (default)
ipv6.dhcp-send-hostname:                yes
ipv6.dhcp-hostname:                     --
ipv6.dhcp-hostname-flags:               0x0 (none)
ipv6.token:                             --
proxy.method:                           none
proxy.browser-only:                     no
proxy.pac-url:                          --
proxy.pac-script:                       --
GENERAL.NAME:                           logicprobe
GENERAL.UUID:                           9093c97c-ddf8-4743-bdb0-91fd3cd67dd0
GENERAL.DEVICES:                        wlp6s0
GENERAL.IP-IFACE:                       wlp6s0
GENERAL.STATE:                          activated
GENERAL.DEFAULT:                        yes
GENERAL.DEFAULT6:                       no
GENERAL.SPEC-OBJECT:                    /org/freedesktop/NetworkManager/AccessPoint/5
GENERAL.VPN:                            no
GENERAL.DBUS-PATH:                      /org/freedesktop/NetworkManager/ActiveConnection/7
GENERAL.CON-PATH:                       /org/freedesktop/NetworkManager/Settings/2
GENERAL.ZONE:                           --
GENERAL.MASTER-PATH:                    --
IP4.ADDRESS[1]:                         172.16.1.22/24
IP4.GATEWAY:                            172.16.1.1
IP4.ROUTE[1]:                           dst = 172.16.1.0/24, nh = 0.0.0.0, mt = 600
IP4.ROUTE[2]:                           dst = 0.0.0.0/0, nh = 172.16.1.1, mt = 600
IP4.DNS[1]:                             8.8.8.8
DHCP4.OPTION[1]:                        dhcp_lease_time = 600
DHCP4.OPTION[2]:                        dhcp_server_identifier = 172.16.1.1
DHCP4.OPTION[3]:                        domain_name_servers = 172.16.1.1 192.168.1.1
DHCP4.OPTION[4]:                        expiry = 1686104901
DHCP4.OPTION[5]:                        ip_address = 172.16.1.22
DHCP4.OPTION[6]:                        next_server = 172.16.1.1
DHCP4.OPTION[7]:                        requested_broadcast_address = 1
DHCP4.OPTION[8]:                        requested_domain_name = 1
DHCP4.OPTION[9]:                        requested_domain_name_servers = 1
DHCP4.OPTION[10]:                       requested_domain_search = 1
DHCP4.OPTION[11]:                       requested_host_name = 1
DHCP4.OPTION[12]:                       requested_interface_mtu = 1
DHCP4.OPTION[13]:                       requested_ms_classless_static_routes = 1
DHCP4.OPTION[14]:                       requested_nis_domain = 1
DHCP4.OPTION[15]:                       requested_nis_servers = 1
DHCP4.OPTION[16]:                       requested_ntp_servers = 1
DHCP4.OPTION[17]:                       requested_rfc3442_classless_static_routes = 1
DHCP4.OPTION[18]:                       requested_root_path = 1
DHCP4.OPTION[19]:                       requested_routers = 1
DHCP4.OPTION[20]:                       requested_static_routes = 1
DHCP4.OPTION[21]:                       requested_subnet_mask = 1
DHCP4.OPTION[22]:                       requested_time_offset = 1
DHCP4.OPTION[23]:                       requested_wpad = 1
DHCP4.OPTION[24]:                       routers = 172.16.1.1
DHCP4.OPTION[25]:                       subnet_mask = 255.255.255.0
IP6.GATEWAY:                            --

$ dig @172.16.1.1 askubuntu.com

; <<>> DiG 9.18.12-0ubuntu0.22.04.1-Ubuntu <<>> @172.16.1.1 askubuntu.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 52124
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;askubuntu.com.         IN  A

;; ANSWER SECTION:
askubuntu.com.      30  IN  A   151.101.129.69
askubuntu.com.      30  IN  A   151.101.65.69
askubuntu.com.      30  IN  A   151.101.193.69
askubuntu.com.      30  IN  A   151.101.1.69

;; Query time: 24 msec
;; SERVER: 172.16.1.1#53(172.16.1.1) (UDP)
;; WHEN: Tue Jun 06 21:20:06 CDT 2023
;; MSG SIZE  rcvd: 95

$ dig askubuntu.com
;; communications error to 127.0.0.53#53: timed out
;; communications error to 127.0.0.53#53: timed out
;; communications error to 127.0.0.53#53: timed out

; <<>> DiG 9.18.12-0ubuntu0.22.04.1-Ubuntu <<>> askubuntu.com
;; global options: +cmd
;; no servers could be reached

2023 年 6 月 8 日添加了各种命令的输出

$ ip route
default via 172.16.1.1 dev wlp6s0 proto dhcp metric 600 
169.254.0.0/16 dev virbr0 scope link metric 1000 linkdown 
172.16.1.0/24 dev wlp6s0 proto kernel scope link src 172.16.1.22 metric 600 
192.168.122.0/24 dev virbr0 proto kernel scope link src 192.168.122.1 linkdown

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

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

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

Link 4 (ipv6leakintrf0)
    Current Scopes: DNS
         Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Current DNS Server: ::1
       DNS Servers: ::1
        DNS Domain: ~.

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

$ ls -l /etc/resolv.conf 
lrwxrwxrwx 1 root root 29 Jun  6 21:40 /etc/resolv.conf -> ../run/resolvconf/resolv.conf

$ systemctl --no-pager status systemd-resolved
● systemd-resolved.service - Network Name Resolution
     Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; vendor preset: enabled)
     Active: active (running) since Thu 2023-06-08 10:55:34 CDT; 27min ago
       Docs: man:systemd-resolved.service(8)
             man:org.freedesktop.resolve1(5)
             https://www.freedesktop.org/wiki/Software/systemd/writing-network-configuration-managers
             https://www.freedesktop.org/wiki/Software/systemd/writing-resolver-clients
   Main PID: 1361 (systemd-resolve)
     Status: "Processing requests..."
      Tasks: 1 (limit: 76889)
     Memory: 8.8M
        CPU: 239ms
     CGroup: /system.slice/systemd-resolved.service
             └─1361 /lib/systemd/systemd-resolved

Jun 08 11:20:57 darkroom systemd-resolved[1361]: Using degraded feature set UDP instead of TCP for DNS server ::1.
Jun 08 11:21:08 darkroom systemd-resolved[1361]: Using degraded feature set TCP instead of UDP for DNS server ::1.
Jun 08 11:21:27 darkroom systemd-resolved[1361]: Using degraded feature set UDP instead of TCP for DNS server ::1.
Jun 08 11:21:43 darkroom systemd-resolved[1361]: Using degraded feature set TCP instead of UDP for DNS server ::1.
Jun 08 11:21:43 darkroom systemd-resolved[1361]: Using degraded feature set UDP instead of TCP for DNS server ::1.
Jun 08 11:21:59 darkroom systemd-resolved[1361]: Using degraded feature set TCP instead of UDP for DNS server ::1.
Jun 08 11:21:59 darkroom systemd-resolved[1361]: Using degraded feature set UDP instead of TCP for DNS server ::1.
Jun 08 11:22:14 darkroom systemd-resolved[1361]: Using degraded feature set TCP instead of UDP for DNS server ::1.
Jun 08 11:22:14 darkroom systemd-resolved[1361]: Using degraded feature set UDP instead of TCP for DNS server ::1.
Jun 08 11:22:30 darkroom systemd-resolved[1361]: Using degraded feature set TCP instead of UDP for DNS server ::1.


$ sudo netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      1361/systemd-resolv 
tcp        0      0 0.0.0.0:445             0.0.0.0:*               LISTEN      2623/smbd           
tcp        0      0 0.0.0.0:139             0.0.0.0:*               LISTEN      2623/smbd           
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1647/sshd: /usr/sbi 
tcp        0      0 127.0.0.1:631           0.0.0.0:*               LISTEN      1570/cupsd          
tcp        0      0 192.168.122.1:53        0.0.0.0:*               LISTEN      1915/dnsmasq        
tcp6       0      0 :::445                  :::*                    LISTEN      2623/smbd           
tcp6       0      0 :::139                  :::*                    LISTEN      2623/smbd           
tcp6       0      0 :::22                   :::*                    LISTEN      1647/sshd: /usr/sbi 
tcp6       0      0 ::1:631                 :::*                    LISTEN      1570/cupsd          
udp        0      0 192.168.122.1:53        0.0.0.0:*                           1915/dnsmasq        
udp        0      0 127.0.0.53:53           0.0.0.0:*                           1361/systemd-resolv 
udp        0      0 0.0.0.0:67              0.0.0.0:*                           1915/dnsmasq        
udp        0      0 172.16.1.255:137        0.0.0.0:*                           2561/nmbd           
udp        0      0 172.16.1.22:137         0.0.0.0:*                           2561/nmbd           
udp        0      0 192.168.122.255:137     0.0.0.0:*                           2561/nmbd           
udp        0      0 192.168.122.1:137       0.0.0.0:*                           2561/nmbd           
udp        0      0 0.0.0.0:137             0.0.0.0:*                           2561/nmbd           
udp        0      0 172.16.1.255:138        0.0.0.0:*                           2561/nmbd           
udp        0      0 172.16.1.22:138         0.0.0.0:*                           2561/nmbd           
udp        0      0 192.168.122.255:138     0.0.0.0:*                           2561/nmbd           
udp        0      0 192.168.122.1:138       0.0.0.0:*                           2561/nmbd           
udp        0      0 0.0.0.0:138             0.0.0.0:*                           2561/nmbd           
udp        0      0 127.0.0.1:323           0.0.0.0:*                           1603/chronyd        
udp        0      0 0.0.0.0:631             0.0.0.0:*                           2560/cups-browsed   
udp        0      0 0.0.0.0:33469           0.0.0.0:*                           1398/avahi-daemon:  
udp        0      0 0.0.0.0:5353            0.0.0.0:*                           1398/avahi-daemon:  
udp6       0      0 :::47323                :::*                                1398/avahi-daemon:  
udp6       0      0 ::1:323                 :::*                                1603/chronyd        
udp6       0      0 :::5353                 :::*                                1398/avahi-daemon:

$ systemd-resolve google.com
systemd-resolve: command not found

$ resolvectl query google.com
google.com: resolve call failed: All attempts to contact name servers or networks failed

相关内容