简体   繁体   English

Netsh.exe命令会覆盖现有的防火墙规则吗?

[英]Does Netsh.exe command overwrite existing firewall rules?

I'm using a netsh command that add a firewall rule on windows 2012 r2 server. 我正在使用netsh命令在Windows 2012 r2服务器上添加防火墙规则。

My command is like this: 我的命令是这样的:

Netsh.exe advfirewall firewall add rule name="name" protocol="TCP" localport=1234 dir=in enable=yes action=allow

What happen if i already have a rule with another name and same localport and protocol? 如果我已经有了另一个名称,相同本地端口和协议的规则,该怎么办?

My command will overwrite that rule or it will create another one on same port? 我的命令会覆盖该规则,还是会在同一端口上创建另一个规则?

I've tried to find any documentation, but i've found nothing about that. 我试图找到任何文档,但对此一无所获。

There is a PowerShell module called NetSecurity. 有一个称为NetSecurity的PowerShell模块。 You can make a statement in powershell which can tell if the rule already exist or not. 您可以在powershell中进行声明,以判断该规则是否已经存在。

Get-NetFirewallRule you can use this command to discover which firewall rules are already defined. 您可以使用Get-NetFirewallRule命令来发现已经定义了哪些防火墙规则。

https://docs.microsoft.com/en-us/powershell/module/netsecurity/?view=win10-ps https://docs.microsoft.com/zh-CN/powershell/module/netsecurity/?view=win10-ps

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM