通过 powershell 管理防火墙

一、基础环境

  操作系统:Microsoft Windows 10 和 Microsoft Windows Server 2019 及以上版本

二、增加规则

New-NetFirewallRule -Name sshd -DisplayName 'OpenSSH Server (sshd)' -Description 'OpenSSH Server 服务'-Profile 'Domain,Private,Public' -Enabled True -Direction Inbound -Protocol TCP -Action Allow -LocalPort 61133

  参数说明

名称 含义
DisplayName 显示名称 文本自定义
Description 描述 文本,自定义
Profile 配置文件 Domain:域
Private:专用
Public:公用
Enabled 启用标志 True:已启用
False:未启用
Direction 方向 Inbound:入站
Outbound:出站
Protocol 协议 TCP:TCP协议
UDP:UDP协议
Action 操作 Allow:允许连接
Deny:阻止连接
LocalPort 本地端口 数值:1-65535

三、查询规则

get-NetFirewallRule -DisplayName 规则显示名称

四、删除规则

Remove-NetFirewallRule -DisplayName 规则显示名称

猜你喜欢

转载自blog.csdn.net/u011046671/article/details/127147203
今日推荐