window防火墙禁用相关端口批处理

@echo off
echo 开始操作

netsh advfirewall firewall delete rule name=”禁用tcp端口”
netsh advfirewall firewall add rule name=禁用tcp端口 dir=in protocol=tcp localport=135-139,445,593,1025,2745,3127,3128,6129 action=block
echo 创建禁用TCP端口规则

netsh advfirewall firewall delete rule name=”禁用udp端口”
netsh advfirewall firewall add rule name=禁用udp端口 dir=in protocol=tcp localport=135-139,445,593,1025,2745,3127,3128,6129 action=block
echo 创建禁用udp端口规则

netsh advfirewall firewall delete rule name=”启用的程序端口”
netsh advfirewall firewall add rule name=启用的程序端口 dir=in protocol=tcp localport=80,8080,1433,1521 action=allow
echo 创建启用的程序端口规则

netsh advfirewall firewall set rule name=”文件和打印机共享(回显请求 – ICMPv4-In)” new enable=yes action=block
echo 禁用ping

netsh advfirewall set allprofiles state on
echo 开启防火墙

echo 操作结束
pause

Leave a Reply

Your email address will not be published. Required fields are marked *