本文共 1586 字,大约阅读时间需要 5 分钟。
Windows 系统防火墙是保护网络连接的重要防护措施。本文将详细介绍如何配置 Windows 防火墙,包括启用、禁用规则、定义程序和端口例外、ICMP设置等内容。
默认情况下,Windows 防火墙已启用。如需临时关闭防火墙,可执行以下命令:
netsh advfirewall set currentprofile state off
为了允许特定程序通过防火墙,可以使用以下命令添加入站规则:
netsh advfirewall firewall add rule name="My Application" dir=in action=allow program="C:\MyApp\MyApp.exe" enable=yes
若需开放特定端口,可以执行以下命令:
netsh advfirewall firewall add rule name="Open Port 80" dir=in action=allow protocol=TCP localport=80
若需移除已启用的规则,可执行以下命令:
netsh advfirewall firewall delete rule name=rule nameprogram="C:\MyApp\MyApp.exe"
ICMP 是常用的网络诊断协议。以下命令可配置ICMP规则:
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
防火墙日志可以帮助管理员追踪网络活动。以下命令可启用日志记录:
netsh advfirewall set currentprofile logging enable
默认策略下,允许入站所有协议,阻止出站流量。若需调整默认策略,可执行以下命令:
netsh advfirewall set allprofiles firewallpolicy blockinbound,allowoutbound
为了安全,需关闭不必要的端口。以下命令可阻止常见端口:
netsh advfirewall firewall add rule name="deny tcp 139" dir=in protocol=tcp localport=139 action=block
若需恢复防火墙到出厂状态,可执行以下命令:
netsh advfirewall reset
若需允许远程管理,可执行以下命令:
netsh advfirewall set allprofiles settings remotemanagement enable
若需临时关闭所有防火墙配置文件,可执行以下命令:
netsh advfirewall set allprofiles state off
netsh advfirewall firewall add rule name="PhaseACL" dir=out remoteip=3.3.3.3 action=block
如需进一步了解防火墙配置,可参考相关文档或技术支持资料。
转载地址:http://cdcfk.baihongyu.com/