在最新的 Ubuntu 更新后,可能是由于我的系统中安装了 pihole,服务器无法解析地址。我完全卸载了 pihole,但问题仍然存在。我看到在最新的 Ubuntu 版本中使用了 netplan,所以我尝试像这样配置 yaml 文件
network:
version: 2
renderer: networkd
ethernets:
eno1:
addresses:
- 192.168.5.20/32
gateway4: 192.168.5.1
nameservers:
search: [local]
addresses: [192.168.5.1]
我应用了配置,并且在 system-resolve --status 命令中,应用了正确的配置。指向的 DNS 服务器正在运行,因为我的所有设备/手机/NAS/等都运行正常,没有问题。
我尝试编辑 /etc/systemd/resolved.conf,但问题仍然存在。唯一能暂时解决问题的方法是修改 /etc/resolved.conf,同时使用相同的 dns 服务器,这样地址似乎可以毫无问题地解析。问题是每次重启时配置都会丢失,并被 127.0.0.1 替换,系统停止解析地址。有没有关于如何在不重新安装所有内容的情况下完全恢复网络配置的帮助?
pkg -l 之后域名系统我得到:
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================-=============-============-================================
un dnsmasq <none> <none> (no description available)
ii dnsmasq-base 2.80-1ubuntu1 amd64 Small caching DNS proxy and DHCP
un dnsmasq-base-lua <none> <none> (no description available)
ls -al /etc/resolv.conf 之后我得到:
lrwxrwxrwx 1 root root 29 May 4 00:48 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
在 cat /etc/resolv.conf 之后
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 192.168.5.13
search local
在 cat /etc/network/interfaces 之后:
ifupdown has been replaced by netplan(5) on this system. See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
# sudo apt install ifupdown
后cat /etc/systemd/resolved.conf
:
# This file is part of systemd.
...
[Resolve]
DNS=192.168.5.1
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=yes
#ReadEtcHosts=yes
执行命令 system-resolve --status 后我得到:
Global
LLMNR setting: no
MulticastDNS setting: no
DNSOverTLS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.5.1
DNSSEC NTA: 10.in-addr.arpa
16.172.in-addr.arpa
168.192.in-addr.arpa
17.172.in-addr.arpa
18.172.in-addr.arpa
19.172.in-addr.arpa
20.172.in-addr.arpa
21.172.in-addr.arpa
22.172.in-addr.arpa
23.172.in-addr.arpa
24.172.in-addr.arpa
25.172.in-addr.arpa
26.172.in-addr.arpa
27.172.in-addr.arpa
28.172.in-addr.arpa
29.172.in-addr.arpa
30.172.in-addr.arpa
31.172.in-addr.arpa
corp
d.f.ip6.arpa
home
在 cat /etc/NetworkManager/NetworkManager.conf 之后:
there's a blank line only displayed.
在 sudo systemctl status systemd-resolved 之后我得到:
Systemd-resolved.service - Network Name Resolution
Loaded: loaded (/lib/systemd/system/systemd-resolved.service; enabled; ve
Active: active (running) since Sun 2019-07-28 15:39:52 CEST; 4h 44min ago
Docs: man:systemd-resolved.service(8)
https://www.freedesktop.org/wiki/Software/systemd/resolved
https://www.freedesktop.org/wiki/Software/systemd/writing-network
https://www.freedesktop.org/wiki/Software/systemd/writing-resolve
Main PID: 3349 (systemd-resolve)
Status: "Processing requests..."
Tasks: 1 (limit: 4915)
Memory: 2.4M
CGroup: /system.slice/systemd-resolved.service
└─3349 /lib/systemd/systemd-resolved
Jul 28 15:39:51 plex systemd[1]: Starting Network Name Resolution...
Jul 28 15:39:52 plex systemd-resolved[3349]: Positive Trust Anchors:
Jul 28 15:39:52 plex systemd-resolved[3349]: . IN DS 19036 8 2 49aac11d7b6f6
Jul 28 15:39:52 plex systemd-resolved[3349]: . IN DS 20326 8 2 e06d44b80b8f1
Jul 28 15:39:52 plex systemd-resolved[3349]: Negative trust anchors: 10.in-a
Jul 28 15:39:52 plex systemd-resolved[3349]: Using system hostname 'plex'.
Jul 28 15:39:52 plex systemd[1]: Started Network Name Resolution.
是的,重启后它会变成 127.0.0.1
cat /run/systemd/resolve/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 directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# 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 192.168.5.1
search local
和
cat /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 "resolvectl 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
options edns0
search local
sudo lshw -C 网络给我:
*-network
description: Wireless interface
product: Wireless 8265 / 8275
vendor: Intel Corporation
physical id: 0
bus info: pci@0000:3a:00.0
logical name: wlp58s0
version: 78
serial: f8:63:3f:08:69:43
width: 64 bits
clock: 33MHz
capabilities: pm msi pciexpress bus_master cap_list ethernet physical wireless
configuration: broadcast=yes driver=iwlwifi driverversion=5.0.0-20-generic firmware=36.9f0a2d68.0 latency=0 link=no multicast=yes wireless=IEEE 802.11
resources: irq:129 memory:dc100000-dc101fff
*-network
description: Ethernet interface
product: Ethernet Connection (4) I219-V
vendor: Intel Corporation
physical id: 1f.6
bus info: pci@0000:00:1f.6
logical name: eno1
version: 21
serial: f4:4d:30:6a:0d:e7
size: 1Gbit/s
capacity: 1Gbit/s
width: 32 bits
clock: 33MHz
capabilities: pm msi bus_master cap_list ethernet physical tp 10bt 10bt-fd 100bt 100bt-fd 1000bt-fd autonegotiation
configuration: autonegotiation=on broadcast=yes driver=e1000e driverversion=3.2.6-k duplex=full firmware=0.1-4 ip=192.168.5.20 latency=0 link=yes multicast=yes port=twisted pair speed=1Gbit/s
resources: irq:125 memory:dc280000-dc29ffff
*-network:0
description: Ethernet interface
physical id: 2
logical name: br-c20159f39807
serial: 02:42:82:dc:5c:c1
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.18.0.1 link=yes multicast=yes
*-network:1
description: Ethernet interface
physical id: 3
logical name: veth3e14a42
serial: 4e:59:53:86:1b:a8
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.130.45 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:2
description: Ethernet interface
physical id: 4
logical name: vethb1a5fa9
serial: ea:45:16:b6:ee:13
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.6.237 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:3
description: Ethernet interface
physical id: 5
logical name: docker0
serial: 02:42:18:4e:ed:2f
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.17.0.1 link=no multicast=yes
*-network:4
description: Ethernet interface
physical id: 6
logical name: veth1f469d7
serial: 46:51:7b:28:7a:11
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.74.93 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:5
description: Ethernet interface
physical id: 7
logical name: vethcd445dd
serial: 26:6e:38:e2:da:1f
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.168.110 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:6
description: Ethernet interface
physical id: 8
logical name: veth9810524
serial: ee:a9:1f:d7:e3:b7
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.61.7 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:7
description: Ethernet interface
physical id: 9
logical name: veth538f6bc
serial: 5e:b5:25:5c:b9:5d
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.52.246 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:8
description: Ethernet interface
physical id: a
logical name: br-03e193556b79
serial: 02:42:77:59:85:26
capabilities: ethernet physical
configuration: broadcast=yes driver=bridge driverversion=2.3 firmware=N/A ip=172.20.0.1 link=yes multicast=yes
*-network:9
description: Ethernet interface
physical id: b
logical name: vethb3f499f
serial: 6a:be:8c:01:13:ec
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.196.173 link=yes multicast=yes port=twisted pair speed=10Gbit/s
*-network:10
description: Ethernet interface
physical id: c
logical name: vethb56cefe
serial: 6a:74:3a:90:6b:60
size: 10Gbit/s
capabilities: ethernet physical
configuration: autonegotiation=off broadcast=yes driver=veth driverversion=1.0 duplex=full ip=169.254.82.220 link=yes multicast=yes port=twisted pair speed=10Gbit/s
答案1
来自评论...
安装和删除 pihole 后,DNS 不再起作用。我们通过以下方式更改了所使用/run/resolvconf/resolv.conf
的符号链接.../etc/resolv.conf
sudo rm -i /etc/resolv.conf
sudo ln -s /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf