Which FW rules to make smb safer (and still usable) in Win and Mac?

Abstract: Restrict SMB firewall rules to trusted subnets and disable NetBIOS to prevent unauthorized access while maintaining file sharing.

Created: 2026-08-23 by
To secure SMB while maintaining usability on Windows and Mac, restrict inbound traffic to ports 445 (TCP) and 137-139 (UDP/TCP) only from trusted local subnets. Disable NetBIOS over TCP/IP if not required for legacy name resolution, and enforce SMBv3 with encryption where supported. This approach blocks external access while allowing internal file sharing.

Understanding SMB Security Risks

SMB (Server Message Block) is a protocol used for providing shared access to files, printers, and other resources on a network. While convenient, it has historically been a target for attacks such as ransomware propagation (e.g., WannaCry) and unauthorized access attempts. The primary vulnerability lies in its default configuration, which often allows connections from any IP address on the network, including untrusted or guest networks. By hardening firewall rules, you can significantly reduce the attack surface without breaking legitimate file sharing workflows.

Configuring Windows Firewall Rules

Windows includes built-in firewall profiles that can be customized to allow SMB traffic only from specific sources. The most critical port for modern SMB communication is TCP 445. Older versions of SMB may use ports 139 (TCP) and UDP 137-138 for NetBIOS name resolution and datagram services.

  1. Open Windows Defender Firewall with Advanced Security from the Start menu.
  2. Navigate to Inbound Rules and click New Rule.
  3. Select Port and choose TCP, then specify Specific local ports: 445.
  4. Allow the connection for Domain, Private, and Public profiles (though Public should ideally be blocked). Restrict this rule to specific IP ranges using the Scope tab if possible.
  5. Repeat steps for UDP ports 137, 138, and TCP port 139 if legacy compatibility is needed.
  6. Create an outbound rule with similar restrictions if strict egress filtering is part of your security policy.

It is crucial to disable NetBIOS over TCP/IP on interfaces that do not require it. This prevents unnecessary broadcast traffic and reduces exposure to NetBIOS-specific exploits. In the Network Connections properties, under IPv4 settings, advanced options allow you to disable NetBIOS on a per-interface basis.

Securing SMB on macOS

macOS uses a different firewall management interface but achieves similar results through Application Layer Filtering. By default, macOS allows incoming connections for certain services, including file sharing, which can be restricted.

  • Go to System Settings > Network > Firewall.
  • Enable the firewall if it is not already active.
  • Click Options to manage application permissions.
  • Locate File Sharing (which uses SMB) and ensure it is set to Allow only locally connected computers if available, or remove it from allowed apps entirely if manual control is preferred.
  • For granular control, use pf (Packet Filter), the BSD-based firewall in macOS. Edit /etc/pf.conf to block inbound traffic on port 445 except from trusted subnets.

Additionally, macOS supports SMB signing and encryption in newer versions. Ensure that SMB Signing is enabled in the sharing preferences to prevent man-in-the-middle attacks. If your environment supports it, enabling SMB Encryption adds an extra layer of protection for data in transit.

Balancing Safety and Usability

Strict firewall rules can sometimes break functionality for users who need to access shared drives from various locations. To maintain usability, consider implementing a Virtual Private Network (VPN) for remote access rather than exposing SMB directly to the internet. For local network users, restricting access by subnet ensures that only devices within your office or home network can connect.

If you are managing multiple systems, group policies (GPO) in Active Directory can automate these firewall configurations across all Windows machines. For Macs, Mobile Device Management (MDM) solutions like Jamf Pro can push pf rules and system configurations consistently. This centralized approach reduces administrative overhead and ensures uniform security posture.

Another consideration is the version of SMB being used. SMBv2 and SMBv3 include significant security improvements over SMBv1, including mutual authentication and encryption. Ensure that both Windows and Mac clients are configured to prefer SMBv3 and disable SMBv1 entirely. Disabling SMBv1 removes the risk of MS17-010 vulnerabilities, which were widely exploited in past ransomware attacks.

Regularly audit your firewall logs to identify any denied connections that might indicate scanning or brute-force attempts. On Windows, check the Security Event Log for event ID 5156 (Filtering Platform Connection) and 5158 (Filtering Platform Drop). On Mac, review /var/log/system.log or use Console.app to monitor pf drop events. These logs provide valuable insights into potential threats and help refine your rules over time.

For teams needing seamless cross-platform collaboration, consider alternative protocols like WebDAV or cloud-based storage solutions that offer built-in security features. However, for local high-speed transfers, hardened SMB remains the most efficient option. Always test changes in a non-production environment before deploying them broadly to avoid disrupting critical workflows.

Frequently Asked Questions

Can I completely disable SMB on my network?

Yes, you can disable SMB entirely if your organization does not rely on local file sharing. This eliminates the attack vector completely. However, many applications still depend on SMB for printer sharing or domain controller communication, so assess dependencies first.

Why do I still get blocked after opening port 445?

You may have additional security layers such as antivirus firewalls or third-party endpoint protection software overriding Windows Firewall rules. Check these applications’ settings to ensure they are not blocking inbound SMB traffic despite your firewall configuration.

Is SMBv1 safe to enable for legacy devices?

No, SMBv1 is considered unsafe due to multiple known vulnerabilities, including EternalBlue. It should never be enabled on modern systems. Instead, upgrade legacy devices to support SMBv2 or v3, or isolate them on a separate VLAN with strict access controls.

How do I verify if SMB encryption is working on Mac?

Use the smbutil statshares command in Terminal to view details of active SMB shares. Look for the encrypt flag indicating that encryption is active for the connection. If it is missing, check the server’s sharing preferences to ensure encryption is enforced.

What happens if I block UDP ports 137-138?

Blocking these ports disables NetBIOS name resolution, which may cause issues for older Windows clients relying on NetBIOS names instead of DNS. Modern systems typically use DNS, so blocking these ports is generally safe and recommended for improved security.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More