34

I've got several Ubuntu machines on my network at home, but the DNS is provided by a windows server (2K). When I ssh to them from another , if I ssh to them as "machine" I can't connect, but if I connect as "machine.local" I can connect.

I think similarly, I can't connect from a windows client (like putty).

What's going on here? - it's clearly an Ubuntu thing.

3
  • 1
    Actually, it looks like a DNS thing, not like an Ubuntu thing at all (especially since you “can't connect” from the Windows machine — and what is the error message anyway?). What is your DNS configuration (nameserver and search)? How does dig machine1 differ from dig machine1.local? Sep 20, 2010 at 23:34
  • Would you happen to have Apple Bonjour or another Zeroconf implementation installed on the Windows 2000 Server? Sep 21, 2010 at 3:04
  • If you happen to know why Android can't browse to a device on the network using its .local hostname (devicename.local does not work but it can browse to devicename without .local), I'd appreciate an answer at android.stackexchange.com/q/230644/22600 Thanks!
    – Ryan
    Oct 29, 2020 at 19:08

2 Answers 2

43

By default, Ubuntu includes avahi. This is an implementation of zeroconf which allows computer hostnames to be resolved with the virtual ".local" name. Whenever your computer tries to connect to "hostname.local", avahi will perform local network broadcasts to see if there any computers with that hostname. Other computers running avahi (or something compatible) should answer.

If you look in /etc/nsswitch.conf, you will find the following line:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

The mdns4_minimal is the configuration setting that makes this redirection work.

Your question actually suggests that avahi is running successfully as you say that you can connect to your Ubuntu computers using "hostname.local". However, you do not make it clear ("When I ssh to them from another, ...") if you are trying to connect from another Ubuntu computer, or from another Windows computer. Without installing other software such as Bonjour, Windows computers cannot resolve zeroconf-style "hostname.local" names.

2
  • Avahi Link for the interested. In short, its complicated.
    – meawoppl
    Sep 9, 2013 at 23:12
  • This answer is rather old now, but Windows 10 will definitely resolve "hostname.local" style names without anything extra (at least... no third-party extras... who knows what garbage is running internally) Jun 15 at 14:11
14

To fix your issue, you just need Avahi. This announces your Ubuntu machine names to the Windows lot.

sudo apt-get install avahi-daemon

machinename.local works thanks to another implementation of zeroconf (of which Avahi is also) called Bonjour, created (IIRC) by Apple. It's installed by default. I don't know why Avahi isn't also but given the confusion it causes people, it probably aught to be.

There's more on this on Wikipedia: http://en.wikipedia.org/wiki/.local

4
  • Avahi uses .lan I think
    – Broam
    Sep 20, 2010 at 17:15
  • 8
    No, avahi uses .local, this is required by the mDNS spec.
    – Kees Cook
    Oct 27, 2010 at 6:13
  • Why would you expect macOS to install multiple zeroconf implementations? I don't see what confusion the existence of Bonjour and Avahi could cause any remotely reasonable person. I'm not trying to be combative, I'm just honestly baffled by what you're saying. AFAI can tell, what you're saying is like saying "Finder is installed by default on macOS. I don't know why explorer.exe isn't also given the confusion it causes people". Sep 4, 2022 at 20:18
  • @MarcelBesixdouze I didn't air any expectation of OS X (as it was still called 12 years ago). I was suggesting Ubuntu should have something I thought it didn't have.
    – Oli
    Sep 6, 2022 at 8:28

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .