Score:1

Why are Nix programs not able to resolve mDNS names when native programs are?

ng flag

My native programs (on Fedora) are able to resolve mDNS / Avahi / zeroconf names, like so:

$ ping felonyspork.local -c 1  
PING felonyspork.local (192.168.88.169) 56(84) bytes of data.
64 bytes from 192.168.88.169 (192.168.88.169): icmp_seq=1 ttl=64 time=1.73 ms

--- felonyspork.local ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 1.734/1.734/1.734/0.000 ms

$ ssh felonyspork.local        
Last login: Mon Apr 25 16:05:34 2022 from 192.168.88.200

$ exit
Connection to felonyspork.local closed.

However, my Nix-installed programs are not:

$ nix-shell -p openssh ssh-tools

[nix-shell:~/src/nixconfig]$ ssh-ping -c 1 felonyspork.local
SSHPING felonyspork.local

--- felonyspork.local ping statistics ---
1 requests transmitted, 0 requests received, 100% request loss

[nix-shell:~/src/nixconfig]$ ssh felonyspork.local
ssh: Could not resolve hostname felonyspork.local: Name or service not known

I have mDNS configured in /etc/nsswitch.conf:

hosts:      files myhostname mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] dns

And avahi-daemon is running on my system.

How can I get Nix programs to correctly resolve mDNS names? This is especially important, because deploying with Morph requires a working Nix SSH session.

Score:1
ng flag

The missing link here is nscd; simply installing nscd and starting the daemon makes the Nix-installed programs work.

$ sudo dnf install nscd
$ sudo systemctl start nscd.service
$ nix-shell -p ssh-tools

[nix-shell:~]$ ssh-ping felonyspork.local
SSHPING felonyspork.local
Pong from felonyspork.local: ssh_seq=1 time=2191 ms
Pong from felonyspork.local: ssh_seq=2 time=1310 ms
^C
--- felonyspork.local ping statistics ---
2 requests transmitted, 2 requests received, 0% request loss
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.