SMB (Server Message Block) is the network file and printer sharing protocol, born in the Windows world. A client mounts a remote shared folder and uses it like a local disk, on TCP port 445. On Linux, the open source implementation is called Samba. This guide explains the difference between SMB and CIFS, how to access a share with smbclient, audit a server with nmap, and harden a Samba configuration. For administrators and blue team profiles, on the command line.
What you will learn
- The difference between SMB, CIFS and Samba.
- The versions of SMB and why SMB1 is dangerous.
- Access a share with
smbclientand mount it. - Audit an SMB server with
nmap. - Harden a Samba configuration.
What are SMB and CIFS?
SMB is the protocol that lets machines share files and printers. Created by IBM in the 80s then extended by Microsoft, it is the mechanism behind corporate network drives and most NAS devices (Synology, TrueNAS, QNAP).
The term CIFS (Common Internet File System) is confusing. It is not a separate protocol: it is the name Microsoft gave in 1996 to a variant of SMB1.
| Term | Reality |
|---|---|
| CIFS | old name of SMB1 |
| SMB | the current protocol (SMB2, SMB3) |
| Samba | the open source implementation for Linux |
Remember the simple rule: CIFS = SMB1, an obsolete dialect. When you mount a share with mount -t cifs, you are actually using a modern SMB client; the cifs name stayed for historical reasons.
SMB versions
Choosing the right version is first of all a matter of security. Three generations coexist, and the first one must disappear.
| Version | Introduced | Key point |
|---|---|---|
| SMB1 (CIFS) | 90s | obsolete, EternalBlue vector, to disable |
| SMB2 | Windows Vista / Server 2008 | signing available, no encryption |
| SMB3 | Windows 8 / Server 2012 | encryption available, to require on the server side |
| SMB 3.1.1 | Windows 10 / Server 2016 | AES-128-GCM encryption, pre-auth integrity |
On the network side, two ports come into play: TCP 445 (SMB directly over TCP, the standard) and TCP 139 (historical SMB encapsulated in NetBIOS). In practice, you watch 445.
Samba: SMB on Linux
Samba is the open source implementation of the SMB protocol for Linux and Unix. It lets a Linux server share files with Windows, macOS and Linux clients, and can even act as an Active Directory domain controller. The current stable version is Samba 4.25, released on 24 September 2026 (read on download.samba.org).
Its configuration lives in /etc/samba/smb.conf: a [global] section for the general settings, then one block per share. A minimal share looks like this:
[partage] path = /srv/partage valid users = alice read only = noAccess a share from the command line
The reference client is smbclient (smbclient package on Debian/Ubuntu, samba-client on RHEL/Fedora). The outputs below come from a real lab: a Samba server in a container exposing a partage share.
-
List the shares of a server, after authentication:
Terminal window smbclient -L //serveur -U aliceSharename Type Commentpartage DiskIPC$ IPC IPC Service (Samba Server) -
Connect to a share: the session is interactive, like an FTP client (
ls,get,put,cd):Terminal window smbclient //serveur/partage -U alice -
Mount the share as a file system with
cifs-utils:Terminal window sudo mount -t cifs //serveur/partage /mnt -o username=aliceDo not force
vers=3.0, contrary to what you read everywhere: automatic negotiation gives a higher dialect, and this guide also hardens the server in a way that makesvers=3.0incompatible.
Audit an SMB server
Before securing, you must see what an attacker sees. Two checks matter: the accepted versions and anonymous access.
nmap enumerates the supported SMB dialects. On the lab, the server accepts SMB 2.1 and 3.0, but not SMB1, which is the expected behaviour:
nmap -p445 --script smb-protocols serveur445/tcp open microsoft-ds| smb-protocols:| dialects:| 2.1| 3.0The second test is anonymous access (null session). On the lab, listing the shares without authentication succeeds, which reveals the share to anyone:
smbclient -L //serveur -NSharename Type Commentpartage DiskHarden a Samba configuration
SMB security rests on a few directives in the [global] section of smb.conf. The goal: refuse old protocols, encrypt, sign and block anonymous access.
[global] server min protocol = SMB3 # alias of SMB3_11: refuses SMB1, SMB2 and SMB3.0 smb encrypt = required # mandatory encryption (SMB3) server signing = mandatory # enforced signing (anti NTLM relay) restrict anonymous = 2 # cuts off null sessionsEach line closes a concrete flaw:
server min protocol = SMB3rules out SMB1 (EternalBlue) and unencrypted SMB2;smb encrypt = requiredencrypts the exchanges (only effective with SMB3);server signing = mandatoryagainst NTLM relay (SMB relay);restrict anonymous = 2cuts off null sessions.
Complete with valid users on each share to restrict access, and above all: never expose port 445 on the Internet. SMB stays confined to the local network, behind a firewall.
Put it into practice
Mount an SMB/CIFS share in a persistent and safe way on a VM: credentials in a protected file, entry in /etc/fstab, and a check of the mount after reboot.
Key points
- SMB is the network file sharing protocol; Samba is its open source Linux implementation.
- CIFS = SMB1, an obsolete dialect to disable (EternalBlue, WannaCry).
- The port to watch is TCP 445; 139 is historical (NetBIOS).
- On the CLI client side:
smbclient -Llists,smbclient //srv/shareconnects,mount -t cifsmounts. Do not forcevers=3.0: negotiation gives 3.1.1, andvers=3.0breaks the mount on a server withserver min protocol = SMB3. - Audit with
nmap --script smb-protocolsand test anonymous access (null session). - Harden Samba:
server min protocol = SMB3,smb encrypt = required,restrict anonymous = 2. - Never expose port 445 on the Internet.
Knowledge check
Check that the essentials of this guide are acquired. The questions only cover what has just been explained here.
Knowledge check
Check what you have learned with this interactive quiz
How it works
- The timer starts when you click Start
- Multiple choice, true/false and short answer questions
- You can move between questions
- Detailed results are shown at the end
Starts the quiz and the timer
Review
(0/0)Score by domain
A domain groups several guides and gets several questions, so its score is more reliable than a per-topic score, which often rests on a single question.
Summary
Strengths
No topic passed at 80% on at least two questions yet.
Weak areas
No topic below the pass mark.
Recommended next
Hints before you try again?
Continue the course: Use iSCSI on Linux
A new full quiz with random questions
Work again only on the questions you missed
FAQ: frequently asked questions about SMB/CIFS
These answers cover the most frequent questions about SMB: the difference with CIFS, port 445, the smbclient commands and the danger of SMB1.
Network file sharing
SMB (Server Message Block) is the network file and printer sharing protocol, born in the Windows world. An SMB client mounts a remote shared folder and uses it like a local disk.- created by IBM in the 80s, extended by Microsoft;
- on Linux/Unix, the open source implementation is Samba;
- listens on TCP port 445.
CIFS is the old SMB1
CIFS (Common Internet File System) is the name Microsoft gave in 1996 to an extended variant of SMB1. It is not a protocol separate from SMB.| Term | Reality |
|---|---|
| CIFS | old name of SMB1 |
| SMB | the current protocol (SMB2, SMB3) |
mount -t cifs, you are actually using a modern SMB client. Remember: CIFS = SMB1, an obsolete dialect not to use any more.Port 445 (and historical 139)
| Port | Use |
|---|---|
| TCP 445 | SMB directly over TCP (standard since Windows 2000) |
| TCP 139 | historical SMB via NetBIOS |
smbclient, the command-line client
# List the shares (authenticated)
smbclient -L //serveur -U alice
# List anonymously (null session)
smbclient -L //serveur -N
# Connect to a share (FTP-like session: ls, get, put)
smbclient //serveur/partage -U alice
The package is smbclient (Debian/Ubuntu) or samba-client (RHEL/Fedora). To mount a share as a file system, use cifs-utils:mount -t cifs //serveur/partage /mnt -o username=alice
Do not force vers=3.0: negotiation obtains 3.1.1, and vers=3.0 breaks the mount against a server with server min protocol = SMB3.To audit a server, nmap enumerates shares and versions: nmap -p445 --script smb-enum-shares,smb-protocols <ip>.Yes, disable it everywhere
SMB1 (CIFS) is obsolete and dangerous. It is the protocol exploited by the EternalBlue (MS17-010) flaw, used by the WannaCry and NotPetya ransomware in 2017 (more than 200,000 systems hit).- Microsoft disables it by default since Windows Server 2019;
- on the Samba side, enforce a minimum version in
smb.conf:
[global]
server min protocol = SMB3
smb encrypt = required
server signing = mandatory
server min protocol = SMB3 rules out SMB1 and SMB2, smb encrypt = required requires encryption and server signing = mandatory the signature (anti NTLM relay). Check that SMB1 is absent with nmap --script smb-protocols.SMB for Linux
Samba is the open source implementation of the SMB protocol for Linux and Unix. It lets a Linux server:- share files and printers with Windows, macOS and Linux clients;
- act as an Active Directory domain controller.
/etc/samba/smb.conf ([global] section then one block per share). The current stable version is Samba 4.25, released in September 2026. It is Samba that lets a Linux and a Windows fleet meet around the same file share.