Linux – Why can Windows machines resolve local names when Linux can’t

dhcplinuxwindows

I have a small network with Windows and Linux machines connected to a D-Link DIR-825 router.

The Windows machines on the network can reach all other machines by name while the Linux machines only can reach other machines by IP-address.

I can see all the machines listed with names and their DHCP assigned addresses in the DHCP client status list in the router web admin interface.

Why can't the Linux machines find any other machine by name while Windows has no problem finding the Linux machines?

Best Answer

I'm not a network expert, and I'm also researching a LOT for answers in this topic. My current findings are:

  • Windows uses NetBIOS names, and such protocol, being a broadcast one, allows them to find each other without any central server.

  • Linux machines in modern distros uses natively a protocol called Avahi, which is also a server-independent, broadcast protocol. Local network machines have a suffix .local, so you can ping from Linux to Linux using ping hostname.local, or see them with avahi-discover package. some apps in Gnome use avahi to list machines in the network (for example, the Remote Desktop Viewer)

  • Installing SAMBA on a Linux machine will assign it a NetBIOS name (or, more technically, will make a Linux machine advertise itself in broadcast requests with their NetBIOS name, which is by default their hostname), and that allows Windows machines to find the Linux ones.

  • Gotcha: Although Linux machines with Samba will reply to NetBIOS protocol requests, with default settings in distros like Ubuntu it won't use NetBIOS as a method to resolve names, and that's why Linux machines can't "see" each other or the Windows machines. For that, you need to edit /etc/nsswitch.conf file and add wins to the list in this line:

    hosts: files mdns4_minimal [NOTFOUND=return] dns wins mdns4

  • You may need to install winbind (and, if not installed automatically, libnss-winbind) package for the above to work.

  • So, for the visibility issue, you either install Samba on all Linux machines (and also edit /etc/nsswitch.conf to enable NetBIOS name resolution), or you install Avahi support in Windows machines.

  • As for file sharing, Samba provides Linux machines file-sharing capabilities with Windows. Theres no need to edit /etc/nsswitch.conf for Linux machines to see shared folders of each other and Windows (and vice-versa) in the "Network" section of Nautilus

I hope this helped! :D

Related Topic