After swapping a faulty router, trying to ssh from PC "A" (Ubuntu 20.04.6) to PC "A", produces the error message: ssh: Could not resolve hostname pca.local: Name or service not known
. ping
and other such commands can't find the host either.
However, hostname connections from other devices like "pcb" to pca.local
, "pca" to pcb.local
, "pcb" to pcb.local
work. Same with "pca" to "pca" via IP address. Interestingly, connections from "pca" to pca
, without the .local
, actually work!
But that is useless to me because it is already known in scripts and whatnot as pca.local
. All devices in the LAN preserved their IP addresses across router changes.
What I have tried:
cat /etc/hostname
shows its own name as expected.systemctl restart systemd-resolved
./etc/init.d/networking restart
.dhclient -r eth0
.- Can't reboot that machine for a few days.
The output of 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.*.
The output of 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
Output of avahi-resolve-host-name pca.local
pca.local 192.168.1.94
Output of 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]
The output of 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
The reason you cannot
ssh
from PC "A" to PC "A" withssh pca.local
is because you don't have any mdns service defined in your/etc/nsswitch.conf
file.First, you need to ensure
avahi-daemon
andlibnss-mdns
are installed.avahi-daemon
is already installed.libnss-mdns
is installed, runapt-cache policy libnss-mdns
. If it's not installed, install withsudo apt install libnss-mdns
.Next, you need to check that the
hosts
line in/etc/nsswitch.conf
hasmdns4_minimal [NOTFOUND=return]
added to it.If
libnss-mdns
was not installed, then installation will update/etc/nsswitch.conf
appropriately.Otherwise, edit
/etc/nsswitch.conf
and change thehosts
line from this:...to this:
To quote the man-page for nsswitch.conf(5), the purpose of the
hosts
line in/etc/nsswitch.conf
is the following:Here is a brief explanation of the services:
/etc/hosts
first.local
/etc/resolv.conf
This AskUbuntu answer has some good info as does this one.