技术支持

为您提供7*24小时在线技术支持、安全技术专家、行业资深安全顾问服务。400-888-1688

系统安全相关

您当前位置首页 > 技术支持 > 系统安全相关

Windows Server 2022防火墙配置与安全策略设置指南

Windows防火墙是Windows操作系统内置的主机防火墙,配合本地安全策略和组策略,可以有效保护Windows Server 2022系统免受网络攻击。

一、启用Windows防火墙

code
# 通过PowerShell管理防火墙
Get-NetFirewallProfile | Format-List Name, Enabled
Set-NetFirewallProfile -Profile Domain,Public,Private -Enabled True

二、添加入站规则

code
# 允许特定端口
New-NetFirewallRule -DisplayName "Allow HTTP 80" -Direction Inbound -Protocol TCP -LocalPort 80 -Action Allow

# 允许特定程序
New-NetFirewallRule -DisplayName "Allow Custom App" -Direction Inbound -Program "C:\Program Files\App\app.exe" -Action Allow

# 限制IP范围
New-NetFirewallRule -DisplayName "RDP from Office" -Direction Inbound -Protocol TCP -LocalPort 3389 -RemoteAddress 192.168.1.0/24 -Action Allow

三、本地安全策略配置

通过 secpol.msc 打开本地安全策略编辑器:

账户策略:

  • 密码必须符合复杂性要求:已启用
  • 密码长度最小值:12个字符
  • 密码最长使用期限:90天
  • 账户锁定阈值:5次无效登录
  • 账户锁定时间:30分钟

四、高级安全审计策略

code
# 启用登录事件审核
auditpol /set /subcategory:"登录" /success:enable /failure:enable

# 启用账户管理审核
auditpol /set /subcategory:"用户账户管理" /success:enable /failure:enable

五、Windows Defender配置

code
# 查看Defender状态
Get-MpComputerStatus

# 启用实时保护
Set-MpPreference -DisableRealtimeMonitoring $false

# 执行快速扫描
Start-MpScan -ScanType QuickScan

六、安全加固建议

  • 禁用不必要的服务(Print Spooler、Remote Registry等)
  • 关闭不必要的端口,使用Netstat -ano检查监听端口
  • 配置远程桌面安全:修改端口、启用NLA、IP限制
  • 配置Windows Update自动安装安全更新

七、高级防火墙规则

code
# 创建出站规则(防止恶意软件外联)
New-NetFirewallRule -DisplayName "Block Outbound 445"     -Direction Outbound -Protocol TCP -LocalPort 445 -Action Block

# 按程序限制网络访问
New-NetFirewallRule -DisplayName "Block App Internet"     -Direction Outbound -Program "C:\Program Files\App\app.exe"     -RemoteAddress Internet -Action Block

# 创建限时规则(如工作时间外禁止访问)
$time = New-NetFirewallTimeRange -Name "WorkHours" -Start "09:00" -End "18:00"
New-NetFirewallRule -DisplayName "RDP Work Hours"     -Direction Inbound -Protocol TCP -LocalPort 3389     -RemoteAddress "192.168.1.0/24" -Action Allow     -TimeRange $time

八、Windows Defender防火墙高级配置

code
# 合并GPO和本地防火墙规则
gpupdate /force

# 导出防火墙策略用于审计
netsh advfirewall export "C:\Firewall_Policy.wfw"

# 导入防火墙策略
netsh advfirewall import "C:\Firewall_Policy.wfw"

# 查看所有规则并导出报表
Get-NetFirewallRule | Select-Object DisplayName, Direction, Action, Enabled | Export-CSV firewall_rules.csv

# 创建安全连接规则(IPsec)
New-NetIPsecRule -DisplayName "Secure RDP"     -RemoteAddress 192.168.1.0/24     -InboundSecurity RequireAuth     -Protocol TCP -LocalPort 3389

九、端口扫描与监控

code
# 查看当前监听端口
netstat -ano | findstr LISTENING

# 使用PowerShell查看
Get-NetTCPConnection -State Listen | Format-Table LocalAddress, LocalPort, OwningProcess

# 查看哪个进程占用端口
Get-Process -Id (Get-NetTCPConnection -LocalPort 80).OwningProcess
这条帮助是否解决了您的问题? 已解决 未解决

安全合格的云服务,让您的业务轻松上云!

立即选购