16

I wonder why my Ubuntu Server 14.04 LTS has problems resolving a hostname from fstab. I tried to mount the following entry:

//NAS-5h2-20/backuppc/  /mnt/backuppc   cifs   auto,user=THEUSER,password=THEPASSWORD,cifsacl,uid=109      0       0

the mount fails with the error

mount: wrong fs type, bad option, bad superblock on //NAS-5h1-15/backuppc,
   missing codepage or helper program, or other error
   (for several filesystems (e.g. nfs, cifs) you might
   need a /sbin/mount.<type> helper program)
   In some cases useful info is found in syslog - try
   dmesg | tail  or so

and the Syslog entry:

Unable to determine destination address.

HOWEVER, this works like a charm if I exchange the hostname NAS-5h2-20 for its IP 192.168.1.29. However, for portability reasons, I'd like to map the mount by hostname within the fstab.

Contents of /etc/hosts is (among other lines):

192.168.1.28    NAS-5h1-15
192.168.1.29    NAS-5h2-20
192.168.1.30    NAS-6h1-04

These Hostnames are not registered with the local DNS-Server. And it's intended do be in some cases able to use different IPs (servercluster/workstation) for DNS and server-internal usage, so I can't register them to the DNS.

It's also no Problem to

ping NAS-5h2-20

.

Thus I'm sure, it's a resolver problem. However, I can't figure out, where. I look at nsswitch.conf, nothing special there:

passwd:         compat
group:          compat
shadow:         compat
hosts:          files dns
networks:       files
protocols:      db files
services:       db files
ethers:         db files
rpc:            db files
netgroup:       nis

And /etc/resolv.conf also looks OK:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 192.168.1.1
search ourdomain.local

So, questions: - why does the resolver fail to read OR ignores the hosts file in this special case?
- is DNS/WINS/ some other resolving method hardcoded into mount.cifs?

Nachtexpress
  • 163
  • 1
  • 1
  • 5
  • 2
    From http://askubuntu.com/a/374699: `sudo apt-get install cifs-utils` –  Jan 28 '16 at 15:21

2 Answers2

13

By default, the samba (cifs) package on some distributions doesn't use the hosts file to resolve the name. Instead, it uses the NetBIOS name to resolve to the IP. There are two ways to go about this:

  • Set samba to use the hosts file for resolution.

In your smb.conf file, find and modify or create the following line:

    [global]
    name resolve order =  host lmhosts wins bcast

and restart samba. This will set samba to a use a standard host name to IP address resolution, using the system /etc/hosts, NIS, or DNS lookups, to resolve the server name. Additionally, added machine-name.domainname as an alias in your hosts file:

    192.168.1.28    machine-name    machine-name.domainname
  • Set the NetBIOS name of the machines you are trying to connect to.

On the machines you're trying to connect to set the following in the smb.conf file:

    netbios name = MachineName

and restart samba.


Ideally, you want to do both of these things, however just setting samba to use the hosts file should work.

References: https://www.samba.org/samba/docs/using_samba/ch07.html

piit79
  • 184
  • 9
Tiksi
  • 146
  • 1
  • 4
  • Tiksi, do you have any ideas how to change this setting without installing the samba package on the machine? Currently speaking, only cifs-utils is installed and would like to avoid installing additional packages only to be able to resolve DNS addresses. Thank you! – David Mar 31 '21 at 02:00
0

I was trying to get this to work with auto.misc, but something was missing.

Installing cifs-utils package and then restarting autofs fixed it.

More details (as requested)...

I use autofs to mount external (network) resources as required.

So, I install autofs, together with samba.

Then I have an entry like this in /etc/auto.misc:

REMFOLDER -fstype=cifs,ro,username=user,password=PW ://windowsbox.my.local.domain/SHAREDFOLDER

That means I can access the SHAREDFOLDER on the windowsbox as /misc/REMFOLDER.

This has worked well for years.

However, on a new installation of Pop OS (based on Ubuntu) and version 21.04, this was not working.

I could use smbclient with the username and password to access the SHAREDFOLDER, but the auto.misc entry was not working.

The message indicated (sorry, didn't note it down) that the username/password was incorrect.

A search led me to here, and the solution that worked was to install the cifs-util package.

russellr
  • 11
  • 4