The SMB Protocol: A Comprehensive Guide to File Sharing

Dhwani Suthar
7 min readMar 23, 2023

--

File sharing is a crucial aspect of modern computing, especially in the world of business. Sharing files across a network is necessary for collaborative projects, remote work, and maintaining a centralized repository of important documents. The SMB protocol, short for Server Message Block, is one of the most widely used file-sharing protocols. In this article, we will discuss everything you need to know about SMB protocol for file sharing.

1. Introduction to SMB

1.1 What is the SMB protocol?

The SMB protocol is a client-server communication protocol used for sharing files, printers, and other resources on a network. Developed by Microsoft, it was first introduced in 1983 as an enhancement to the LAN Manager protocol. The protocol allows multiple clients to access shared resources on a server, providing a centralized storage location for files.

The SMB protocol is also known as CIFS (Common Internet File System), which is an updated version of the protocol. SMB/early CIFS’s implementation had several flaws that limited its applicability to managing small files for end-users. The protocol was “chatty,” which resulted in poor performance over long distances or when there was a lag between client and server. CIFS includes improvements such as support for long file names, symbolic links, and enhanced security features.

1.2 The History of SMB

The SMB protocol has gone through several versions over the years, with each new version introducing new features and security improvements:

  1. SMB1: This is the original version of the protocol, which was introduced in the 1980s. It has several security vulnerabilities and is no longer recommended for use.
  2. SMB2: This version of the protocol was introduced in Windows Vista and Windows Server 2008. It includes improvements such as better performance, scalability, and security.
  3. SMB2.1: This version of the protocol was introduced in Windows 7 and Windows Server 2008 R2. It includes some additional features such as support for larger file sizes and better caching.
  4. SMB3: This is the latest version of the protocol, which was introduced in Windows 8 and Windows Server 2012. It includes several new features, such as encryption, better performance, and support for remote storage access.

It is recommended to use SMB3 for security and performance reasons. However, some older systems may only support SMB1 or SMB2. If you need to support older systems, it is important to be aware of the security risks associated with these older versions of the protocol.

2. How does the SMB protocol work?

2.1 Architecture Model of SMB

The SMB protocol operates on the client-server model. When a client wants to access a shared resource, it sends a request to the server using the SMB protocol. The server then responds with the requested data, allowing the client to access the resource.

The client-server model of SMB allows for centralized management and control of shared resources, making it easy for multiple clients to access and use these resources. However, it also requires careful design and implementation to ensure that the system is secure and reliable. Proper authentication and access control mechanisms must be in place to prevent unauthorized access to shared resources, and the server must be designed to handle large numbers of requests from multiple clients simultaneously.

Figure 2.1.1: User authentication and session establishment sequence

The process involves negotiating the SMB dialect and determining whether the server supports extended security or not, and then proceeding with the session setup based on the capabilities of the server.

If the server supports extended security, the SMB client builds an SMB_COM_SESSION_SETUP_ANDX request in the extended form and sends it to the server, which responds with an extended SMB_COM_SESSION_SETUP_ANDX server response. The security BLOB in the session setup response is built as specified in [RFC2743]. The SMB client then invokes the local security package to determine whether the session setup request should be completed, aborted, or continued.

If the session setup needs to be continued, then additional roundtrips will be required until the session setup can be established. Each additional roundtrip consists of one SMB_COM_SESSION_SETUP_ANDX client request and one SMB_COM_SESSION_SETUP_ANDX server response. The details of the additional roundtrips follow the same sequence as the Session Setup Roundtrip described earlier.

It is important to note that the SMB_COM_NEGOTIATE exchange must not be repeated over the same SMB connection, as this will result in the server disconnecting the client by closing the underlying transport connection. The parameters returned in the SMB_COM_NEGOTIATE response must be used when creating new sessions over the same connection.

2.2 What are the benefits of using the SMB protocol for file sharing?

The SMB protocol offers several benefits for file sharing, including:

  1. Centralized storage: The protocol allows users to store files in a central location, making it easy to access and manage files from multiple devices.
  2. Security: The protocol includes authentication and authorization features that enable administrators to control access to shared resources.
  3. Cross-platform compatibility: The SMB protocol is supported by Windows, macOS, and Linux operating systems, making it easy to share files across different platforms.
  4. High-performance: The protocol is designed for high-performance file sharing, making it ideal for large files or data-intensive applications.

2.3 Demo

Sharing Linux drive to Windows

Step 01: Open the linux file explorer

  • Select any folder that you want to share.
  • Right click on that folder and open properties
Figure 2.3.1 Open properties of folder that we want to share

Step 02 : In document properties

  • Open Network Share and check all the required checkbox.
  • Click on create share
Figure 2.3.2 Sharing folder from document properties

Step 03 — Go to windows PC connected on LAN and add the network location.

Figure 2.3.3 Adding a network location in windows

Step 05: The map network drive window will open and add the address of the host in form of //<host-ip>/<Folder-name>

Figure 2.3.4 IP address of host is 172.16.101.121
Figure 2.3.5 Selecting folder from network

Now the network drive has been mounted and you can access the file system of linux from windows

Figure 2.3.6 Linux drive mounted in Windows

Sharing Windows Network Drive to Linux

Step 01: Find the IP address of the windows computer

Figure 2.3.7 The IP address of the windows PC is 172.16.103.75

Step 02: From the linux explorer go to other locations and enter the address of the windows PC in form of smb://<host-ip-address>

Figure 2.3.8 Connection of windows drive

Now you have successfully mounted the windows drive in linux.

Figure 2.3.9 Connection successful of Windows drive on linux

3. Comparison with NFS and CIFS

NFS (Network File System), SMB (Server Message Block) and CIFS (Common Internet File System) are all file sharing protocols designed to allow client systems to access files over a computer network, most commonly with network attached storage systems.

3.1 Network File System (NFS)

NFS is typically used for Linux and Unix systems while SMB and CIFS are mostly used in Windows environments. This protocol is used for:

Access and share files on remote servers

  1. Access and share files on remote servers
  2. Statefulness was intoduced in version 4
  3. Enables multiple users to access files
  4. Uses TCP/IP or the User Datagram Protocol
  5. Used to deploy mission-critical applications

3.2 Common Internet File System (CIFS)

  1. One of the early dialects of SMB
  2. Stateful sharing protocol
  3. Used mostly with direct hosting and NetBIOS-based transports
  4. Focused on shared file, print, and applications in small local area networks
  5. Generally less scalable

3.3 CIFS, NFS & SMB

CIFS and SMB are often used interchangeably which can be misleading. Now CIFS is considered a chatty-buggy protocol so it’s rarely used in mordern storage systems today. Experts now recommend using SMB version 3.0 or later which are far more secure and provide much better efficiency and performance in WANs and LANs. Newer versions of SMB also added features like end-to-end encyption, custom dialect fencing and other features.

While both NFS and SMB provide file sharing capabilities, there are benefits and drawbacks for each protocol. In general, experts continue to agree than NFS will continue to be used more for Linux-based environments, while SMB will be used for Windows. However, newer version of SMB and NFS are becoming increasingly similar to each other.

4. Conclusion

The SMB protocol is a widely used file-sharing protocol that provides a centralized storage location for files, making it easy to access and manage files from multiple devices. While the protocol offers several benefits, including security, cross-platform compatibility, and high-performance file sharing, there are also potential drawbacks to consider, such as security vulnerabilities and configuration complexity. Understanding the pros and cons of the SMB protocol can help you make informed decisions about how to share files across your network.

--

--