让 Windows 防火墙放行 ping(ICMP 回显)
添加允许 ICMPv4 回显请求的入站规则,让这台电脑可以被 ping 通。
以管理员身份运行 `netsh advfirewall firewall add rule name="Allow ICMPv4 Ping" protocol=icmpv4:8,any dir=in action=allow`,即可让电脑响应 ping。
01命令
命令
$ netsh advfirewall firewall add rule name="Allow ICMPv4 Ping" protocol=icmpv4:8,any dir=in action=allow02作用说明
Windows 防火墙默认丢弃传入的 ICMP 回显请求,所以其他设备 ping 这台电脑会显示超时,其实网络是正常的。这条 netsh 规则在所有配置文件上放行 ICMPv4 类型 8(回显请求)。如果只想在内网放行,可加参数 `profile=private`;需要响应 IPv6 的 ping,把协议改成 icmpv6:8,any 再建一条规则。
03风险
!注意: 响应 ping 会暴露你的机器。在公共 Wi-Fi 上建议加 profile=private,或用完即删除该规则。
04撤销
撤销
$ netsh advfirewall firewall delete rule name="Allow ICMPv4 Ping"05来源
- New-NetFirewallRule依据: Creates an inbound firewall rule; can be scoped to the ICMPv4 protocol to allow echo requests.
- netsh依据: Documents netsh WLAN commands including `netsh wlan show profile name=... key=clear` and `netsh wlan delete profile name=...`.
最后验证: 2026-09-18 · 分类: 网络