Created
September 9, 2021 15:23
-
-
Save Flashwalker/18a43a68bc3a4451d004cd1f241014f1 to your computer and use it in GitHub Desktop.
Block remote smb network in connections on Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
::Set firewall on | |
netsh advfirewall set currentprofile state on | |
::Block in connections from all | |
netsh advfirewall firewall add rule name="blockSMBforeign_TCP-139" action=block protocol=TCP dir=in localport=139 remoteip=any | |
netsh advfirewall firewall add rule name="blockSMBforeign_TCP-445" action=block protocol=TCP dir=in localport=445 remoteip=any | |
::Allow only local connections from 192.16.0.0/16 subnet | |
netsh advfirewall firewall add rule name="allowSMB_0_0_16_TCP-139" action=allow protocol=TCP dir=in localport=139 remoteip=192.168.0.0/16 | |
netsh advfirewall firewall add rule name="allowSMB_0_0_16_TCP-445" action=allow protocol=TCP dir=in localport=445 remoteip=192.168.0.0/16 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment