# 允许 ICMPv4 请求
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow
# 允许 ICMPv6 请求
netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol=icmpv6:8,any dir=in action=allow
实质上是添加了一条新规则对旧规则进行覆盖
# 禁用 ICMPv4 请求
netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=block
# 禁用 ICMPv6 请求
netsh advfirewall firewall add rule name="ICMP Allow incoming V6 echo request" protocol=icmpv6:8,any dir=in action=block
!会删除所有匹配的规则,请谨慎使用
具体用法可以参考:netsh advfirewall firewall delete rule ?
# 删除规则
netsh advfirewall firewall delete rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in
在 Windows 搜索框中(Win + S)输入 高级安全 Windows Defender 防火墙 (Windows Firewall with Advanced Security) 并打开

入站规则文件和打印机共享(回显请求 - ICMPv*-In)