Inconsistent behavior of smbclient/mount.cifs on Port 139 vs. 445 when tunnelling over SSH...

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Situation as follows:
    Remote client = Windows XP
    Server = Linux
I ssh from Remote Windows XP machine to the Linux server.

I would like to mount my remote windows partition on my Linux server.
After MUCH experimenting, I have noticed the following hard to
understand behavior:

- When not using an SSH tunnel, both 'smbclient' and 'mount.cifs' work
  over either port 139 or 445

- When using smbclient over an SSH tunnel, it only works over port 139

- Conversely, when using mount.cifs over an SSH tunnel, it only works
  over port 445

- When using SSH, smbclient works only with remote port forwarding to
  <remote Windows name> while mount.cifs works only with remote port
  forwarding to
  However, if the 2 machines are on the same network then smbclient
  will also work using (but mount.cifs won't work with
  <remote Windows name>)

- When using SSH, smbclient requires an address of form
  '//<remote name>/sharename' while mount.cifs requires addresses of form

- Smbclient will also work substituting  '//' or
  '//<Remote IP>' for '//<remote name>' but gives an error message:
        "Called name not present"
  However, mount.cifs only works with '//' (you can't even
  use '//localhost')

So basically, I have 3 questions:
  1. Why doesn't smbclient work over port 445 when using SSH?
  2. Why doesn't mount.cifs work over port 139 when using SSH?
  3. Why does smbclient require forwarding to <remote_name> while
     mount.cifs requires forwarding to 'localhost'

Here are more details of all the permutations I have tried:
       (1) 'smbclient' vs. 'mount.cifs'
       (2) Ports 139 vs. 445
       (3) For port forwarding I have tried all the following combinations
                -R xxxx:localhost:yyy
                -R xxxx:
                -R xxxx:<remote name>:yyy
                -R xxxx:<remote IP>:yyy
            where yyy=139 or 445, respectively
       (4) When calling smbclient or mount.cifs from the Linux server,
           I have tried all of the following combinations:
                //<remote name>/sharename
                //<remote IP>/sharename

I then observed that only the following combinations work:
(A) smbclient
    Port 139
    -R xxxx:<remote name>:139      
    //<remote name>/sharename

(B) Same as (A) but with:
    //<remote IP>/sharename
    This works but gives an error message "Called name not present"

(C) If the remote Windows machine and the Linux server on the 'same'
    network, then 'smbclient' also works if you use:
       -R xxxx:localhost:139 or  -R xxxx:

(D) If no SSH then smbclient works on either port 139 or 445

(E) mount.cifs
    Port 445
    -R xxxx:localhost:445   or -R xxxx:
    //  (note you can't use //localhost/sharename)
(F) If the remote Windows machine and the Linux server on the 'same'
    network, then 'mount.cifs' also works if you use:
    -R xxxx:<remote_name>:445 or -R xxxx:<remote_IP>:445

Site Timeline