CIFS: mount error(112): Host is down

When trying to mount a Windows share using mount, I ran into this problem:

mount -v -t cifs -o username=username,password=password //hostname/sharename /mnt
mount.cifs kernel mount options: ip=XXX.XXX.XXX.XXX,unc=\\hostname\sharename,user=username,prefixpath=sharename,pass=********
mount error(112): Host is down

In my case, the error was due to a protocol mismatch when trying to mount the share: in the latest versions of Windows Server, SMBv1 is disabled.

To reach this conclusion, I ran smbclient in debug mode:

smbclient -L //hostname/sharename -U username -d 3
protocol negotiation failed: NT_STATUS_CONNECTION_RESET

To overcome this issue, I specified the protocol when using mount:

mount -t cifs -o username=username,password=password,vers=3.0 //hostname/sharename /mnt

If you want to use smbclient, add the -m option:

smbclient -L //hostname/sharename -U username -m SMB3

Mounting a Windows share using CIFS

Windows shares can be mounted using cifs option:

mount -t cifs -o username=username,password=password //hostname/sharename /mnt

By default, Windows shares are mounted with 0777 permissions in Linux.

You can change the default permissions using dir_mode and file_mode options in mount:

mount -t cifs -o username=username,password=password,dir_mode=0755,file_mode=0755 //hostname/sharename /mnt

To make the mount persistent, add the entry to /etc/fstab:

//hostname/sharename    /mountpoint   cifs  _netdev,username=username,password=password,dir_mode=0755,file_mode=0755,uid=500,gid=500 0 0

Adding a secondary IP address (CentOS, Fedora, RHEL)

You will not need a secondary NIC but you’ll create virtual adapters as the secondary IP will be routing through the primary.

Network configurations are stored in /etc/sysconfig/network-scripts

network-scripts$ ls -l | grep ifcfg
-rw-r--r--. 1 root root 304 Nov 11 19:04 ifcfg-eth0
-rw-r--r--. 1 root root 254 May 25 2017 ifcfg-lo

You have to name the virtual adapter in a sequential order, e.g., ifcfg-eth0:1, ifcfg-eth0:2 etc.

Copy the physical adapter configuration file:

cp ifcfg-eth0 ifcfg-eth0:1

and configure it to include these parameters:

DEVICE=<device name>
IPADDR=<IP address>
NETMASK=<netmask>

There is no need to configure a MAC address or a default gateway.

To activate the interface you can restart the entire network server (if you can do it) or use:

ifup eth0:1