Announcement

Collapse
No announcement yet.

can't resolve winxp host name with mount.cifs but can with smbclient

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    can't resolve winxp host name with mount.cifs but can with smbclient

    A problem I'm having...

    - Trying to access a share on winxp home machine named leyre

    have tried:
    sudo mount.cifs //leyre/share /leyre/test/
    sudo mount.cifs //leyre/share /leyre/test/ -o servern=LEYRE
    sudo mount.cifs //leyre/share /leyre/test/ -o servern=<router/DHCP server's IP>

    these return:
    mount error: could not resolve address for leyre: Name or service not known
    No ip address specified and hostname not found

    "smbclient //leyre/share" has no problems though.

    If I use the IP address in the mount.cifs call then everythign is fine but this is not desirable. How do I get leyre resolved to an IP as it does with smbclient?

    Thanks for any insight!

    chris

    #2
    Re: can't resolve winxp host name with mount.cifs but can with smbclient

    I always use something like this to mount SMB shares, but of course the specifics may be different depending on configuration of both the SMB server and SMB client:

    Code:
    sudo mount //192.168.1.23/ShareName /mnt/MountPoint -o rw,uid=1000,gid=1000,username=User,password=UsersPassword
    I note that you are specifically calling upon mount.cifs, which should be fine in theory. However I have learned to trust mount because it is intelligent enough to figure out the specifics of the filesystem for me. In some obscure case that I haven't yet run across, the difference between the two calls may become important.

    If I don't know the IP address of the SMB server then I use nmblookup to find the IP. Example usage:

    Code:
    $ nmblookup MyServer
    querying MyServer on 192.168.1.255
    192.168.1.23 MyServer<00>
    Now you know how to get the IP address of the SMB server, but how can you easily incorporate that into a single command? First let's work on isolating the IP address in the output of nmblookup.

    Code:
    $ nmblookup MyServer | grep -v "querying"
    192.168.1.23 MyServer<00>
    $ nmblookup MyServer | grep -v "querying" | awk '{print $1}'
    192.168.1.23
    As you can see I am exploiting the power of our Bash shell working in concert with our GNU core utilities. Here is what each command does:
    • nmblookup resolves the IP address of the SMB server
    • grep -v performs a regex search for lines which do not contain the pattern
    • awk '{print $1}' selects the first field from the remaining text output of nmblookup


    As you can see, the commands are all joined together with "|" pipes so the output of each command is passed to the next and the effects are cumulative. Really I should say the effects are subtractive since we are removing the stuff we don't want at each step of processing.

    Now how do I incorporate that into a simple mount command? Easily, thanks again to the awesome power of Bash. We can use command substitution to insert the final output of the commands above into the mount command. For example:

    Code:
    $ sudo mount //$(nmblookup MyServer | grep -v "querying" | awk '{print $1}')/ShareName /mnt/ShareName/ -o rw,uid=1000,gid=1000,username=User,password=UsersPassword
    For further reference, please install and read "The GNU Bash Reference Manual".

    Code:
    sudo apt-get install bash-doc
    info bashref
    Also see the bundled documentation for each command.

    Code:
    mount --help
    man mount
    nmblookup --help
    man nmblookup
    grep --help
    man grep
    man awk
    I sincerely hope this helps you. If you don't have success, please post your results back here so we can try to figure out what went wrong.

    Edit:
    I did test all this on my Kubuntu 8.04 Hardy machine, and it does work for me.
    Welcome newbies!
    Verify the ISO
    Kubuntu's documentation

    Comment


      #3
      Re: can't resolve winxp host name with mount.cifs but can with smbclient

      Hi Telengard,
      I appreciate your solution, but I am wondering why I need to mount a winxp share in such a round-about way. This must be a very common task. Why am I not able to resolve my host name to its IP when smbclient does it without any special consideration? What about this servern=LEYRE? Does that do anything?

      so...

      EN GARDE, TELENGARD, CAN YOU ANSWER ME THESE?
      ...(with all due respect)

      chris

      Comment


        #4
        Re: can't resolve winxp host name with mount.cifs but can with smbclient

        Sorry, I can't answer your question. I've never used the servern= option, and don't know anything about it.

        Be careful not to think of a noob like me as any kind of authority on Linux. Like most users, I learn to do things in a way that works for me. Sometimes my ways coincide with what someone else is trying to do, and then maybe I can offer helpful advice. Sometimes not. That's why I always try to accompany my responses to help requests with links or references to official documentation, or information from other higher authorities.

        As I am not able to make mount.cifs work for you directly, please consider the method offered in my first response as a work-around until someone who knows better can offer a more satisfactory answer.
        Welcome newbies!
        Verify the ISO
        Kubuntu's documentation

        Comment


          #5
          Re: can't resolve winxp host name with mount.cifs but can with smbclient

          I just realized that I don't even have the smbfs package installed. I am still able to mount SMB shares without smbfs by using the method outlined in my first response.

          Originally posted by man mount
          Mount options for cifs
          See the options section of the mount.cifs(8 ) man page (smbfs package must be installed).
          Welcome newbies!
          Verify the ISO
          Kubuntu's documentation

          Comment


            #6
            Re: can't resolve winxp host name with mount.cifs but can with smbclient

            i have never mounted a SMB share i just access them on the fly when needed. perhaps i am missing something. try it out open dolphin and for the location use

            smb:/<host name or ip>

            you should see the list of shares on that host.
            Mark Your Solved Issues [SOLVED]
            (top of thread: thread tools)

            Comment


              #7
              Re: can't resolve winxp host name with mount.cifs but can with smbclient

              No problem, Telengard, I appreciate the solution!

              Sithlord, that's pretty simple! Thanks, I'll go with that for awhile...

              chris

              Comment


                #8
                Re: can't resolve winxp host name with mount.cifs but can with smbclient

                any other ideas on mounting?

                Comment

                Working...
                X