原理就是添加防火墙策略封堵端口,以关闭 445 端口为例,搜索cmd,右击以管理员身份运行,然后键入以下命令:
net stop server
sc config lanmanserver start= disabled
netsh advfirewall set currentprofile state on
netsh advfirewall firewall add rule name="DenyEquationTCP" dir=in action=block localport=445 remoteip=any protocol=tcp
netsh advfirewall firewall add rule name="DenyEquationUDP" dir=in action=block localport=445 remoteip=any protocol=udp
以上适合 Windows 7,如果是 Windows 10,命令改成:
net stop server
sc config lanmanserver start= disabled
netsh firewall set opmode enable
netsh advfirewall firewall add rule name="DenyEquationTCP" dir=in action=block localport=445 remoteip=any protocol=tcp
netsh advfirewall firewall add rule name="DenyEquationUDP" dir=in action=block localport=445 remoteip=any protocol=udp