Linux – Samba: connecting to a DFS share using smbclient

cifslinuxnetwork-sharesamba

I have a problem connecting to a DFS share using smbclient. It does work using mount -t cifs.
Namely, when I do

sudo mount -t cifs //<dfs-url>/<service> ~/mountpoint/ -o username=<username>   

things work perfectly. However, doing

smbclient //<dfs-url>/<service> -U <username> -W <workgroup>
Enter <username>'s password:
Domain=[<domain>] OS=[Windows Server 2012 R2 Datacenter 9600] Server=[Windows Server 2012 R2 Datacenter 6.3]
tree connect failed: NT_STATUS_BAD_NETWORK_NAME 

I would expect that if I can connect using a cifs mount, I should be able to connect using smbclient.
Am I doing something wrong with the smbclient invokation?
Has anbody managed to connect to a DFS share using smbclient?

Best Answer

The error "tree connect failed: NT_STATUS_BAD_NETWORK_NAME" is because the path is not correct. Example: Path = //<dfs-url>/data/share1 Path = //<dfs-url>/data/share2

When mounting cifs, you can mount //<dfs-url>/data and see both shares. With smbclient you only can use //<dfs-url>/data/share1 or share2