使用注册表查看 ICMP 类型设置
Use registry to see ICMP type settings
我想看看我的系统允许/启用了哪些 ICMP 类型。
我发现 this 您可以在哪里设置 ICMP,但是是否可以在注册表中查看这些设置或通过 powershell 命令获取它们?
使用 Get-NetFirewallRule
to enumerate the firewall rules. Use Get-NetFirewallPortFilter
获取有关这些规则正在过滤的内容的详细信息。过滤 ICMP 协议规则的输出,然后是 select ICMP 类型。
Get-NetFirewallRule -Enabled True -Action Allow |
Get-NetFirewallPortFilter |
Where-Object { $_.Protocol -in 'icmpv4', 'icmpv6' } |
Select-Object -Expand IcmpType -Unique
将 Allow
替换为 Block
以枚举阻止规则。
如果Get-NetFirewallRule
找不到规则,它将抛出错误。您可以通过在命令中添加 -ErrorAction SilentlyContinue
来抑制它。
请注意,*-NetFirewall*
cmdlet 是随 Windows Server 2012 引入的,在早期版本中不可用。对于那些你需要使用 netsh
命令的人。使用类似这样的东西来枚举防火墙规则
netsh advfirewall firewall show rule all
并解析相关信息的输出。
我想看看我的系统允许/启用了哪些 ICMP 类型。
我发现 this 您可以在哪里设置 ICMP,但是是否可以在注册表中查看这些设置或通过 powershell 命令获取它们?
使用 Get-NetFirewallRule
to enumerate the firewall rules. Use Get-NetFirewallPortFilter
获取有关这些规则正在过滤的内容的详细信息。过滤 ICMP 协议规则的输出,然后是 select ICMP 类型。
Get-NetFirewallRule -Enabled True -Action Allow |
Get-NetFirewallPortFilter |
Where-Object { $_.Protocol -in 'icmpv4', 'icmpv6' } |
Select-Object -Expand IcmpType -Unique
将 Allow
替换为 Block
以枚举阻止规则。
如果Get-NetFirewallRule
找不到规则,它将抛出错误。您可以通过在命令中添加 -ErrorAction SilentlyContinue
来抑制它。
请注意,*-NetFirewall*
cmdlet 是随 Windows Server 2012 引入的,在早期版本中不可用。对于那些你需要使用 netsh
命令的人。使用类似这样的东西来枚举防火墙规则
netsh advfirewall firewall show rule all
并解析相关信息的输出。