更换故障路由器后,尝试从 PC“A”(Ubuntu 20.04.6) ssh 到 PC“A”,出现错误消息:ssh: Could not resolve hostname pca.local: Name or service not known
。ping
其他类似命令也找不到主机。
但是,从其他设备(如“pcb”到pca.local
、“pca”到pcb.local
、“pcb”到 )的主机名连接可以pcb.local
正常工作。通过 IP 地址从“pca”到“pca”的连接也是如此。有趣的是,从“pca”到 的连接(pca
没有.local
)实际上可以正常工作!
但这对我来说毫无用处,因为它已经在脚本和其他东西中被熟知pca.local
。LAN 中的所有设备在路由器更改后都保留了其 IP 地址。
我已尝试过:
cat /etc/hostname
正如预期的那样显示自己的名字。systemctl restart systemd-resolved
。/etc/init.d/networking restart
。dhclient -r eth0
。- 几天内不能重新启动那台机器。
输出service avahi-daemon status
● avahi-daemon.service - Avahi mDNS/DNS-SD Stack
Loaded: loaded (/lib/systemd/system/avahi-daemon.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2024-06-12 12:44:47 CST; 1h 49min ago
TriggeredBy: ● avahi-daemon.socket
Main PID: 163913 (avahi-daemon)
Status: "avahi-daemon 0.7 starting up."
Tasks: 2 (limit: 4383)
Memory: 1.3M
CGroup: /system.slice/avahi-daemon.service
├─163913 avahi-daemon: registering [pca.local]
└─163914 avahi-daemon: chroot helper
jun 12 12:44:47 pca avahi-daemon[163913]: Server startup complete. Host name is pca.local. Local service cookie is 2927830272.
jun 12 12:44:47 pca avahi-daemon[163913]: Failed to parse address 'fe80::1%eth0', ignoring.
jun 12 13:08:25 pca avahi-daemon[163913]: Withdrawing address record for fe80::342a:68ff:fec8:fa4e on veth2964dfb.
jun 12 13:08:28 pca avahi-daemon[163913]: Registering new address record for fe80::a881:e7ff:fec7:ead3 on veth6ddcaf7.*.
jun 12 13:34:33 pca avahi-daemon[163913]: Withdrawing address record for fe80::a881:e7ff:fec7:ead3 on veth6ddcaf7.
jun 12 13:34:35 pca avahi-daemon[163913]: Registering new address record for fe80::5c62:9eff:fe29:543e on veth31f1578.*.
jun 12 13:53:37 pca avahi-daemon[163913]: Withdrawing address record for fe80::5c62:9eff:fe29:543e on veth31f1578.
jun 12 13:53:40 pca avahi-daemon[163913]: Registering new address record for fe80::c0eb:52ff:fe22:656d on veth6d79f34.*.
jun 12 14:26:11 pca avahi-daemon[163913]: Withdrawing address record for fe80::c0eb:52ff:fe22:656d on veth6d79f34.
jun 12 14:26:13 pca avahi-daemon[163913]: Registering new address record for fe80::2ce3:93ff:fe4e:8b6f on vethd1fb373.*.
输出ip addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 6a:55:c4:0f:59:ba brd ff:ff:ff:ff:ff:ff
inet 192.168.1.94/24 brd 192.168.1.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 2806:107e:15:413d:bdc8:3b3e:88ec:370e/64 scope global temporary dynamic
valid_lft 540279sec preferred_lft 21774sec
inet6 2806:107e:15:413d:c92f:8f13:fca8:2576/64 scope global temporary deprecated dynamic
valid_lft 453986sec preferred_lft 0sec
inet6 2806:107e:15:413d:7893:65ce:cb5a:a28c/64 scope global dynamic mngtmpaddr noprefixroute
valid_lft 2441181sec preferred_lft 2441181sec
inet6 fe80::4455:f83b:22ee:5769/64 scope link noprefixroute
valid_lft forever preferred_lft forever
输出avahi-resolve-host-name pca.local
pca.local 192.168.1.94
输出cat /etc/avahi/avahi-daemon.conf | grep -v "#"
[server]
use-ipv4=yes
use-ipv6=no
ratelimit-interval-usec=1000000
ratelimit-burst=1000
[wide-area]
enable-wide-area=yes
[publish]
publish-hinfo=no
publish-workstation=no
[reflector]
[rlimits]
输出cat /etc/nsswitch.conf
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: files
group: files
shadow: files
gshadow: files
hosts: files mymachines dns myhostname
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis