我无法解析本地主机名,但远程主机名可以工作......
ping unifi
ping: unifi: Temporary failure in name resolution
...
ping google.de
PING google.de (142.250.185.195) 56(84) bytes of data.
64 bytes from google.de (142.250.185.195): icmp_seq=1 ttl=112 time=25.5 ms
64 bytes from google.de (142.250.185.195): icmp_seq=2 ttl=112 time=26.7 ms
64 bytes from google.de (142.250.185.195): icmp_seq=3 ttl=112 time=130 ms
我努力了:
a)在 netplan.yaml 中更改 dns(删除 8.8.8.8):
# This is the network config written by 'subiquity'
network:
ethernets:
ens18:
addresses:
- 192.168.1.12/24
nameservers:
addresses:
- 192.168.1.1
search: []
routes:
- to: default
via: 192.168.1.1
version: 2
进而
sudo netplan apply
WARNING:root:Cannot call Open vSwitch: ovsdb-server.service is not running.
b) 在 /etc/systemd/resolved.conf.d/dns_servers.conf 中删除了 8.8.8.8
sudo nano /etc/systemd/resolved.conf.d/dns_servers.conf
看起来像这样:
[Resolve]
DNS=192.168.1.1
然后重启服务
sudo service systemd-resolved restart
要得到
resolvectl status
Global
Protocols: -LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
resolv.conf mode: stub
DNS Servers: 192.168.1.1
Link 2 (ens18)
Current Scopes: DNS
Protocols: +DefaultRoute +LLMNR -mDNS -DNSOverTLS DNSSEC=no/unsupported
DNS Servers: 192.168.1.1
c) 更改了 resolv.conf 的符号链接
sudo mv -f /etc/resolv.conf /etc/resolv.conf.bak
然后
sudo ln -sv /run/systemd/resolve/resolv.conf /etc/resolv.conf
'/etc/resolv.conf' -> '/run/systemd/resolve/resolv.conf'
sudo nano /run/systemd/resolve/resolv.conf 看起来像这样:
nameserver 192.168.1.1
search .
是的...
d)我已重启机器
最后...什么都没有改变,我可以 ping 远程主机,但不能 ping 本地主机。
这路由器设置为 192.168.1.1
主 DNS 服务器 192.168.1.1(路由器的 IP)辅助 DNS 服务器 8.8.8.8(google)
当然,我可以通过 IP 来 ping 本地主机。
e)我已添加当地的进入我的 /etc/netplan/00-installer-config.yaml
network:
ethernets:
ens18:
addresses:
- 192.168.1.12/24
nameservers:
addresses:
- 192.168.1.1
search:
- local
routes:
- to: default
via: 192.168.1.1
version: 2
我已经重新启动了 netplan:
sudo netplan apply
WARNING:root:Cannot call Open vSwitch: ovsdb-server.service is not running.
名称仍然无法解析...
f)我检查了 avahi 服务
sudo systemctl status avahi-daemon
也许从这里我们可以找到一些东西?
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2024-05-07 17:01:20 UTC; 2h 42min ago
TriggeredBy: ● avahi-daemon.socket
Main PID: 3008 (avahi-daemon)
Status: "avahi-daemon 0.8 starting up."
Tasks: 2 (limit: 9269)
Memory: 944.0K
CPU: 98ms
CGroup: /system.slice/avahi-daemon.service
├─3008 "avahi-daemon: running [automator.local]"
└─3009 "avahi-daemon: chroot helper"
May 07 19:43:06 automator avahi-daemon[3008]: Interface ens18.IPv4 no longer relevant for mDNS.
May 07 19:43:06 automator avahi-daemon[3008]: Joining mDNS multicast group on interface ens18.IPv4 with address 192.168.1.12.
May 07 19:43:06 automator avahi-daemon[3008]: New relevant interface ens18.IPv4 for mDNS.
May 07 19:43:06 automator avahi-daemon[3008]: Registering new address record for 192.168.1.12 on ens18.IPv4.
May 07 19:43:06 automator avahi-daemon[3008]: Withdrawing address record for 192.168.1.12 on ens18.
May 07 19:43:06 automator avahi-daemon[3008]: Leaving mDNS multicast group on interface ens18.IPv4 with address 192.168.1.12.
May 07 19:43:06 automator avahi-daemon[3008]: Interface ens18.IPv4 no longer relevant for mDNS.
May 07 19:43:06 automator avahi-daemon[3008]: Joining mDNS multicast group on interface ens18.IPv4 with address 192.168.1.12.
May 07 19:43:06 automator avahi-daemon[3008]: New relevant interface ens18.IPv4 for mDNS.
May 07 19:43:06 automator avahi-daemon[3008]: Registering new address record for 192.168.1.12 on ens18.IPv4.