smbclient finds NAS, but mount can't find it
I'm trying to auto-mount a NAS drive I have to Ubuntu Server, but it's giving me an issue where it doesn't seem to find the NAS name on the network when I mount it.
Pulling up the shares like this works fine, and gives me a print out of the shares on the NAS.
smbclient -L //NASNAMEHERE
I proceeded to add the share I want to /etc/fstab using the line below. The .smbcredentials
file contains the user/pass combo for RW access to the share.:
//NASNAMEHERE/Archive /home/user/Archive cifs credentials=/home/user/.smbcredentials,iocharset=utf8,file_mode=0777,dir_mode=0777 0 0
However, when I run sudo mount -a
to mount the new device, it gives me this.
mount error: could not resolve address for martinez-nas: Unknown error
It seems to be a networking issue, as I can't seem to ping the NAS by name directly, but I'm confused about why this won't work, if smbclient
can properly find the NAS and list the shares.
Running Ubuntu Server 14.04.2
Found this question which answers it for me. Basically, Samba can do hostname lookups, while mount can't. I set the IP address instead of the hostname in /etc/fstab
, and it worked like a charm.
The difference is the samba client does netbios name lookups while mount.cifs does host name lookups which requires some kind of lan-side DNS mechanism. CIFS has no idea what a netbios name is.
There are some solutions:
[1] Some routers provide that lan side DNS mechanism automatically. That's why only a subset of CIFS users experience this name resolution problem. Perhaps your router does this but it is not enabled - it's worth investigating.
[2] You could give your nas a static ip address. This can also be done on the router if you don't want to do it on the nas itself. Then just access the server by that ip address.
[3] You could use an mDNS qualified host name ( hostname.local ) if your nas has one. Currently Linux, Win10 ( you have to enable it ), Apple Macs, and these network devices designed to work with Macs all have these host names. If you know the current IP address of the nas you can use this command ( with the correct ip address ) to see if it has one:
avahi-resolve -a 192.168.1.208
Use the name from that output and attach a .local at the end if it doesn't already have that.
[4] And lastly is the much misunderstood and misinterpreted winbind "gimmick":
If an application wants to resolve the ip address of a host name it looks to /etc/nsswitch.conf file to know how. If you look at the file you will see the different ways it does that: "files" ( /etc/hosts ), "mdns4" ( mDNS ), and "dns" itself. Nowhere in there is any reference to netbios. So add it by placing the parameter wins before the parameter dns.
wins in turn needs the libnss_wins.so library and you get that when you install the following package:
sudo apt install libnss-winbind
Installing that package also installs winbind itself.
So you end up installing something ( winbind ) designed for something completely different in order to make a netbios name appear as a host name to things like CIFS and ping. Back in the day this "solution" had consequences as it sometimes slowed down internet access but given the relative speed increases over the years I'm guessing no one would notice.