0

I've got a pair of Ubuntu machines and a Windows PC. If I create a share on the Windows PC, either Ubuntu computer can mount it using mount -t cifs -o username=me //computername/sharename /mnt/mountpoint. If I create a share on either Ubuntu machine, the Windows computer can see it at //computername/sharename on the network and access it just fine.

However, if I create a share on one Ubuntu computer (either) and try to mount it on the other one, I get mount error: could not resolve address for computername: Unknown error. Using the IP instead of the netbios name gets it mounted just peachy.

Even more strange, nmblookup computername yields the IP address.

What do I need to do on the Ubuntu sharing- and mounting- computers in order to mount the share by netbios name instead of IP address? (Outside of making a bash script to retrieve the IP address from the netbios name every time, or setting static IPs).

0

System-wide NBNS support is not a standard part of Ubuntu (or most other Linux systems). The reason nmblookup works is because it generates and and receives NBNS packets on its own, while all other tools (including mount.cifs) rely on the global "resolve hostname" function to pick the right protocol.

The hostname lookup module for NBNS is called libnss_wins.so.2, usually packaged either as libnss-winbind or just part of smbclient. Once installed, Debian and Ubuntu will automatically activate it, otherwise it needs to be added to the "hosts" line of /etc/nsswitch.conf:

- hosts:          files dns
+ hosts:          files dns wins

To work, the module needs winbindd to be running. (I think previously it used to work standalone, or just with nmbd running, but apparently not anymore.)

Test with:

  • getent ahosts ComputerName for all active modules (those listed in nsswitch.conf),
  • getent -s wins ahosts ComputerName for the wins module specifically (whether active or not).
|improve this answer|||||
  • Could you explain this a little more for me? I'm not sure what to do with the information you've given me so far. Simply adding those two lines to the nsswitch.conf files didn't do anything to the problem. Is there a way for me to check or activate winbindd? Or could I check to see if libnss_wins.so.2 is not functioning properly? – Bo Thompson May 18 '18 at 21:35
  • ...actually, why doesn't my global "resolve hostname" function work with Linux shares when it does with Windows ones? – Bo Thompson May 19 '18 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.