13

I want to check the dialect version in SMB connections.

On Windows, Get-SmbConnection will get it.

PS C:\Windows\system32> Get-SmbConnection
ServerName    ShareName     UserName     Credential   Dialect      NumOpens
----------    ---------     --------     ----------   -------      -------
savdal08r2    c$            SAVILLTEC... SAVILLTEC... 2.10         1
savdalfs01    c$            SAVILLTEC... SAVILLTEC... 3.00         1

on macOS, smbutil statshares -a works well.

What should I do on linux?

roaima
  • 107,089
  • 14
  • 139
  • 261
maP1E bluE
  • 233
  • 1
  • 2
  • 5
  • I forgot to explain that linux is a client and I mount the samba server with `mount.cifs -o user=xxx......` – maP1E bluE Oct 30 '18 at 05:01

3 Answers3

15

If you are running a Samba server on Linux, smbstatus should show the protocol version used by each client.

If Linux is the client, it depends on which client you're using: if you're using the kernel-level cifs filesystem support, in all but quite new kernels, the answer was that you look into /proc/mounts to see if the mount options for that filesystem include a vers= option; if not, assume it uses SMB 1.

SMB protocol autonegotiation in kernel-level CIFS/SMB support is rather recent development, and as far as I know, if you don't specify the protocol version you want, the autonegotiation will only indicate the result if you enable CIFS debug messages. but fortunately the developers made it so the negotiation result will always be shown in /proc/mounts.

If you use smbclient or other userspace SMB/CIFS clients (e.g. one integrated to your desktop environment), then it might have its own tools and diagnostics.

telcoM
  • 87,318
  • 3
  • 112
  • 232
  • 1
    The mount points show the version negotiated by default as far as I am aware, have a look at https://unix.stackexchange.com/questions/367884/cifs-randomly-losing-connection-to-windows-share – Rui F Ribeiro Oct 29 '18 at 19:24
  • Thanks,I forgot to explain that linux is a client.i look into the manual of smbstatus cifs-util and find nothing.I didn't expect it to exist in the mount. – maP1E bluE Oct 30 '18 at 04:58
  • 1
    "if the mount options for that filesystem include a `vers=` option; if not, assume it uses SMB 1". Do you happen to have a reference for this statement? For example, on https://wiki.samba.org/index.php/LinuxCIFSKernel, I find this seemingly contradictory statement: "For improved security and performance, SMB3 is the now the default dialect (SMB3.1.1/SMB3.02/SMB3/SMB2.1 dialects are requested by default)." – bers May 06 '20 at 05:32
  • 2
    @bers If the `cifs` filesystem supports autonegotiation, it will always show the `vers=` option according to the actual version negotiated, in `/proc/mounts`. If that option is not there, you're dealing with an old kernel that cannot autonegotiate and very likely defaults to SMB 1. In [kernel.org Git logs](https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/log/fs/cifs/connect.c?h=v5.7-rc4) the default was changed in 2017-07-08 and autonegotiation was added after that in 2017-09-17. Distributions may or may not have backported those patches both at once to their kernel pkgs. – telcoM May 06 '20 at 10:11
  • thanks, @telcoM! – bers May 06 '20 at 11:26
  • Add "-b" option; e.g "smbstatus -b" returns lines like this one: "1662 nobody nogroup (ipv4:192.168.1.100:48372) SMB3_11" – user2431763 Aug 17 '22 at 12:50
  • @user2431763 You probably wanted to add this comment to [the answer of FreeSoftwareServers](https://unix.stackexchange.com/a/478523/258991) and not to mine. Each answer has a separate "add a comment" link. – telcoM Aug 17 '22 at 16:30
  • My `/proc/mounts` (Ubuntu 22.04) keeps showing `vers=default`. But the actual dialect negotiated / used can be queried via `/proc/fs/cifs/DebugData`. – Stefan Aug 31 '22 at 14:53
  • @Stefan looks like the the recent kernels may have changed the behavior again, then. – telcoM Sep 12 '22 at 16:35
8

You can use a script that comes with nmap. nmap/Zenmap(GUI) will allow you to scan a single device or subnet range (your home or office network) and try and show you what SMB protocols are in use.

nmap --script smb-protocols 192.168.1.0/24

The big point here is to cease using SMBv1 due to security concerns. It's also known as 'NT LM 0.12' Zenmap is available for most major platforms.

cdplayer
  • 181
  • 1
  • 4
  • This shows SMB versions offered by the server, but not the actual SMB version used by an actual client-server connection. – bers May 06 '20 at 05:30
2

Use smbstatus >>

https://www.samba.org/samba/docs/current/man-html/smbstatus.1.html

Example Output:

[root@server~]# smbstatus --shares

Service      pid     Machine       Connected at                     Encryption   Signing
---------------------------------------------------------------------------------------------
PubRO        26900   192.168.1.255 Thu Oct 25 12:43:51 AM 2018 PDT  -            -
FreeSoftwareServers
  • 2,482
  • 10
  • 37
  • 57