Samba – Configure Avahi nss-mdns not to use local suffix with hostnames because of issue in mounting Samba share

avahihostnamelinux-networkingmdnssamba

How to configure Avahi & nss-mdns to resolve names in my small home network in the same manner as Windows does with NetBIOS or more recently LLMNR.

For Linux, there are two options:

  • Winbind aka NetBIOS for linux, marked as DEPRECATED by many specialists
  • Avahi & nss-mdns – aka Zeroconf, MODERN, sounds good, I crave for similarities with LLMNR.

I gave try to Avahi.
It is already preconfigured in /etc/nsswitch.conf
Instalation OK. Daemon runs, discovery runs, lookup – sort of.

But there is a problem.

ping foopc1
does not work – unknown host

ping foopc2.local

works!

I personally would not mind using "suffixed" names, but some systems do.
Notably Samba. Mounting cifs network shares is not possible.
Smb4k sees other computers nicely, but when attempted to mount a share (smb/cifs) it fails:
could not resolve address for foopc1

It seems that for samba client (mount.cifs) there must be match between network name accepted by hostname resolver (?) and name obtained by nmblookup (??) Please correct me if I'm wrong!

How to make a ping recognize my computers as foopc1 and foopc2 and NOT as foopc1.local and foopc2.local?

According to nss-mdns project homepage
http://0pointer.de/lennart/projects/nss-mdns/ I created /etc/mdns.allow and put there just asterix:

*

..but to no avail.

I also tried to make network name aliases, to map:

foopc1.local -> foopc1

but /etc/hosts does not support this and there is no simple way to get around.

Excluded solutions:

  • editing /etc/hosts – keeping static mapping list is impractical in today's dynamic
    networks
  • local DNS – all computers are powered down frequently, no server like HW here
  • fiddling with wifi router setup, assigning fixed IP to MAC addresses etc. – let's imagine I don't have access to it
  • note: our wifi router does not have DNS server (common practice)
  • PLUS: a challenge to prove that Linux can do same things as Windows with the same user friendly way

See also Why can Windows machines resolve local names when Linux can't?

Best Answer

If you insert "search local" within the file /etc/resolv.conf, the queries will be send with the given domain for example host my-pc result in a first query for my-pc and a second for my-pc.local.

Related Topic