Hello,

mounting with cifs requires an extra option for the ip.

Some time ago I've had the same problem with the auto.smb script in the autofs package, and proposed modifications, simply when using the filesystem cifs, do a lookup with the utility
nmblookup like:

ipaddress=$($NMBLOOKUP $key --debug-level=0 2>>/dev/null | grep '<00>' | awk '{ print $1 }')

add the found ip address to the options like:

opts="-fstype=cifs,guest,ip=$ipaddress"

If no ip is found you can exit with an errorcode or continue and mount without ip, but will propably also exit with error, because that does not work.


Attached the modified file. The patch never made it to the source...


Hope it's of any help.

Stef Bon
the Netherlands

ps the name of the attached file is auto.smb.orig, rename this to auto.smb and replace the old one with this.



Ian Shay wrote:

> Think that smbclient is using other methods for netbios name resolving,
> maybe you can try //matsa.full.dns.name or //ip.address

Wow, this seems unfortunate that mount.cifs does not honour smb.conf. At any rate, I cannot use what you are suggesting because the IP addresses are DHCP-assigned and the Linksys router that does the DHCP does not do DNS; it supplies an external DNS server, which of course won't work.

So, given that I don't want to go through the process of giving static IPs and editing fstab or auto.misc every time a new laptop is temporarily added to the network, is there a way to have mount.cifs use BCAST as a way of resolving names?

Furthermore, this was NOT a problem on the older Linux box that I am trying to replace (it has redhat 7 and some older version of samba). What can I do to get at least the same level of functionality as the old one had?

Ian

#!/bin/bash

# This file must be executable to work! chmod 755!

key="$1"

FILESYSTEM="cifs"

if [ "$FILESYSTEM" = "cifs" ]; then

    for P in /bin /sbin /usr/bin /usr/sbin
    do
        if [ -x $P/nmblookup ]
        then
                NMBLOOKUP=$P/nmblookup
                break
        fi
    done

    [ -x $NMBLOOKUP ] || exit 1
    
    ipaddress=$($NMBLOOKUP $key --debug-level=0 2>>/dev/null | grep '<00>' | 
awk '{ print $1 }')

    if [ -z "$ipaddress" ]; then

        exit 1
    
    fi
    
    opts="-fstype=cifs,guest,ip=$ipaddress"
    
    
else

    opts="-fstype=$FILESYSTEM,guest"
    
fi

for P in /bin /sbin /usr/bin /usr/sbin
do
        if [ -x $P/smbclient ]
        then
                SMBCLIENT=$P/smbclient
                break
        fi
done

[ -x $SMBCLIENT ] || exit 1

$SMBCLIENT -gNL $key 2>/dev/null| awk -v key="$key" -v opts="$opts" -F'|' -- '
        BEGIN   { ORS=""; first=1 }
        /Disk/  {
                  if (first)
                        print opts; first=0
                  dir = $2
                  loc = $2
                  # Enclose mount dir and location in quotes
                  # Double quote "$" in location as it is special
                  gsub(/\$$/, "\\$", loc);
                  print " \\\n\t \"/" dir "\"", "\"://" key "/" loc "\""
                }
        END     { if (!first) print "\n"; else exit 1 }
        '

-- 
To unsubscribe from this list go to the following URL and read the
instructions:  https://lists.samba.org/mailman/options/samba

Reply via email to