![如何修复名称解析失败](https://linux22.com/image/1191522/%E5%A6%82%E4%BD%95%E4%BF%AE%E5%A4%8D%E5%90%8D%E7%A7%B0%E8%A7%A3%E6%9E%90%E5%A4%B1%E8%B4%A5.png)
我有一个相当新的 Kubuntu 安装并且我以某种方式弄乱了它的名称解析。
root @ asus-f751s ~ # host www.ecosia.org 22-12-19 12:05
;; communications error to 127.0.0.1#53: connection refused
root @ asus-f751s ~ :-( # ls -l /etc/resolv.conf 22-12-19 12:20
lrwxrwxrwx 1 root root 27 Dec 19 11:30 /etc/resolv.conf -> /run/resolvconf/resolv.conf
root @ asus-f751s ~ # ls -l /run/resolvconf/resolv.conf 22-12-19 12:20
ls: cannot access '/run/resolvconf/resolv.conf': No such file or directory
root @ asus-f751s ~ :-( # systemctl | grep -Fi resol 22-12-19 12:04
systemd-resolved.service loaded active running Network Name Resolution
名称解析守护进程似乎正在运行,从上面的代码片段可以看出。我不确定解析状态是否没有可疑之处。resolv.conf 模式被告知丢失,但如果它指的是文件,则没有新信息。
root @ asus-f751s ~ :-( # resolvectl status 22-12-19 12:21
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: missing
Link 2 (enp2s0f1)
Current Scopes: none
Protocols: -DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
Link 3 (wlp3s0)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 192.168.2.1 fe80::1%21849
DNS Domain: speedport.ip
甚至连运行目录都丢失了。
root @ asus-f751s ~ # echo "nameserver 192.168.2.1 22-12-19 12:32
nameserver fe80::1%wlp3s0
search speedport.ip" > /run/resolvconf/resolv.conf
zsh: no such file or directory: /run/resolvconf/resolv.conf
root @ asus-f751s ~ :-( # ls -l /run/resolvconf 22-12-19 12:32
ls: cannot access '/run/resolvconf': No such file or directory
我可以实现临时修复(重启后它就消失了)
root @ asus-f751s ~ # mkdir /run/resolvconf 22-12-19 12:32
root @ asus-f751s ~ # echo "nameserver 192.168.2.1 22-12-19 12:33
nameserver fe80::1%wlp3s0
search speedport.ip" > /run/resolvconf/resolv.conf
root @ asus-f751s ~ # host www.ecosia.org 22-12-19 12:33
www.ecosia.org is an alias for www.ecosia.org.cdn.cloudflare.net.
www.ecosia.org.cdn.cloudflare.net has address 104.18.14.27
www.ecosia.org.cdn.cloudflare.net has address 104.18.15.27
www.ecosia.org.cdn.cloudflare.net has IPv6 address 2606:4700::6812:f1b
www.ecosia.org.cdn.cloudflare.net has IPv6 address 2606:4700::6812:e1b
但我希望有一个永久的解决方案。
如果有人能启发我,我会很高兴。