Immediately after I switched to Fedora on my main machine I noticed that I can’t SSH into other machines on my local network via their hostname.

My home network is set up in a way that every machine has it’s FQDN hostname, though it has invalid TLD (.local). My naming scheme is as follows:

spock.tomica.local - my main rig
scotty.tomica.local - my laptop

…you get the point. Anyways, when I tried connecting to scotty.tomica.local SSH gave error that it cannot resolve hostname.

I immediately double-checked my router configuration, made sure SSH AND my laptop were both turned on, checked my firewall rules (though, nothing has been changed there in a while).

So lets check if scotty.tomica.local really returns valid IP address:

$ dig a scotty.tomica.local +short

and as we see it does. Lets SSH into that IP address:

ssh root@

It works! Weird, right? Why then SSH cannot resolve hostname scotty.tomica.local and dig can? Well, aparently they don’t resolve it in same way. SSH for domain resolving uses priority list from /etc/nsswitch.conf which on my newly installed Fedora rig contained:

hosts:      files mdns4_minimal [NOTFOUND=return] dns myhostname mymachines

Which obviously has wrong order. For it to resolve local names via DNS I needed to move dns “up a bit” so now it looks like:

hosts:      files dns mdns4_minimal [NOTFOUND=return] myhostname mymachines

After that I was able to connect via SSH by using .local FQDN once again.