Ivan Tomica

Problem SSHing into .local machines

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.

Sysadmin on the everlasting journey of learning.


  1. Pete Travis

    2015-10-02 - 15:03

    mdns4_minimal resolves .local addresses out of the box – iff you didn’t explicitly use the .local suffix. You get that part for free with mdns; your original configuration might work with `ssh scotty.tomica.local.local` instead :)

    • Ivan Tomica

      2015-10-02 - 15:55

      Hey Pete,

      thanks for pointing this out to me. In my specific case that wouldn’t work because I do use .local suffix in my host names explicitly. I also have .vm “fake tld” for virtual machines so there’s also that :-)

  2. Aleksandersen

    2016-02-07 - 19:56

    Without a DNS server configured with your naming structure and IPs, this setup of your’s would never work. Use mDNS instead. “.local” would never have “just worked”, and you were probably using mDNS without known it.

    Don’t use “.local” to name your machines; it’s a special-purpose reserved domain and not something you can just give your machines. Install and read up on Avahi. It is an mDNS auto-configuring ad-hock solution that you can use on your home network. There are no TLDs that you can just assign to your own machines without domain name ownership. (“.home” and “.homenet” are proposed in various RFCs, but it’s not gone anywhere yet.

    • Ivan Tomica

      2016-02-07 - 20:14

      It was probably worth mentioning that .local domain was configured on my router so yeah, it apparently needed dns to resolve this domain before returning “notfound”. Also, since this is home network that’s not used for anything serious using .local, .lan, .home or .whateveryoucanthinkof shouldn’t make much difference.

Leave a Reply

Your email address will not be published. Required fields are marked *