大网数据广告活动
服务器运维问答

CIFS mount in fstab succeeds on IP, fails on hostname written in /etc/hosts

· 52CE 我爱测

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 …

问题原文

原帖链接 · Nachtexpress · CC BY-SA 3.0

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?

已采纳解答

原帖链接 · Tiksi · CC BY-SA 4.0

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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2014-07-01)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0 / CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。