1. 命令行方式
1.1. 允许请求
# 允许 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
1.2. 禁用请求
实质上是添加了一条新规则对旧规则进行覆盖
# 禁用 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
1.3. 删除规则
!会删除所有匹配的规则,请谨慎使用
具体用法可以参考:netsh advfirewall firewall delete rule ?
# 删除规则
netsh advfirewall firewall delete rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in
2. 图形化界面
2.1. 打开 高级安全 Windows Defender 防火墙 界面
在 Windows 搜索框中(Win + S)输入 高级安全 Windows Defender 防火墙
(Windows Firewall with Advanced Security) 并打开
2.2. 启用 文件和打印机共享(回显请求 - ICMPv*-In)
- 单击左侧
入站规则
- 在入站规则中找到
文件和打印机共享(回显请求 - ICMPv*-In)
- 右键启用规则(或在右侧操作栏中 启用规则)
3. 参考
- 使用 netsh advfirewall 防火墙上下文 - Windows Server | Microsoft Docs https://docs.microsoft.com/zh-cn/troubleshoot/windows-server/networking/netsh-advfirewall-firewall-control-firewall-behavior
- How to Allow Pings (ICMP Echo Requests) Through Your Windows Firewall: https://www.howtogeek.com/howto/windows-vista/allow-pings-icmp-echo-request-through-your-windows-vista-firewall/
- 怎么在windows开启ping功能-百度经验 https://jingyan.baidu.com/article/f3e34a12ab7dc1f5ea653510.html
- 本文系个人学习总结,希望可以提供思路或参考,欢迎讨论和建议
- 署名:cc01cc: https://github.com/cc01cc
- 创建于:2022年6月30日
- 本作品采用知识共享署名-相同方式共享 4.0 国际许可协议进行许可
- 欢迎大家转载分享,转载请标明源地址,谢谢