LUOPING0 2020-03-28
方式1:
注意:如果机器有特殊要求,不能开启防火墙,请跳过此方法!
务必先开启防火墙,然后在“高级安全Windows防火墙”入站规则,添加阻止本地445端口的策略,其他系统自带的445端口策略可以忽略。类似截图:
Bat 关闭445端口:封禁其他端口只需要修改localport=138,139等。
@echo off echo "state on firewall......" sc config MpsSvc start=auto netsh advfirewall set allprofiles state on echo "start ICMP...." netsh firewall set icmpsetting 8 echo "add port 445......" netsh advfirewall firewall add rule name="close445tcp" protocol=TCP dir=in localport=445 action=block netsh advfirewall firewall add rule name="close445udp" protocol=UDP dir=in localport=445 action=block pause
Bat 开启445端口:
@echo off echo "state off firewall......" netsh advfirewall set allprofiles state off echo "delete port 445......" netsh advfirewall firewall delete rule name="close445tcp" netsh advfirewall firewall delete rule name="close445udp" pause
方式二:
Win+R,输入:gpedit.msc,打开本地组策略,注意策略做好之后,务必设置“分配”。也可以将策略导出,提供给其他Windows机器