# 文件服务器

文件服务器是一种计算机或存储服务，它集中存储文件，并通过网络供其他计算机使用，使多个用户和应用程序能够读取、创建和更新共享文件，而无需各自保留副本。大多数文件服务器通过一种网络文件共享协议对外提供存储，最常见的是 Windows 环境中的[服务器消息块](https://www.edgepedia.org/zh/server-message-block)（SMB）协议，或 Unix 和 Linux 环境中的[网络文件系统](https://www.edgepedia.org/zh/network-file-system)（NFS）协议。

| 关键事实 | 详情 |
|---|---|
| 核心协议 | SMB 允许应用程序通过 TCP/IP 或其他传输方式在远程服务器上读取、创建和更新文件；SMB 服务器组件共享文件、打印机和命名管道，并应答客户端请求<sup>[1](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)</sup> |
| 网络端口 | SMB 文件服务器在 TCP 端口 445（或 139）上接受连接；使用 SMB2 或更高版本创建的共享不使用 NetBIOS 端口 137 至 139<sup>[2](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-secure-traffic)</sup> |
| 方言版本 | SMB 3.1.1 受 Windows 10 版本 1607 及更高版本和 Windows Server 2016 及更高版本支持；SMB 3.0 受 Windows 8 和 Windows Server 2012 支持<sup>[1](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)</sup> |
| 安全模型 | 两级保护：使用用户名和密码的用户级身份验证，以及由分配给共享本身的密码控制的共享级身份验证<sup>[3](https://learn.microsoft.com/en-us/windows/win32/fileio/microsoft-smb-protocol-authentication)</sup> |
| 加密 | SMB 加密随 Windows 8 和 Windows Server 2012 中的 SMB 3.0 引入；AES-128-GCM 是 SMB 3.1.1 的默认密码算法，Windows Server 2025 和 Windows 11 24H2 要求所有出站 SMB 客户端连接使用加密<sup>[4](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-feature-descriptions?tabs=windows-server)</sup> |
| 容量管理 | 文件服务器资源管理器的配额可以限制卷或文件夹允许使用的空间，例如对用户的个人服务器文件夹设置 200 MB 限制，并在超过 180 MB 时发送电子邮件通知<sup>[5](https://learn.microsoft.com/en-us/windows-server/storage/fsrm/quota-management)</sup> |
| 安全指南 | CISA 的 #StopRansomware 指南指示各组织在缓解现有依赖关系后禁用 SMB 协议版本 1 并升级到 SMBv3<sup>[6](https://www.cisa.gov/stopransomware/ransomware-guide)</sup> |

## 文件服务器的工作原理

通过 SMB 进行文件共享涉及两种协议角色：SMB 服务器和 SMB 客户端。服务器是共享资源（文件、打印机、[命名管道](https://www.edgepedia.org/zh/named-pipe)）并应答 SMB 客户端请求的组件；在计算机上创建共享时，该计算机的 SMB 服务器负责处理传入连接和文件访问请求。客户端连接远程共享并发送请求；映射网络驱动器或访问 UNC 路径（如 \\server\share）由客户端组件处理。这两种角色都存在于 Windows 客户端和服务器版本中，因此一台 [Windows 11](https://www.edgepedia.org/zh/windows-11) 机器既可以托管共享，也可以连接到其他位置的共享<sup>[1](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)</sup>。

建立连接时，客户端和服务器协商双方都支持的最高 SMB 方言版本。更高的方言版本增加了改进的安全性和性能等特性，同时保持与旧版本的向后兼容性<sup>[1](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)</sup>。

## 协议与实现

**SMB。** [Microsoft Windows](https://www.edgepedia.org/zh/microsoft-windows) 和 OS/2 使用 SMB 进行客户端-服务器文件与打印机共享。在 Unix 方面，[Samba](https://www.edgepedia.org/zh/samba-software) 是一套使用 SMB 协议的 Unix 应用程序套件，允许 Windows 客户端在 Unix 主机上共享文件和打印机，也允许 Unix 用户访问 Windows 系统共享的资源<sup>[7](https://www.samba.org/samba/docs/using_samba/ch01.html)</sup>。

**NFS。** 网络文件系统版本 4 协议是一种分布式文件系统协议，支持传统文件访问，同时集成了文件锁定、强安全协商、客户端缓存和国际化<sup>[8](https://www.rfc-editor.org/info/rfc7530/)</sup>。NFS 是 Linux 文件服务器和托管云 NFS 服务（如 Amazon Elastic File System）的常用协议<sup>[9](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html)</sup>。

**云网关。** 文件服务器不再必须是本地网络上的物理机器。[Amazon S3](https://www.edgepedia.org/zh/amazon-s3) File Gateway 结合了服务和虚拟软件设备，使用 NFS 或 SMB 协议为 Amazon S3 提供文件接口，可部署在本地作为虚拟机或硬件设备，也可部署在 VMware Cloud on AWS 或 Amazon EC2 中<sup>[10](https://docs.aws.amazon.com/filegateway/latest/files3/what-is-file-s3.html)</sup>。Azure Files 提供由云存储支持的 SMB [文件共享](https://www.edgepedia.org/zh/file-sharing)，具有基于身份的身份验证和 Windows ACL 支持<sup>[11](https://learn.microsoft.com/en-us/azure/storage/files/storage-files-authorization-overview)</sup>。

## 访问控制与权限

Microsoft SMB 安全模型有两个级别。在用户级身份验证下，客户端必须提供用户名和密码；一旦通过身份验证，用户就可以访问服务器上所有未同时受共享级安全保护的共享，管理员可以确定哪些用户和组可以访问某个共享。在共享级身份验证下，访问仅由分配给共享的密码控制，不建立用户身份。在这两种情况下，密码在发送前都会使用 NTLM 或较旧的 LAN Manager（LM）质询-响应方法进行加密<sup>[3](https://learn.microsoft.com/en-us/windows/win32/fileio/microsoft-smb-protocol-authentication)</sup>。

**共享权限与文件权限。** SMB 共享权限比文件权限更基本：它们仅提供读取、更改或完全控制三种权限。共享权限和文件权限可以相互覆盖，最终执行的是限制最严格的权限；例如，如果 Everyone 对共享具有完全控制权，但某个用户通过文件级 ACL 对文件夹只有只读访问权限，则该用户适用读取访问权限<sup>[12](https://learn.microsoft.com/en-us/azure/azure-netapp-files/network-attached-storage-permissions)</sup>。SMB 存储权限依赖于在文件或文件夹级别应用的传统 NTFS 访问控制列表<sup>[13](https://learn.microsoft.com/en-us/fslogix/how-to-configure-storage-permissions)</sup>。Windows 还区分在文件夹的“共享”选项卡上设置的共享权限与底层文件系统上的 NTFS 权限<sup>[14](https://learn.microsoft.com/en-us/windows/security/identity-protection/access-control/access-control)</sup>。

云 SMB 共享遵循相同的分层模型。Azure Files 在共享级别、目录级别和文件级别强制执行授权；共享级权限通过 Azure RBAC 角色（如“存储文件数据 SMB 共享读取者”）分配给 Microsoft Entra 用户或组，目录和文件级别则保留并强制执行 Windows ACL<sup>[11](https://learn.microsoft.com/en-us/azure/storage/files/storage-files-authorization-overview)</sup>。AWS S3 File Gateway SMB 共享提供三种身份验证模式：针对任何经过身份验证的 AD 用户的 Microsoft [Active Directory](https://www.edgepedia.org/zh/active-directory) 访问、通过域用户和组的允许和拒绝列表实现的受限访问，以及针对任何持有来宾密码者的来宾访问<sup>[15](https://docs.aws.amazon.com/filegateway/latest/files3/GettingStartedCreateFileShare.html)</sup>。

## 文件服务器流量的安全性

**签名。** SMB 签名将会话密钥生成的签名放入每条 SMB 消息中；如果消息在传输中被更改，哈希将不再匹配，签名还确认发送方和接收方的身份，防止中继攻击。SMB 2.02 签名用 HMAC-SHA-256 取代了 SMB1 中使用的 MD5 方法，SMB 3.0 增加了 AES-CMAC<sup>[16](https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/overview-server-message-block-signing)</sup>。

**加密。** SMB 加密提供 SMB 数据的端到端加密，并保护数据在不可信网络上不被窃听，可按共享或整个文件服务器进行配置。Windows 会自动协商双方都支持的最先进密码算法：SMB 3.0 使用 AES-128-CCM，SMB 3.1.1 默认使用 AES-128-GCM，[Windows Server](https://www.edgepedia.org/zh/windows-server) 2022 及更高版本使用 AES-256-CCM 或 AES-256-GCM<sup>[4](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-feature-descriptions?tabs=windows-server)</sup>。加密不涵盖静态数据，静态数据另行处理，例如通过 BitLocker 驱动器加密<sup>[17](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn551363%28v%3Dws.11%29)</sup>。

**强化。** SMB 3.1.1 增加了强制性预身份验证完整性，对连接的早期阶段进行签名或加密，使中间人攻击者无法篡改协商和会话设置消息，也无法强制降级到较旧的方言版本<sup>[18](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-interception-defense)</sup>。后续版本增加了 NTLM 阻止、一个身份验证速率限制器（延迟基于 NTLM 或 PKU2U 的失败尝试以削弱暴力攻击），以及对签名和加密支持情况的审计<sup>[4](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-feature-descriptions?tabs=windows-server)</sup>。从 Windows 11 24H2 和 Windows Server 2025 开始，内置防火墙规则不再包含 SMB NetBIOS 端口，因为 SMB2 及更高版本的共享不使用端口 137 至 139<sup>[2](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-secure-traffic)</sup>。从 [Windows 10](https://www.edgepedia.org/zh/windows-10) 版本 1709 和 Windows Server 版本 1709 开始，SMBv1 默认不安装<sup>[19](https://learn.microsoft.com/windows/security/threat-protection/security-policy-settings/microsoft-network-client-digitally-sign-communications-always)</sup>，CISA 的勒索软件指南呼吁禁用 SMBv1 并升级到 SMBv3<sup>[6](https://www.cisa.gov/stopransomware/ransomware-guide)</sup>。

## 容量与命名空间管理

Windows 文件服务器包含文件服务器资源管理器，其配额管理节点可创建配额，限制卷或文件夹允许使用的空间，并在接近或超过限制时生成通知；自动应用配额覆盖现有和未来的子文件夹，配额模板可在整个组织中重复使用<sup>[5](https://learn.microsoft.com/en-us/windows-server/storage/fsrm/quota-management)</sup>。

为了在众多服务器之间组织共享，[分布式文件系统](https://www.edgepedia.org/zh/distributed-file-system-microsoft)（DFS）将多台服务器上的共享逻辑分组为一个单一的分层命名空间。DFS 链接指向一个或多个称为目标的共享文件夹；当用户访问链接时，DFS 服务器根据客户端的站点信息选择目标，从而分散请求并在某些服务器发生故障时提供持续访问。DFS 使用 Windows Server 文件复制服务在复制的目标之间复制更改，保留文档的最新更改<sup>[20](https://learn.microsoft.com/en-us/windows/win32/dfs/distributed-file-system-dfs-functions)</sup>。

## 面向应用程序和群集的文件服务器

SMB 3 将文件服务器转变为满足高要求工作负载的存储。Hyper-V 可以将虚拟机文件（包括配置、VHD 文件和快照）存储在 SMB 3.0 文件共享上，SQL Server 可以将用户数据库文件存储在 SMB 文件共享上<sup>[1](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)</sup>。横向扩展文件服务器使用 SMB 3 在多个群集节点之间提供持续可用的文件共享，是 Hyper-V 和 [Microsoft SQL Server](https://www.edgepedia.org/zh/microsoft-sql-server) 工作负载推荐的群集类型；而 DFS 复制和 BranchCache 等功能则需要传统的群集文件服务器用于一般用途<sup>[21](https://learn.microsoft.com/en-us/windows-server/failover-clustering/sofs-overview)</sup>。SMB 还充当超融合和群集存储解决方案（如存储空间直通和存储副本）的互连协议<sup>[1](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)</sup>。

## 更广泛存储格局中的文件服务器

NIST 的《存储基础设施安全指南》（SP 800-209）描述了存储的架构演变：从直连存储到置于网络中并通过各种接口和协议访问的存储资源，最后到对底层存储技术进行抽象的基于云的访问；这种演变增加了管理复杂性和配置错误的可能性，指南通过关于身份验证、授权、数据保护、隔离和加密的建议来应对这些问题<sup>[22](https://www.nist.gov/publications/security-guidelines-storage-infrastructure)</sup>。现代文件服务器正处于这一格局之中：本地 SMB 或 NFS 服务器可以迁移到 Amazon FSx 等托管服务，而不需要 SMB 或 NFS 配置的工作负载可以使用无服务器、完全弹性的文件存储，如 Amazon EFS<sup>[23](https://docs.aws.amazon.com/pdfs/prescriptive-guidance/latest/transitioning-from-vmware-to-the-aws-cloud/transitioning-from-vmware-to-the-aws-cloud.pdf)</sup>。连接要求保持简单：SMB 文件服务器通过 TCP 端口 139 或 445 访问<sup>[24](https://docs.aws.amazon.com/datasync/latest/userguide/datasync-network.html)</sup>，较新的传输方式将覆盖范围扩展到本地网络之外，基于 QUIC 的 SMB 使用 QUIC 和 [TLS 1.3](https://www.edgepedia.org/zh/tls-1-3) 代替 TCP，使用户无需 VPN 即可通过互联网安全地访问边缘文件服务器<sup>[4](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-feature-descriptions?tabs=windows-server)</sup>。

## References

1. [What is SMB File Sharing for Windows and Windows Server? Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/storage/file-server/file-server-smb-overview)
2. [Secure SMB Traffic in Windows Server, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-secure-traffic)
3. [Microsoft SMB Protocol Authentication, Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/fileio/microsoft-smb-protocol-authentication)
4. [SMB features in Windows and Windows Server, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-feature-descriptions?tabs=windows-server)
5. [Quota Management, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/storage/fsrm/quota-management)
6. [#StopRansomware Guide, CISA](https://www.cisa.gov/stopransomware/ransomware-guide)
7. [What Is Samba?, Using Samba, samba.org](https://www.samba.org/samba/docs/using_samba/ch01.html)
8. [RFC 7530: Network File System (NFS) Version 4 Protocol, RFC Editor](https://www.rfc-editor.org/info/rfc7530/)
9. [What is Amazon Elastic File System?, AWS documentation](https://docs.aws.amazon.com/efs/latest/ug/whatisefs.html)
10. [What is Amazon S3 File Gateway, AWS Storage Gateway documentation](https://docs.aws.amazon.com/filegateway/latest/files3/what-is-file-s3.html)
11. [Overview of Azure Files authorization and access control, Microsoft Learn](https://learn.microsoft.com/en-us/azure/storage/files/storage-files-authorization-overview)
12. [Understand NAS share permissions in Azure NetApp Files, Microsoft Learn](https://learn.microsoft.com/en-us/azure/azure-netapp-files/network-attached-storage-permissions)
13. [Configure SMB Storage Permissions, FSLogix, Microsoft Learn](https://learn.microsoft.com/en-us/fslogix/how-to-configure-storage-permissions)
14. [Access Control Overview, Microsoft Learn](https://learn.microsoft.com/en-us/windows/security/identity-protection/access-control/access-control)
15. [Creating a file share, AWS Storage Gateway documentation](https://docs.aws.amazon.com/filegateway/latest/files3/GettingStartedCreateFileShare.html)
16. [Overview of Server Message Block signing, Microsoft Learn](https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/overview-server-message-block-signing)
17. [SMB Security Enhancements, Microsoft Learn](https://learn.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-r2-and-2012/dn551363%28v%3Dws.11%29)
18. [Protect SMB traffic from interception, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/storage/file-server/smb-interception-defense)
19. [Microsoft network client: Digitally sign communications (always), Microsoft Learn](https://learn.microsoft.com/windows/security/threat-protection/security-policy-settings/microsoft-network-client-digitally-sign-communications-always)
20. [Distributed File System (DFS) Functions, Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/dfs/distributed-file-system-dfs-functions)
21. [Scale-Out File Server for application data overview, Microsoft Learn](https://learn.microsoft.com/en-us/windows-server/failover-clustering/sofs-overview)
22. [Security Guidelines for Storage Infrastructure, NIST SP 800-209](https://www.nist.gov/publications/security-guidelines-storage-infrastructure)
23. [Transitioning from VMware to the AWS Cloud, AWS Prescriptive Guidance](https://docs.aws.amazon.com/pdfs/prescriptive-guidance/latest/transitioning-from-vmware-to-the-aws-cloud/transitioning-from-vmware-to-the-aws-cloud.pdf)
24. [AWS DataSync network requirements, AWS documentation](https://docs.aws.amazon.com/datasync/latest/userguide/datasync-network.html)

---
*Initially written Sep 17, 2026 · Reviewed: Oct 15, 2026 · Edited: Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 技术与人造世界 › 计算技术与数字系统 › 网络与安全 › Networking fundamentals and architecture › Networking fundamentals overview

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/file-server

English original: https://www.edgepedia.org/file-server
