cmd关闭防火墙端口

发布时间 2023-06-12 18:53:34作者: 枫叶小镇


关闭常用的端口135/137/138/139/445 端口
netsh advfirewall set allprofile state on
netsh advfirewall firewall add rule name=deny_TCP135 dir=in action=block protocol=TCP localport=135
netsh advfirewall firewall add rule name=deny_TCP135 dir=out action=block protocol=TCP localport=135
netsh advfirewall firewall add rule name="deny_UDP135" dir=in action=block protocol=udp localport=135
netsh advfirewall firewall add rule name="deny_UDP135" dir=out action=block protocol=udp localport=135

netsh advfirewall firewall add rule name=deny_TCP137 dir=in action=block protocol=TCP localport=137
netsh advfirewall firewall add rule name=deny_TCP137 dir=out action=block protocol=TCP localport=137
netsh advfirewall firewall add rule name="deny_UDP137" dir=in action=block protocol=udp localport=137
netsh advfirewall firewall add rule name="deny_UDP137" dir=out action=block protocol=udp localport=137

netsh advfirewall firewall add rule name=deny_TCP138 dir=in action=block protocol=TCP localport=138
netsh advfirewall firewall add rule name=deny_TCP138 dir=out action=block protocol=TCP localport=138
netsh advfirewall firewall add rule name="deny_UDP138" dir=in action=block protocol=udp localport=138
netsh advfirewall firewall add rule name="deny_UDP138" dir=out action=block protocol=udp localport=138

netsh advfirewall firewall add rule name=deny_TCP139 dir=in action=block protocol=TCP localport=139
netsh advfirewall firewall add rule name=deny_TCP139 dir=out action=block protocol=TCP localport=139
netsh advfirewall firewall add rule name="deny_UDP139" dir=in action=block protocol=udp localport=139
netsh advfirewall firewall add rule name="deny_UDP139" dir=out action=block protocol=udp localport=139

netsh advfirewall firewall add rule name=deny_TCP445 dir=in action=block protocol=TCP localport=445
netsh advfirewall firewall add rule name=deny_TCP445 dir=out action=block protocol=TCP localport=445
netsh advfirewall firewall add rule name="deny_UDP445" dir=in action=block protocol=udp localport=445
netsh advfirewall firewall add rule name="deny_UDP445" dir=out action=block protocol=udp localport=445